Igor Serko
03/04/2026, 8:06 AMMarvin
03/04/2026, 8:06 AMMarvin
03/04/2026, 8:12 AMprefect server start --host 0.0.0.0 --no-services
- One ECS service (single task) for background services:
prefect server services start
- One-off migration job during deploys:
prefect server database upgrade -y
- Data plane
- RDS Postgres (required for HA/multi-replica). Avoid SQLite in production.
- Redis (ElastiCache) required for multi-server/event coordination and scaling.
- Load balancer
- ALB health check: /api/health on port 4200
- Configure keep-alive > ALB idle timeout (e.g., set PREFECT_SERVER_API_KEEPALIVE_TIMEOUT=65)
- Security and settings
- Basic Auth for server/API:
# On the server
PREFECT_SERVER_API_AUTH_STRING="username:password"
# On all clients (workers, dev laptops) that call your API
PREFECT_API_AUTH_STRING="username:password"
Store in AWS Secrets Manager and inject via ECS task definition.
- CORS/CSRF for public endpoints:
PREFECT_SERVER_API_CSRF_PROTECTION_ENABLED=true
PREFECT_SERVER_API_CORS_ALLOWED_ORIGINS="<https://prefect.example.com>"
- UI config behind a proxy:
PREFECT_UI_API_URL="<https://prefect.example.com/api>"
- Redis/messaging (for HA and scale)
- Typical env you’ll see:
PREFECT_MESSAGING_BROKER=prefect_redis.messaging
PREFECT_MESSAGING_CACHE=prefect_redis.messaging
PREFECT_SERVER_EVENTS_CAUSAL_ORDERING=prefect_redis.ordering
PREFECT_SERVER_CONCURRENCY_LEASE_STORAGE=prefect_redis.lease_storage
PREFECT_SERVER_DOCKET_URL="redis://<redis-host>:6379/1"
- Database tips
- Connection URL example:
PREFECT_API_DATABASE_CONNECTION_URL="<postgresql+asyncpg://user:pass@rds-host:5432/prefect>"
- For large DBs, raise migration timeout:
PREFECT_API_DATABASE_TIMEOUT=600
- Set event retention to control DB growth and vacuum routinely.
When self-hosting on ECS is a great fit
- You need strict VPC isolation or can’t use a public SaaS.
- You already run ECS/RDS/ElastiCache and have central observability/ops.
- You’re okay without Cloud-only features (RBAC, SSO, audit logs).
- You want precise control over upgrades, backups, and sizing.
When Prefect Cloud is usually easierMarvin
03/04/2026, 8:12 AM