Most code doesn't need to use this directly; instead use
library(http/http_server), which combines this library with the
typical HTTP libraries that most servers need.
This module defines hooks into the HTTP framework to dynamically
schedule worker threads. Dynamic scheduling relieves us from finding a
good value for the size of the HTTP worker pool.
The decision to add a worker follows these rules:
- If the load average caused by the worker threads exceeds
http:max_load, no worker is added.
- Wait for some time, depending on how close we are to the
http:max_workers limit.
- If the worker is still needed, add it.
The policy depends on three settings:
- http:max_workers
- The maximum number of workers that will be created. Default is
100.
- http:worker_idle_limit
- The number of seconds a dynamic worker waits for a new job. If
no job arrives in time it terminates. Default is 10 seconds.
- http:max_load
- Max load average created by the HTTP server, i.e. the amount
of CPU time consumed per second. Default is 10.
- http:schedule_workers(+Dict)[multifile]
- Called if there is no immediately free worker to handle the
incomming request. The request is forwarded to the thread
__http_scheduler
as the hook is called in time critical code.
- reschedule(+Message, +State0, -State) is semidet[private]
- accept_queue(+Dict, -Queue)[private]
- As of 7.7.16,
queue
is a member of the provided dict. For older
versions we need a hack.