Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-scaling actor wrapper #14

Open
TylerBloom opened this issue Apr 12, 2024 · 0 comments
Open

Auto-scaling actor wrapper #14

TylerBloom opened this issue Apr 12, 2024 · 0 comments

Comments

@TylerBloom
Copy link
Owner

About

A useful actor pattern is an actor that spawns and deletes worker actors to scale with the traffic it is receiving. This will require a change to the actor client and the base stream that is used by the actor runtime.

Design

The work actors will be created by a function that is given to the manager state. This closure will be called whenever the manager needs to spawn a new worker. Instead of the standard unbounded channel, each worker will have a bounded channel of some small capacity (say, 10 message). The manager will even distribute messages between workers. If at any point it finds that it can not pass on the message to any worker, it will spawn a new worker and pass the message on to it. Every worker will have a timeout duration. If the worker goes that length of time or longer without processing a message, it will be shutdown (either by itself or the manager).

Requirements

This design will require a change to the message passing model. Currently, SinkActors only ever have an unbounded channel through which it can receive message. This was a decision made prior to this crate being standalone. It would be ideal to generalize this so that users can pick their preferred channel types to use as well as enabling this feature.

Alternative

Backpressure is a requirement. If generalizing over channel types is too difficult, a secondary stream that contains a bounded channel can be attached, and the manager can forward messages via that channel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant