Used reco API for load testing.
| docker-compose.yml
| readme.md
| tree.txt
+---app
| Dockerfile
| main.py
| requirements.txt
| utils.py
+---assets
| locust-1.jpg
| locust-2.jpg
| locust-3.jpg
+---data
| customer_item_matrix.parquet
| df.parquet
| item_item_sim_matrix.parquet
| user_user_sim_matrix.parquet
\---locust
locustfile.py
There are only two prerequisites:
git clone https://github.com/silverstone1903/auto-load-testing
You can change load test values in docker-compose.yml. locust works with 50 users, 2 hatch rate and 10 seconds run time by default. When run time limit reached docker stopping locust container and then app looks unhealty. To prevent this I added --exit-code-from {container}
command to run compose. When locust finishes compose stopping the remain container and shut downs the app.
command: -f /mnt/locust/locustfile.py --headless -u 50 -r 2 --run-time 10s --host http://fastapi:8000
docker-compose up --exit-code-from locust
If you make any changes you can add --build
.
docker-compose up --build --exit-code-from locust
docker-compose down
If you want to check locust results you can use logs
. Uvicorn app works with --log-level critical
so there won't be any fastapi related logs. You can easily check locust aggregated results.
docker-compose logs --tail 50
- FastAPI: http://localhost:8000
Blog post (in Turkish): Auto Load Testing - FastAPI + locust