-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Backpressure in ActorPools #28
Comments
I see there's a similar issue #3, though that seems more generic than just for pools. I'd be ok with either - making it more generic for actors and pools, or being a specific pool implementation detail. |
Hi @johnpyp
Could you clarify this a little? Do you mean calling Would the |
Right, the latter, i.e "send_async_when_available().await" The first option of just using .send doesn't work because it only fills up a one actor at a time, so I'd have to set up a parallel feeder anyways, kind of defeating the purpose. |
I see, I think this could be easily achieved using a I wonder if this should simply be the behaviour of Though, is this issue specific to the actor pool? Or is this the same thing with regular actors too I wonder. |
On second thought, I think changing regular actors to use bounded channels would likely be beneficial in that unbounded channels are definitely a potential for a memory leak, and using bounded channels would also close this issue. |
Closed in #29 |
For single-actors I think the unbounded channels work fine, because implicitly they're sequential, conceptually (of course you can do more complex things).
However for actor pools, I want the ability to fill up all the actors in a given pool, and not keep spamming messages until they're ready to accept some more. I can't use
.send().await
like I would in a normal actor, because that's effectively just making the pool meaningless. I can'tsend_async
unless it's trivially small data, because it's not going to have any backpressure, and will effectively memory leak.In this case, I think it's fine to have a model of something like...
This does of course have an implicit race condition, which probably doesn't matter for a lot of use cases, but it could be baked into another send method like...
For users who want more backpressure than the pool actor count provides, they can easily add a buffered channel on top of this (or another actor itself that buffers).
The text was updated successfully, but these errors were encountered: