Skip to content

A set asynchronous, non-blocking & parallelism problems to challenge your mind!

License

Notifications You must be signed in to change notification settings

jabrena/latency-problems

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Latency problems

Motivation

Euler problems are an excellent source of Mathematical problems to improve your programming skills. The problems are able to be solved with multiple programming paradigms like Object Oriented, Functional or Reactive.

But in the implementation process, I missed that the problems don´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, in Kotlin you can use Coroutines, in Scala you can use Future, in Clojure you can use Future.

On top of the languages, exist libraries that improve the way to manage asynchronous calls and add Backpressure support for Reactive use cases. In Reactor you can use Mono or Flux objects, in RxJava, you can use Flowable

Finally, exist libraries that offer rich implementations of Reactive programming patterns. In Resilience4j, you could find solutions for: Circuit breaking, Rate limiting, Bulkheading, Automatic retrying

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

Feature: Consume some REST God Services

Background: Decimal representation of `Zeus` is 122101117115

Scenario: Consume the APIs in a Happy path scenario
    Given a list of REST API about Greek, Roman & Nordic
    When  call and retrieve all API info
    Then  filter by god starting with `n`
    And   convert the names into a decimal format
    And   sum

Scenario: Consume the APIs considering some latency in the greek service
    Given a list of REST API about Greek, Roman & Nordic
    When  call and retrieve all API info from the good list
    Then  filter by god starting with `n`
    And   convert the names into a decimal format
    And   sum

Notes:

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:

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:

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: Consume a REST Greek God Service

Scenario: Consume the API in a Happy path case
    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`

Scenario: Force an internal Retry behaviour
    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`

Scenario: Consume the API with a bad response
    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`

Scenario: Consume the API with a corrupted response
    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`

Scenario: Test a bad internal configuration
    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:

Problem 7

Feature: Consume a REST Roman God Service

Scenario: Consume the API in a Happy path case
    Given a REST API about Roman gods
    When  the client sends the request
    And   execute a Circuit Breaker Policy
    Then  return all gods finishing the name with `s`

Scenario: Force an internal Circuit Breaker behaviour
    Given a REST API about Roman gods
    When  the client sends the request
    And   execute a Circuit Breaker Policy
    Then  return all gods finishing the name with `s`

Notes:

Problem 8

Feature: Consume a REST Indian God Service

Background:
A new REST API was deployed recently and the service 
doesn´t have the same capacity than other God Services.
It is necessary to protect the service with a rate limiter temporally
meanwhile the God Infrastructure is increasing the consumer capacity.

Scenario: Consume the API in a Happy path case
    Given a REST API about Indian gods
    When  the client sends the request
    And   execute a Rate limiter Policy
    Then  return all gods who contains in the name `a` & `i`

Scenario: Force a Rate limiter behaviour
    Given a REST API about Indian gods
    When  the client sends the request
    And   execute a Rate limiter Policy
    Then  return all gods who contains in the name `a` & `i`

Notes:

Problem 9

Feature: Consume a REST God Collector

Background:
The new REST God collector service has a high demand
and it is necessary to protect the internal subsystems from
high levels of concurrent traffic. 

Scenario: Consume the API in a Happy path case
    Given a REST API about God collector
    When  the client sends the request
    And   execute a Bulkhead Policy
    Then  return all gods

Scenario: Force a Bulkhead behaviour
    Given a REST API about God collector
    When  the client sends the request
    And   execute a Bulkhead Policy
    Then  return all gods

Notes:

Problem 9

Feature: Calculate the popularity of Indian gods in Mahabharata

Background:
The Mahabharata is one of the two major Sanskrit epics of ancient India 

Scenario: Calculate the influence of Indian gods in Mahabharata
    Given a REST API about Indian Gods
    When  the client sends the request
    Then  return the Top 3 indian gods mentioned in Mahabharata
    And   with presence in Wikipedia
    And   the number of hits in Mahabharata data source
       

Releases

No releases published

Packages

No packages published