Make it possible to not add requests to 'waiting' queue in poolboy#27
Open
eugenebolshakov wants to merge 4 commits into
Open
Make it possible to not add requests to 'waiting' queue in poolboy#27eugenebolshakov wants to merge 4 commits into
eugenebolshakov wants to merge 4 commits into
Conversation
When `:poolboy.transaction/3` is used, poolboy puts the request into a 'waiting' queue if all workers are busy. The caller is then blocked until a worker becomes available and the request is processed (or passed timeout value is reached). This is helpful during short load spikes, however if the overload is sustained, the queue can become too expensive to manage: poolboy uses `:queue.filter/2` to remove items from the queue, which is an O(n) operation. It may be preferable to not add a request to the queue and abandon it immediately if all workers are busy to avoid overloading the pool and ensuring that new requests that come in don't have to wait for the ever-growing queue of previous requests is processed. This commit adds a configuration option for disabling adding a request to the 'waiting' queue: poolboy allows to do that when `:poolboy.checkout/3` is used instead of `:poolboy.transaction/3`. The default value for the option is `true`, which is the current behaviour.
`:poolboy.checkout/3` returns `:full` or a pid [1]:
-spec checkout(Pool :: pool(), Block :: boolean()) -> pid() | full.
When `:poolboy.checkout/3` returns `:full`, an error should be
returned indicating that the pool is full.
[1] https://github.com/devinus/poolboy/blob/1.5.0/src/poolboy.erl#L46
*Problem* Some transport options are invalid when passed to the tcp transport, but machine_gun pools are specified not for a specific host-port pair but for a so called "pool group", this means that options set for the ssl transport are being passed to the tcp transport and causing failure. *Solution* Drop invalid options depending on the given transport. Currently only `verify`, as that is the option that is being specified.
sanitize transport options
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
:poolboy.transaction/3is used, poolboy puts the request into a'waiting' queue if all workers are busy. The caller is then blocked until a
worker becomes available and the request is processed (or passed timeout value
is reached). This is helpful during short load spikes, however if the overload
is sustained, the queue can become too expensive to manage: poolboy uses
:queue.filter/2to remove items from the queue, which is an O(n) operation.It may be preferable to not add a request to the queue and abandon it
immediately if all workers are busy to avoid overloading the pool and ensuring
that new requests that come in don't have to wait for the ever-growing queue of
previous requests is processed.
This commit adds a configuration option for disabling adding a request to the
'waiting' queue: poolboy allows to do that when
:poolboy.checkout/3is usedinstead of
:poolboy.transaction/3. The default value for the option istrue, which is the current behaviour.