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

Grace period before idle workers are stopped #89

Open
spacebat opened this issue May 18, 2024 · 3 comments
Open

Grace period before idle workers are stopped #89

spacebat opened this issue May 18, 2024 · 3 comments

Comments

@spacebat
Copy link

spacebat commented May 18, 2024

Hey, I'm using Poolex to control workers that send commands to kubernetes pods. When the worker exits the pod is stopped so as to avoid orphan pods piling up.

To reduce costs I'd like to have a lower workers_count and a larger max_overflow to scale up to meet workloads. Even when a docker image is cached on the kubernetes node, depending on the image it can take a few seconds for the pod become ready.

When into overflow, I'd like to amortise the cost of starting a pod by keeping the worker+pod alive and idle for a configurable grace period. The overflowed idle worker either becomes busy with a new command, or the period expires and the worker is killed, taking the pod with it.

I have an implementation that I'd be happy to firm up into a worthy contribution if you think this is a good idea:
develop...spacebat:poolex:grace-for-idle-workers

@spacebat
Copy link
Author

I also considered a behaviour for worker handling - all the decisions taken through the worker lifecycle, but that seemed like it would be more intrusive and risky.

@general-CbIC
Copy link
Owner

Hi 👋
Thanks for your issue!

It is a complicated and specific task. I am not sure about the implementation of adding a new entity type (or an abstraction covering IdleWorkers) to Poolex.

I need some time to think about it 🙏

@general-CbIC
Copy link
Owner

Hi, @spacebat !
Sorry for such a significant delay, and thank you for waiting.
I think adding a shutdown delay configuration for "overflowed" workers is a good idea.

I have some comments on your implementation. Would you still like to contribute that logic yourself? If so, we can discuss some points.

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

2 participants