mirror of
https://github.com/frappe/gunicorn.git
synced 2026-07-02 10:41:30 +08:00
docs: regenerate settings.md
This commit is contained in:
parent
1d0df29796
commit
1af599769f
@ -208,17 +208,38 @@ DirtyArbiter and the exiting DirtyWorker.
|
|||||||
|
|
||||||
Dirty applications to load in the dirty worker pool.
|
Dirty applications to load in the dirty worker pool.
|
||||||
|
|
||||||
A list of application paths in pattern ``$(MODULE_NAME):$(CLASS_NAME)``.
|
A list of application paths in one of these formats:
|
||||||
|
|
||||||
|
- ``$(MODULE_NAME):$(CLASS_NAME)`` - all workers load this app
|
||||||
|
- ``$(MODULE_NAME):$(CLASS_NAME):$(N)`` - only N workers load this app
|
||||||
|
|
||||||
Each dirty app must be a class that inherits from ``DirtyApp`` base class
|
Each dirty app must be a class that inherits from ``DirtyApp`` base class
|
||||||
and implements the ``init()``, ``__call__()``, and ``close()`` methods.
|
and implements the ``init()``, ``__call__()``, and ``close()`` methods.
|
||||||
|
|
||||||
Example::
|
Example::
|
||||||
|
|
||||||
dirty_apps = [
|
dirty_apps = [
|
||||||
"myapp.ml:MLApp",
|
"myapp.ml:MLApp", # All workers load this
|
||||||
"myapp.images:ImageApp",
|
"myapp.images:ImageApp", # All workers load this
|
||||||
|
"myapp.heavy:HugeModel:2", # Only 2 workers load this
|
||||||
]
|
]
|
||||||
|
|
||||||
|
The per-app worker limit is useful for memory-intensive applications
|
||||||
|
like large ML models. Instead of all 8 workers loading a 10GB model
|
||||||
|
(80GB total), you can limit it to 2 workers (20GB total).
|
||||||
|
|
||||||
|
Alternatively, you can set the ``workers`` class attribute on your
|
||||||
|
DirtyApp subclass::
|
||||||
|
|
||||||
|
class HugeModelApp(DirtyApp):
|
||||||
|
workers = 2 # Only 2 workers load this app
|
||||||
|
|
||||||
|
def init(self):
|
||||||
|
self.model = load_10gb_model()
|
||||||
|
|
||||||
|
Note: The config format (``module:Class:N``) takes precedence over
|
||||||
|
the class attribute if both are specified.
|
||||||
|
|
||||||
Dirty apps are loaded once when the dirty worker starts and persist
|
Dirty apps are loaded once when the dirty worker starts and persist
|
||||||
in memory for the lifetime of the worker. This is ideal for loading
|
in memory for the lifetime of the worker. This is ideal for loading
|
||||||
ML models, database connection pools, or other stateful resources
|
ML models, database connection pools, or other stateful resources
|
||||||
@ -226,6 +247,9 @@ that are expensive to initialize.
|
|||||||
|
|
||||||
!!! info "Added in 25.0.0"
|
!!! info "Added in 25.0.0"
|
||||||
|
|
||||||
|
!!! info "Changed in 25.1.0"
|
||||||
|
Added per-app worker allocation via ``:N`` format suffix.
|
||||||
|
|
||||||
### `dirty_workers`
|
### `dirty_workers`
|
||||||
|
|
||||||
**Command line:** `--dirty-workers INT`
|
**Command line:** `--dirty-workers INT`
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user