dashbitco / nimble_pool

A tiny resource-pool implementation for Elixir
347 stars 20 forks source link

Terminate idle resources #22

Closed oliveigah closed 2 years ago

oliveigah commented 3 years ago

https://github.com/dashbitco/nimble_pool/issues/1

Known problems with the implementantion:

oliveigah commented 3 years ago

@josevalim Thanks for the feedback!

Just finished the requested changes, let me know if you see some other way I can improve the feature.

Also, I've added a disclaimer section on the docs related to the known implementations issues on the PR description.

Gonna remove them on the follow up PRs.

oliveigah commented 2 years ago

@josevalim @ericmj @xinz

Thank you for the feedback! I've just added a commit that tackles the problem:

On large pools, if many resources goes idle at the same cycle you may end up terminating a large amount of workers sequentially, what could lead to the pool being unable to fulfill requests.

I've added a pool configuration option called :max_idle_pings which defines a limit to the number of workers that can be pinged for each cycle of the handle_ping/2 optional callback. Defaults to nil, which is no limit.

There are two behaviours I think it is important to keep in mind:

Let me know what you think! :smiley:

oliveigah commented 2 years ago

@josevalim Thanks for the feedback. Just finished the suggested improvements.

Let me know if you see some other way to make it better!

josevalim commented 2 years ago

:green_heart: :blue_heart: :purple_heart: :yellow_heart: :heart: