AnyEvent-Fork-Pool
view release on metacpan or search on metacpan
These parameters are all passed more or less directly to
L<AnyEvent::Fork::RPC>. They are only briefly mentioned here, for
their full documentation please refer to the L<AnyEvent::Fork::RPC>
documentation. Also, the default values mentioned here are only documented
as a best effort - the L<AnyEvent::Fork::RPC> documentation is binding.
=over 4
=item async => $boolean (default: 0)
Whether to use the synchronous or asynchronous RPC backend.
=item on_error => $callback->($message) (default: die with message)
The callback to call on any (fatal) errors.
=item on_event => $callback->(...) (default: C<sub { }>, unlike L<AnyEvent::Fork::RPC>)
The callback to invoke on events.
=item init => $initfunction (default: none)
and AnyEvent::Fork::Pool::retire ();
... normal code goes here
}
=back
=head1 POOL PARAMETERS RECIPES
This section describes some recipes for pool parameters. These are mostly
meant for the synchronous RPC backend, as the asynchronous RPC backend
changes the rules considerably, making workers themselves responsible for
their scheduling.
=over 4
=item low latency - set load = 1
If you need a deterministic low latency, you should set the C<load>
parameter to C<1>. This ensures that never more than one job is sent to
each worker. This avoids having to wait for a previous job to finish.
This makes most sense with the synchronous (default) backend, as the
asynchronous backend can handle multiple requests concurrently.
=item lowest latency - set load = 1 and idle = max
To achieve the lowest latency, you additionally should disable any dynamic
resizing of the pool by setting C<idle> to the same value as C<max>.
=item high throughput, cpu bound jobs - set load >= 2, max = #cpus
To get high throughput with cpu-bound jobs, you should set the maximum
pool size to the number of cpus in your system, and C<load> to at least
AnyEvent::Fork::RPC Parameters
These parameters are all passed more or less directly to
AnyEvent::Fork::RPC. They are only briefly mentioned here, for
their full documentation please refer to the AnyEvent::Fork::RPC
documentation. Also, the default values mentioned here are only
documented as a best effort - the AnyEvent::Fork::RPC
documentation is binding.
async => $boolean (default: 0)
Whether to use the synchronous or asynchronous RPC backend.
on_error => $callback->($message) (default: die with message)
The callback to call on any (fatal) errors.
on_event => $callback->(...) (default: "sub { }", unlike
AnyEvent::Fork::RPC)
The callback to invoke on events.
init => $initfunction (default: none)
The function to call in the child, once before handling
sub my::worker {
++$count == 100
and AnyEvent::Fork::Pool::retire ();
... normal code goes here
}
POOL PARAMETERS RECIPES
This section describes some recipes for pool parameters. These are
mostly meant for the synchronous RPC backend, as the asynchronous RPC
backend changes the rules considerably, making workers themselves
responsible for their scheduling.
low latency - set load = 1
If you need a deterministic low latency, you should set the "load"
parameter to 1. This ensures that never more than one job is sent to
each worker. This avoids having to wait for a previous job to
finish.
This makes most sense with the synchronous (default) backend, as the
asynchronous backend can handle multiple requests concurrently.
lowest latency - set load = 1 and idle = max
To achieve the lowest latency, you additionally should disable any
dynamic resizing of the pool by setting "idle" to the same value as
"max".
high throughput, cpu bound jobs - set load >= 2, max = #cpus
To get high throughput with cpu-bound jobs, you should set the
maximum pool size to the number of cpus in your system, and "load"
to at least 2, to make sure there can be another job waiting for the
( run in 0.241 second using v1.01-cache-2.11-cpan-0d8aa00de5b )