Solution

In the Actor programming model, an Actor can spawn other Actors. In such a scenario, the parent Actors are known as the supervisor and the Actors that it spawns are called subordinates. The subordinates carry out individual tasks of an operation that the supervisor is assigned to perform. The hierarchy may extend to deeper levels, that is, a subordinate may further delegate tasks to its subordinates and itself act as supervisor for those subordinates:

Managed Actors (Solution)

The role of supervisor is to aggregate the responses of the subordinates and report it to its parent, which may be the application itself or another supervisor.

In case of failures of one of the subordinates, the subordinate suspends its operations and reports the failure to its supervisor. The supervisor is responsible for managing failures. Based on the type of failure message, the supervisor can try to spawn the Actor again or message other Actors to rollback their operations.

The obvious benefit of this pattern is performance. Since the subordinates run concurrently, the over-all time it takes for the slowest subordinate to respond drives the performance of the system.

Another benefit of the pattern is the low cost of adding tasks to an operation. For example, to add a new task to an operation, you can add an independent subordinate to the hierarchy. The addition of new subordinate will not add latency to the system as the overall response time is still the response time of the slowest subordinate. You can find this pattern used widely in Netflix and LinkedIn.

Combining this pattern with Remindable Actors pattern can add resiliency and fault tolerance to your application.

The supervisor after sending a message to a subordinate can send a scheduled timeout reminder message to itself. If the subordinate responds before the message appears, then the message is discarded. If the response is not received or received after the timeout message appears, the missing information is either ignored or substituted with a default value. Thus, a failing service or a slow responding service will not break the application.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.92.105