Giter Site home page Giter Site logo

latency-problems's Introduction

latency-problems

Motivation

Euler problems are an excellent source of Mathematical problems to improve your programming skills. The problems are able to be solved in many different ways using an Object Oriented, Functional or Reactive approaches.

But in the implementation process, I missed that the problem doesn´t add any Latency factor to increase the complexity and this is part of the daily problems for every Software Engineer in the market.

Programming languages provide native solutions to manage latency. In Java, you can use CompletableFuture objects, in Kotlin you can use Coroutines, in Scala you can use Future, On top of the languages, exist libraries that refine the ideas and new features. In Reactor you can use Mono or Flux objects.

The purpose of this repository is the creation of a set problems adding the Latency as part of the problem to be solved in many different ways.

Enjoy the journey!

Juan Antonio Breña Moral

Problems

Problem 1

Ancient European peoples worshiped many gods like Greek, Roman & Nordic gods. Every God is possible to be represented as the concatenation of every character converted in Decimal. Zeus = 122101117115

Load the list of Gods and find the sum of God names starting with the letter n.

Notes: Review the timeout for Every connection. If in the process to load the list, the timeout is reached, the process will calculate with the rest of the lists. REST API: https://my-json-server.typicode.com/jabrena/latency-problems

Problem 2

Greek gods are quite popular and they have presence in Wikipedia, the multilingual online encyclopedia. If you try to find further information about Zeus you should visit the address: https://en.wikipedia.org/wiki/Zeus

Load the list of Greek Gods and discover what is the God with more literature described on Wikipedia.

Notes: Review the timeout for Every connection. REST API 1: https://my-json-server.typicode.com/jabrena/latency-problems/greek REST API 2: https://en.wikipedia.org/wiki/{greekGod}

Problem 3

God fans are using a new API to provide information about GREEK, ROMAN or NORDIC gods. It is important that the interface support Concurrent access to the API. Provide a Test that ensure that in a Concurrent scenario, the information retrieved is Thread Safe.

Notes: Review the timeout for Every connection. REST API 1: https://my-json-server.typicode.com/jabrena/latency-problems/greek

Problem 4

Given a set of providers to exchange money 
When  make the request to get the rate for the exchange 100 EUR into USD
Then  find the average rate from valid responses from the the providers

Notes: Review the timeout for Every connection. Money exchange providers:

Problem 5

Feature: Load Balancing

Scenario: Consume a REST Greek God Service
    Given a 5 instances of the same REST API about Greek gods
    When  the client sends the request
    And   execute a load balancing policy to distribute the traffic
    Then  return all gods starting with `a`

Notes:

Problem 6

Feature: Retry

Scenario: Consume a REST Greek God Service
    Given a REST API about Greek gods
    When  the client sends the request
    And   execute a Retry Policy
    Then  return all gods starting with `a`

Notes:

Troubleshooting

How to know the maximum native threads in your system?

OSX: sysctl kern.num_threads
OSX: ulimit -u
Linux: cat /proc/sys/kernel/threads-max

What happen if I receive pthread_create failed (EAGAIN)?

If you receive the following error message in your tests:

[26.110s][warning][os,thread] Failed to start thread - pthread_create failed (EAGAIN) for attributes: 
stacksize: 1024k, guardsize: 4k, detached.
Process finished with exit code 130 (interrupted by signal 2: SIGINT)
Caused by: java.lang.OutOfMemoryError: unable to create native thread: possibly out of memory or 
process/resource limits reached

Review the Test and implementation, it is possible that you are reaching the limit of your hardware.

References

latency-problems's People

Contributors

jabrena avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.