<@ULVA73B9P> When scaling prefect self hosted, now...
# marvin-ai
m
@Marvin When scaling prefect self hosted, now that docket is supported and api workers are spread across multiple VMs, can there be multiple prefect background services one on each VM?
m
thought for 292.4 seconds
Short answer: Yes. With Docket enabled, you can safely run multiple Prefect background services—one on each VM—and they’ll coordinate work without duplicating it. Key points - Use a shared Docket backend (Redis) across all instances - Set
PREFECT_SERVER_DOCKET_URL=redis://<host>:6379/<db>
- Do not use the default
memory://
when running multiple instances (it will duplicate work) - Two supported patterns: 1) Recommended: Run multiple API replicas with services disabled, and run one or more dedicated background-service processes - API replicas:
Copy code
prefect server start --host 0.0.0.0 --no-services
- Background services (on one or more VMs/containers):
Copy code
prefect server services start
2) Acceptable: Keep background services enabled on every API replica; with Redis-backed Docket they will still coordinate and not double-execute. The trade-off is shared CPU/memory with the API. - For multi-instance deployments also ensure: - A shared Postgres database via
PREFECT_API_DATABASE_CONNECTION_URL
- Run DB migrations once, then set
PREFECT_API_DATABASE_MIGRATE_ON_START=false
on all long-lived replicas - Helpful CLI checks: -
prefect server start --help
shows
--no-services
-
prefect server services --help
shows
start
,
stop
, and
ls
(list) subcommands Docs and references - Server concepts and self-hosting: Prefect 3 Server concepts - Server CLI: Server CLI guide - Settings reference (Docket): Settings reference: ServerDocketSettings If you want, I can share a minimal docker-compose that runs multiple API replicas plus one or more background-service containers using Redis-backed Docket.