This project contains a small FastAPI application backed by a PostgreSQL database and a pair of benchmark clients used to compare synchronous and asynchronous HTTP requests. It can be used to observe latency and throughput differences when making many concurrent requests.
- Python 3.13+
- PostgreSQL database
The project dependencies are declared in pyproject.toml. Install them with pip:
pip install -r uv.lockThe database connection details are provided through environment variables:
DATABASE_URL– connection string used by the applicationDB_NAME,DB_USER,DB_PASSWORD,DB_HOST,DB_PORT– used by the data population script
Create a .env file or export the variables in your shell before running the code.
Start the FastAPI server with uvicorn:
uvicorn main:app --reloadThe service exposes a single endpoint:
GET /clientes/{id}– returns a client record from the database
Use the generator_fake_clients.py script to seed the database with sample clients:
python generator_fake_clients.pyTwo benchmark scripts are provided:
benchmark_client_async.py– performs requests usinghttpx.AsyncClientbenchmark_client_sync.py– performs requests usingrequests
Each script will issue 10,000 requests against the running API and print throughput and latency metrics.
Run them with:
python benchmark_client_async.pypython benchmark_client_sync.pyCompare the output numbers to evaluate the performance differences between asynchronous and synchronous requests.

