Skip to content

Make it possible to not add requests to 'waiting' queue in poolboy#27

Open
eugenebolshakov wants to merge 4 commits into
petrohi:masterfrom
bbc:master
Open

Make it possible to not add requests to 'waiting' queue in poolboy#27
eugenebolshakov wants to merge 4 commits into
petrohi:masterfrom
bbc:master

Conversation

@eugenebolshakov

Copy link
Copy Markdown

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.

Eugene Bolshakov and others added 4 commits June 14, 2021 15:01
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.
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

Successfully merging this pull request may close these issues.

3 participants