{"id":16169447,"url":"https://github.com/jabrena/latency-problems","last_synced_at":"2025-03-18T23:31:01.749Z","repository":{"id":73643641,"uuid":"195648582","full_name":"jabrena/latency-problems","owner":"jabrena","description":"A set asynchronous, non-blocking \u0026 parallelism problems to challenge your mind!","archived":false,"fork":false,"pushed_at":"2019-09-30T17:04:54.000Z","size":87,"stargazers_count":32,"open_issues_count":2,"forks_count":2,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-02-28T13:18:05.448Z","etag":null,"topics":["completablefuture","coroutines","euler","flux","future","java","kotlin","latency","loom","mono","rxjava2","wiremock","zio"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jabrena.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-07-07T12:29:09.000Z","updated_at":"2025-02-24T18:28:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"92bf56cf-aca3-42f5-bafb-f40fabe9bcfb","html_url":"https://github.com/jabrena/latency-problems","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabrena%2Flatency-problems","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabrena%2Flatency-problems/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabrena%2Flatency-problems/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabrena%2Flatency-problems/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jabrena","download_url":"https://codeload.github.com/jabrena/latency-problems/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243955750,"owners_count":20374373,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["completablefuture","coroutines","euler","flux","future","java","kotlin","latency","loom","mono","rxjava2","wiremock","zio"],"created_at":"2024-10-10T03:14:55.401Z","updated_at":"2025-03-18T23:31:01.742Z","avatar_url":"https://github.com/jabrena.png","language":null,"readme":"# Latency problems\n\n## Motivation\n\n[Euler problems](https://projecteuler.net/archives) are an excellent source of Mathematical\nproblems to improve your programming skills. The problems are able to be solved with multiple \nprogramming paradigms like Object Oriented, Functional or Reactive.\n\nBut in the implementation process, I missed that the problems don´t add any Latency factor to\nincrease the complexity and this is part of the daily problems for every Software Engineer in the market.\n\nProgramming languages provide native solutions to manage latency.\nIn `Java`, you can use [CompletableFuture](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html), \nin `Kotlin` you can use [Coroutines](https://kotlinlang.org/docs/reference/coroutines-overview.html), \nin `Scala` you can use [Future](https://www.scala-lang.org/api/2.12.3/scala/concurrent/Future.html),\nin `Clojure` you can use [Future](https://clojuredocs.org/clojure.core/future).\n\nOn top of the languages, exist libraries that improve the way to manage [asynchronous](https://www.reactivemanifesto.org/glossary#Asynchronous) calls \nand add [Backpressure](https://www.reactivemanifesto.org/glossary#Back-Pressure) support for Reactive use cases. In `Reactor` you can use [Mono\u003cT\u003e](https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html) or \n[Flux\u003cT\u003e](https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Flux.html) objects,\nin `RxJava`, you can use [Flowable\u003cT\u003e](http://reactivex.io/RxJava/2.x/javadoc/io/reactivex/Flowable.html) \n\nFinally, exist libraries that offer rich implementations of Reactive programming patterns.\nIn `Resilience4j`, you could find solutions for: `Circuit breaking`, `Rate limiting`, `Bulkheading`, `Automatic retrying`\n\nThe purpose of this repository is the creation of a set problems adding the Latency as part of the problem to be solved\nin many different ways.\n\nEnjoy the journey!\n\nJuan Antonio Breña Moral\n\n## Problems\n\n### Problem 1\n\n``` gherkin \nFeature: Consume some REST God Services\n\nBackground: Decimal representation of `Zeus` is 122101117115\n\nScenario: Consume the APIs in a Happy path scenario\n    Given a list of REST API about Greek, Roman \u0026 Nordic\n    When  call and retrieve all API info\n    Then  filter by god starting with `n`\n    And   convert the names into a decimal format\n    And   sum\n\nScenario: Consume the APIs considering some latency in the greek service\n    Given a list of REST API about Greek, Roman \u0026 Nordic\n    When  call and retrieve all API info from the good list\n    Then  filter by god starting with `n`\n    And   convert the names into a decimal format\n    And   sum\n```\n\n![](./docs/sequence-diagram-latency-problem1.svg)\n\n**Notes:** \n\n- Review the timeout for Every connection.\n- If in the process to load the list, the timeout is reached, the process will calculate with the rest of\nthe lists.\n- REST API: https://my-json-server.typicode.com/jabrena/latency-problems\n\n\n### Problem 2\n\nGreek gods are quite popular and they have presence in Wikipedia, the multilingual online encyclopedia.\nIf you try to find further information about `Zeus` you should visit the address: https://en.wikipedia.org/wiki/Zeus\n\nLoad the list of Greek Gods and discover what is the God with more literature described on Wikipedia.\n\n![](./docs/sequence-diagram-latency-problem2.svg)\n\n**Notes:** \n\n- Review the timeout for Every connection.\n- REST API 1: https://my-json-server.typicode.com/jabrena/latency-problems/greek\n- REST API 2: https://en.wikipedia.org/wiki/{greekGod}\n\n### Problem 3\n\n\nGod fans are using a new API to provide information about `GREEK`, `ROMAN` or `NORDIC` gods.\nIt is important that the interface support Concurrent access to the API. Provide a Test that ensure\nthat in a Concurrent scenario, the information retrieved is `Thread Safe`.\n\n![](./docs/sequence-diagram-latency-problem3.svg)\n\n\n**Notes:** \n\n- Review the timeout for Every connection.\n- REST API 1: https://my-json-server.typicode.com/jabrena/latency-problems/greek\n\n\n### Problem 4\n\n``` gherkin\nGiven a set of providers to exchange money \nWhen  make the request to get the rate for the exchange 100 EUR into USD\nThen  find the average rate from valid responses from the the providers\n```\n\n![](./docs/sequence-diagram-latency-problem4.svg)\n\n**Notes:** \nReview the timeout for Every connection.\nMoney exchange providers:\n- https://transferwise.com/fr?sourceCurrency=EUR\u0026targetCurrency=USD\u0026sourceAmount=100\n- https://www.xe.com/es/currencyconverter/convert/?Amount=100\u0026From=EUR\u0026To=USD\n- https://www.iban.com/currency-converter?from_currency=EUR\u0026to_currency=USD\u0026amount=100\n- https://www.x-rates.com/calculator/?from=EUR\u0026to=USD\u0026amount=100\n\n\n### Problem 5\n\n``` gherkin\nFeature: Load Balancing\n\nScenario: Consume a REST Greek God Service\n    Given a 5 instances of the same REST API about Greek gods\n    When  the client sends the request\n    And   execute a load balancing policy to distribute the traffic\n    Then  return all gods starting with `a`\n```\n\n![](./docs/sequence-diagram-latency-problem5.svg)\n\n**Notes:** \n\n- Try to test the solution without any Internet call\n- Review the timeout for Every connection.\n- Review the load balancing options\n- REST API 1: https://my-json-server.typicode.com/jabrena/latency-problems/greek\n\n### Problem 6\n\n``` gherkin\nFeature: Consume a REST Greek God Service\n\nScenario: Consume the API in a Happy path case\n    Given a REST API about Greek gods\n    When  the client sends the request\n    And   execute a Retry Policy\n    Then  return all gods starting with `a`\n\nScenario: Force an internal Retry behaviour\n    Given a REST API about Greek gods\n    When  the client sends the request\n    And   execute a Retry Policy\n    Then  return all gods starting with `a`\n\nScenario: Consume the API with a bad response\n    Given a REST API about Greek gods\n    When  the client sends the request\n    And   execute a Retry Policy\n    Then  return all gods starting with `a`\n\nScenario: Consume the API with a corrupted response\n    Given a REST API about Greek gods\n    When  the client sends the request\n    And   execute a Retry Policy\n    Then  return all gods starting with `a`\n\nScenario: Test a bad internal configuration\n    Given a REST API about Greek gods\n    When  the client sends the request\n    And   execute a Retry Policy\n    Then  return all gods starting with `a`\n\n```\n\n![](./docs/sequence-diagram-latency-problem6.svg)\n\n**Notes:** \n\n- Try to test the solution without any Internet call\n- Review the timeout for Every connection.\n- Review the retry options\n- REST API 1: https://my-json-server.typicode.com/jabrena/latency-problems/greek\n\n\n### Problem 7\n\n``` gherkin\nFeature: Consume a REST Roman God Service\n\nScenario: Consume the API in a Happy path case\n    Given a REST API about Roman gods\n    When  the client sends the request\n    And   execute a Circuit Breaker Policy\n    Then  return all gods finishing the name with `s`\n\nScenario: Force an internal Circuit Breaker behaviour\n    Given a REST API about Roman gods\n    When  the client sends the request\n    And   execute a Circuit Breaker Policy\n    Then  return all gods finishing the name with `s`\n\n```\n\n![](./docs/sequence-diagram-latency-problem7.svg)\n\n**Notes:** \n\n- Try to test the solution without any Internet call\n- Review the timeout for Every connection.\n- Review the circuit breaker options\n- REST API 1: https://my-json-server.typicode.com/jabrena/latency-problems/roman\n\n### Problem 8\n\n``` gherkin\nFeature: Consume a REST Indian God Service\n\nBackground:\nA new REST API was deployed recently and the service \ndoesn´t have the same capacity than other God Services.\nIt is necessary to protect the service with a rate limiter temporally\nmeanwhile the God Infrastructure is increasing the consumer capacity.\n\nScenario: Consume the API in a Happy path case\n    Given a REST API about Indian gods\n    When  the client sends the request\n    And   execute a Rate limiter Policy\n    Then  return all gods who contains in the name `a` \u0026 `i`\n\nScenario: Force a Rate limiter behaviour\n    Given a REST API about Indian gods\n    When  the client sends the request\n    And   execute a Rate limiter Policy\n    Then  return all gods who contains in the name `a` \u0026 `i`\n\n```\n\n![](./docs/sequence-diagram-latency-problem8.svg)\n\n**Notes:** \n\n- Try to test the solution without any Internet call\n- Review the timeout for Every connection.\n- Review the rate limiter options\n- REST API 1: https://my-json-server.typicode.com/jabrena/latency-problems/indian\n\n### Problem 9\n\n``` gherkin\nFeature: Consume a REST God Collector\n\nBackground:\nThe new REST God collector service has a high demand\nand it is necessary to protect the internal subsystems from\nhigh levels of concurrent traffic. \n\nScenario: Consume the API in a Happy path case\n    Given a REST API about God collector\n    When  the client sends the request\n    And   execute a Bulkhead Policy\n    Then  return all gods\n\nScenario: Force a Bulkhead behaviour\n    Given a REST API about God collector\n    When  the client sends the request\n    And   execute a Bulkhead Policy\n    Then  return all gods\n```\n\n![](./docs/sequence-diagram-latency-problem9.svg)\n\n\n**Notes:** \n\n- Try to test the solution without any Internet call\n- Review the timeout for Every connection.\n- Review the bulkhead options\n- REST API 1: https://my-json-server.typicode.com/jabrena/latency-problems/greek\n- REST API 2: https://my-json-server.typicode.com/jabrena/latency-problems/roman\n\n### Problem 9\n\n``` gherkin\nFeature: Calculate the popularity of Indian gods in Mahabharata\n\nBackground:\nThe Mahabharata is one of the two major Sanskrit epics of ancient India \n\nScenario: Calculate the influence of Indian gods in Mahabharata\n    Given a REST API about Indian Gods\n    When  the client sends the request\n    Then  return the Top 3 indian gods mentioned in Mahabharata\n    And   with presence in Wikipedia\n    And   the number of hits in Mahabharata data source\n       \n```\n\n![](./docs/sequence-diagram-latency-problem9-1.svg)\n\n\n- Try to test the solution without any Internet call\n- Review the timeout for Every connection.\n- REST API 1: https://my-json-server.typicode.com/jabrena/latency-problems/indian\n- Mahabharata Data Source: https://archive.org/stream/TheMahabharataOfKrishna-dwaipayanaVyasa/MahabharataOfVyasa-EnglishTranslationByKMGanguli_djvu.txt\n- REST API 2: https://en.wikipedia.org/wiki/{indianGod}\n\n## [Troubleshooting](./TROUBLESHOOTING.md)\n\n## [References](./REFERENCES.md)\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjabrena%2Flatency-problems","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjabrena%2Flatency-problems","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjabrena%2Flatency-problems/lists"}