class uwsgiconf.options.workers_cheapening.Algo(*args, **kwargs)
class uwsgiconf.options.workers_cheapening.AlgoSpare(*args, **kwargs)

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(*, check_interval_overload=None)
Parameters:check_interval_overload (int) – Interval (sec) to wait after all workers are busy before new worker spawn.
class uwsgiconf.options.workers_cheapening.AlgoSpare2(*args, **kwargs)

This algorithm is similar to spare, but suitable for large scale by increase workers faster (before overload) and decrease them slower.

set_basic_params(*, check_interval_idle=None)
Parameters:check_interval_idle (int) – Decrease workers after specified idle. Default: 10.
class uwsgiconf.options.workers_cheapening.AlgoQueue(*args, **kwargs)

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.

set_basic_params(*, check_num_overload=None)
Parameters:check_num_overload (int) – Number of backlog items in queue.
class uwsgiconf.options.workers_cheapening.AlgoBusyness(*args, **kwargs)

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.


Requires cheaper_busyness plugin.

set_basic_params(*, check_interval_busy=None, busy_max=None, busy_min=None, idle_cycles_max=None, idle_cycles_penalty=None, verbose=None)
  • check_interval_busy (int) – Interval (sec) to check worker busyness.
  • busy_max (int) – Maximum busyness (percents). Every time the calculated busyness is higher than this value, uWSGI will spawn new workers. Default: 50.
  • busy_min (int) – 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.
  • idle_cycles_max (int) – This option tells uWSGI how many idle cycles are allowed before stopping a worker.
  • idle_cycles_penalty (int) – Number of idle cycles to add to idle_cycles_max in case worker spawned too early. Default is 1.
  • verbose (bool) – Enables debug logs for this algo.
set_emergency_params(*, workers_step=None, idle_cycles_max=None, queue_size=None, queue_nonzero_delay=None)

Sets busyness algorithm emergency workers related params.

Emergency workers could be spawned depending upon uWSGI backlog state.


These options are Linux only.

  • workers_step (int) – Number of emergency workers to spawn. Default: 1.
  • idle_cycles_max (int) – Idle cycles to reach before stopping an emergency worker. Default: 3.
  • queue_size (int) – Listen queue (backlog) max size to spawn an emergency worker. Default: 33.
  • queue_nonzero_delay (int) – If the request listen queue is > 0 for more than given amount of seconds new emergency workers will be spawned. Default: 60.
class uwsgiconf.options.workers_cheapening.AlgoManual(*args, **kwargs)

Algorithm allows to adjust number of workers using Master FIFO commands.

class uwsgiconf.options.workers_cheapening.Cheapening(*args, **kwargs)

uWSGI provides the ability to dynamically scale the number of running workers (adaptive process spawning) via pluggable algorithms.


This uses master process.

class algorithms

Algorithms available to use with cheaper_algorithm.


alias of AlgoBusyness


alias of AlgoManual


alias of AlgoQueue


alias of AlgoSpare


alias of AlgoSpare2

set_basic_params(*, spawn_on_request=None, cheaper_algo=None, workers_min=None, workers_startup=None, workers_step=None)
  • spawn_on_request (bool) – Spawn workers only after the first request.
  • cheaper_algo (Algo) – The algorithm object to be used used for adaptive process spawning. Default: spare. See .algorithms.
  • workers_min (int) –

    Minimal workers count. Enables cheaper mode (adaptive process spawning).


    Must be lower than max workers count.

  • workers_startup (int) – 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.
  • workers_step (int) – Number of additional processes to spawn at a time if they are needed,
set_memory_limits(*, rss_soft=None, rss_hard=None)

Sets worker memory limits for cheapening.

  • rss_soft (int) –

    Don’t spawn new workers if total resident memory usage of all workers is higher than this limit in bytes.


    This option expects memory reporting enabled: .logging.set_basic_params(memory_report=1)

  • rss_hard (int) – Try to stop workers if total workers resident memory usage is higher that thi limit in bytes.

Print out enabled cheaper algorithms.