Expand description
A bounded, shared worker pool for blocking work (the M/M/c side of the hybrid design).
- Bounded queue.
OffloadPool::try_submitfails at once withRejected::Fullwhenmax_queuejobs are waiting; nothing grows without bound. - Workers on demand. A worker thread is started only when a job arrives and no worker is
idle, up to
max_threads; idle workers exit afteridle_timeout. - CoDel admission. Each job’s sojourn time (from submission until a worker takes it) is
measured. When it stays above
targetfor a wholeinterval, the pool reports overload and refuses new jobs withRejected::Overloadeduntil a job is taken faster thantargetagain (Nichols and Jacobson, “Controlling Queue Delay”, 2012). A server answers those with a fast 503 instead of queueing. The effective target is the larger oftargetand four times the jobs’ recent mean run time, so a pool of slow blocking jobs (100 ms calls to a database) does not shed because a job waits a few run times behind a burst: only a queue that keeps growing past what the workers can absorb is overload (K10: at the old one-run-time target, 500 clients of 100 ms jobs on 192 workers had nearly every request shed).
Structs§
- Offload
Config - Settings of an
OffloadPool. - Offload
Pool - A bounded shared worker pool. Cheap to clone. See the module docs.
- Offload
Stats - Counters of an
OffloadPool.
Enums§
- Rejected
- Why
OffloadPool::try_submitrefused a job.
Functions§
- default_
threads - The worker cap for
max_threads: 0: 32 per CPU, at least 512 and at most 1024. Sized for blocking integration calls like a thread-per-request server’s pool (a 100 ms handler needs about 10 threads per 100 requests per second; Cameleer’s pool is 1024); workers start on demand and exit afteridle_timeout, so the cap costs nothing until jobs block (K10).
Type Aliases§
- Job
- A unit of offloaded work.