<@ULVA73B9P> I'm running prefect server container ...
# ask-marvin
b
@Marvin I'm running prefect server container on a 1 CPU ECS instance, will the server take advantage of more cores if I pump it to 2 or 4, or is the server single threaded?
m
thought for 134.3 seconds
Short answer: The Prefect Server container runs a single Uvicorn worker by default, so it won’t automatically use multiple CPU cores just by giving the task more vCPUs. You’ll see some benefit from async I/O, but you won’t get multi-core parallelism out of the box. Ways to use more cores: - Scale out replicas (recommended) - Run multiple ECS tasks behind a load balancer, all pointing to the same Postgres database. - Run one “primary” with services enabled and additional replicas with services disabled to avoid duplicate schedulers. - Example: - Primary:
Copy code
prefect server start --ui
(services like the scheduler/late-run detector are on by default; you can force them on with
--scheduler --late-runs
if you prefer) - Additional replicas:
Copy code
prefect server start --ui --no-services
- Run multiple workers in a single container (advanced) - Replace the default command with Gunicorn managing multiple Uvicorn workers:
Copy code
gunicorn -k uvicorn.workers.UvicornWorker -w 4 -b 0.0.0.0:4200 'prefect.server.api.server:create_app()'
- This will utilize multiple CPU cores within one task. Ensure your environment variables (e.g., database connection URL) are set so the app can start normally. Other considerations: - The database is usually the bottleneck. Make sure your Postgres instance has sufficient CPU/IO and connection capacity for whichever scaling approach you choose. - The server is I/O heavy; you may get more headroom by scaling replicas behind an ALB rather than increasing cores on a single process. Docs: - Self-hosted guidance: Prefect 3.x self-hosted docs - Uvicorn deployment notes: Uvicorn deployment If you share how you’re starting the container (entrypoint/command and env) and your DB setup, I can suggest a concrete ECS task definition and health check config.