Cheapening¶
Classes¶
AlgoBusyness¶
Algorithm adds or removes workers based on average utilization for a given time period. It's goal is to keep more workers than the minimum needed available at any given time, so the app will always have capacity for new requests.
Note
Requires cheaper_busyness plugin.
set_basic_params¶
-
Interval (sec) to check worker busyness.
-
Maximum busyness (percents). Every time the calculated busyness is higher than this value, uWSGI will spawn new workers. Default: 50.
-
Minimum busyness (percents). If busyness is below this value, the app is considered in an "idle cycle" and uWSGI will start counting them. Once we reach needed number of idle cycles uWSGI will kill one worker. Default: 25.
-
This option tells uWSGI how many idle cycles are allowed before stopping a worker.
-
Number of idle cycles to add to
idle_cycles_maxin case worker spawned too early. Default is 1. -
Enables debug logs for this algo.
set_emergency_params¶
-
Number of emergency workers to spawn. Default: 1.
-
Idle cycles to reach before stopping an emergency worker. Default: 3.
-
Listen queue (backlog) max size to spawn an emergency worker. Default: 33.
-
If the request listen queue is > 0 for more than given amount of seconds new emergency workers will be spawned. Default: 60.
Sets busyness algorithm emergency workers related params.
Emergency workers could be spawned depending upon uWSGI backlog state.
Note
These options are Linux only.
AlgoManual¶
Algorithm allows to adjust number of workers using Master FIFO commands.
AlgoQueue¶
If the socket's listen queue has more than cheaper_overload requests
waiting to be processed, uWSGI will spawn new workers.
If the backlog is lower it will begin killing processes one at a time.
.. note: Only available on Linux and only on TCP sockets (not UNIX domain sockets).
set_basic_params¶
AlgoSpare¶
The default algorithm.
If all workers are busy for a certain amount of time seconds then uWSGI will spawn new workers. When the load is gone it will begin stopping processes one at a time.
set_basic_params¶
AlgoSpare2¶
This algorithm is similar to spare, but suitable for large scale
by increase workers faster (before overload) and decrease them slower.
set_basic_params¶
Cheapening¶
uWSGI provides the ability to dynamically scale the number of running workers (adaptive process spawning) via pluggable algorithms.
Note
This uses master process.
set_basic_params¶
-
Spawn workers only after the first request.
-
The algorithm object to be used for adaptive process spawning. Default:
spare. See.algorithms. -
Minimal workers count. Enables cheaper mode (adaptive process spawning).
1.. note:: Must be lower than max workers count. -
The number of workers to be started when starting the application. After the app is started the algorithm can stop or start workers if needed.
-
Number of additional processes to spawn at a time if they are needed,
set_memory_limits¶
-
Don't spawn new workers if total resident memory usage of all workers is higher than this limit in bytes.
Warning
This option expects memory reporting enabled:
.logging.set_basic_params(memory_report=1) -
Try to stop workers if total workers resident memory usage is higher that thi limit in bytes.
Sets worker memory limits for cheapening.