Self-hosting
Scaling
Splitting the worker across containers with worker roles, CPU limits, and what to tune for large libraries.
One worker container does everything by default, and that suits most libraries. For a large library, or several machines, you can split the work up.
Worker roles
WORKER_ROLES says what a worker container runs. By default it's all. Otherwise it's a comma-separated list:
| Role | Runs |
|---|---|
steps | Every processing step |
step:<name> | One step, such as step:tagging or step:description |
albums | Keeping albums' rule picks current |
people | Placing faces with people |
places | Putting media in places by where they were taken |
all | Everything (the default) |
The full list of step names is in the worker roles reference. An unknown role stops the worker at start with a message listing the valid ones.
Several workers
Run several worker containers, each with its own roles. Any number can share a role: taking work is race-safe, so two workers never do the same media, and leases keep longer runs apart. For example, to give tagging its own container, using a models server on another machine with a GPU:
services:
worker:
environment:
WORKER_ROLES: steps,albums,people,places
worker-tagging:
extends: worker
environment:
WORKER_ROLES: step:tagging,step:nsfw
MODELS_URL: http://gpu-box.lan:8090
CPU limits
Every service has a CPU limit from .env, so one busy service can't take the whole machine:
| Variable | Default | Service |
|---|---|---|
POSTGRES_CPUS | 6 | The database |
MODELS_CPUS | 6 | The models server |
VISION_CPUS | 8 | The vision service (and its threads per model) |
WORKER_CPUS | 6 | The worker |
API_CPUS | 3 | The API |
WEB_CPUS | 2 | The app |
STORAGE_CPUS | 2 | Storage |
MIGRATOR_CPUS | 2 | The migrator |
The defaults suit an 8 to 16 core machine. On a smaller one, lower POSTGRES_CPUS, WORKER_CPUS and VISION_CPUS so the app stays responsive while the worker is busy.
Large libraries
With hundreds of thousands of media:
- Give PostgreSQL memory. Search and duplicate checks use vector indexes that are fastest in memory. Raise
shared_buffersandeffective_cache_sizewith acommand:on thepostgresservice. - Put the database on an SSD.
- Tune step concurrency for your hardware in Settings → Processing.
- Give the models server a card that fits every model at once, so it never has to stop one to start another. See Sharing one GPU.
- Expect the first pass to take days, not hours: every media goes through a dozen steps. The dashboard's work queue shows each step's pace and how long the rest will take.