From 1af599769f398dbeadbd5f83dabeab79a5d2a37d Mon Sep 17 00:00:00 2001 From: Benoit Chesneau Date: Sun, 1 Feb 2026 03:11:42 +0100 Subject: [PATCH] docs: regenerate settings.md --- docs/content/reference/settings.md | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/docs/content/reference/settings.md b/docs/content/reference/settings.md index fd16c45d..454f9300 100644 --- a/docs/content/reference/settings.md +++ b/docs/content/reference/settings.md @@ -208,17 +208,38 @@ DirtyArbiter and the exiting DirtyWorker. 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 and implements the ``init()``, ``__call__()``, and ``close()`` methods. Example:: dirty_apps = [ - "myapp.ml:MLApp", - "myapp.images:ImageApp", + "myapp.ml:MLApp", # All workers load this + "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 in memory for the lifetime of the worker. This is ideal for loading 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 "Changed in 25.1.0" + Added per-app worker allocation via ``:N`` format suffix. + ### `dirty_workers` **Command line:** `--dirty-workers INT`