TL;DR: On a quarter of a CPU one Uvicorn worker beats four, and a capped async connection pool is what keeps a 50-connection database happy. Migrations at start, a health route that survives a sleeping container, CORS against the container hostname, and the free and $1 options for the PostgreSQL itself. Tested on Python 3.12 with SQLAlchemy 2 and asyncpg.
FastAPI is the framework people reach for when they want an API up this afternoon, and it deploys well on a small container because it is asynchronous: one process can hold hundreds of open requests while it waits on the database. This guide takes a FastAPI service with PostgreSQL to a free container tier, with the async database setup done properly, the worker count that actually fits a quarter of a CPU, and the connection limits you will hit if you copy a tutorial written for a bigger box.
Tested on Python 3.12 with SQLAlchemy 2 and asyncpg.…