FastAPI can serve high levels of I/O-bound concurrency on modest hardware, but production capacity still depends on worker count, database latency, CPU-heavy endpoints, background tasks, and the services sharing the VPS.
The best server is sized for the complete API stack rather than benchmark numbers from an empty hello-world application.
Key takeaways
- 2 GB RAM is a practical starting point for small FastAPI production services.
- 4 GB is more comfortable with PostgreSQL, Redis, Docker, and multiple workers.
- Async code helps I/O-bound concurrency but not CPU-heavy work.
- Keep the API close to its database.
- Use background workers for expensive tasks.
How much RAM for FastAPI?
A small API can run comfortably on 2 GB with Uvicorn or Gunicorn workers and a reverse proxy. Four gigabytes gives more headroom when the same server hosts PostgreSQL, Redis, Docker, or background jobs.
Measure memory per worker before scaling concurrency.
Async vs CPU-heavy endpoints
FastAPI performs well for workloads that spend time waiting on databases and external APIs. CPU-heavy image processing, data science, encryption, or document generation still consumes processor time.
Move expensive jobs to workers or use more appropriate compute when CPU is the bottleneck.
Database and Redis placement
Keep PostgreSQL or MySQL in the same region because API requests may trigger several round trips. Redis can help caching and queues but should not consume uncontrolled memory.
Small deployments can keep services on one VPS and split them later.
Docker and deployment
Docker makes the API, proxy, database, and workers reproducible, but build processes can consume temporary resources. CI-based builds reduce pressure on small servers.
Configure health checks, restarts, logs, metrics, and a rollback path for production.
Frequently asked questions
Is 1 GB enough for FastAPI?
It can be for a tiny API, but 2 GB is a safer production starting point.
Does FastAPI need multiple workers?
Worker count depends on CPU, memory, workload, and concurrency. More workers are not always better.
Is FastAPI good on Docker VPS?
Yes. Docker is a common deployment model for FastAPI services and their dependencies.
When should FastAPI use dedicated CPU?
When CPU-heavy endpoints or sustained traffic create measurable processor saturation.