Context: If I wanted to create a Python AI agent system for recruiters of a specific business, I would want to create a solution that only allows the specific organisation access.
The auth solution should also be role-based: Admin - monitors usage and manages costs, and adds specific employees as recruiters. Recruiters - employees who can use the system.
I benchmarked the major Python frameworks with real PostgreSQL workloads: complex queries, nested relationships, and properly optimized eager loading for each framework (select_related/prefetch_related for Django, selectinload for SQLAlchemy). Each framework tested with multiple servers (Uvicorn, Granian, Gunicorn) in isolated Docker containers with strict resource limits.
All database queries are optimized using each framework's best practices - this is a fair comparison of properly-written production code, not naive implementations.
Key finding: performance differences collapse from 20x (JSON) to 1.3x (complex DB queries). Database I/O is the great equalizer - framework choice barely matters for database-heavy apps.
This setup ensures completely fair comparison - no resource contention between frameworks, each gets identical isolated environment.
Endpoints Tested
/json-1k - Simple 1KB JSON serialization
/json-10k - Large 10KB JSON serialization
/db - 10 simple database reads
/articles?page=1&page_size=20 - Paginated articles with nested authors + tags
/articles/1 - Single article with author, tags, and all comments
Key Results
Simple JSON (/json-1k) - RPS
litestar-uvicorn: 31,745
litestar-granian: 22,523
bolt: 22,289
fastapi-uvicorn: 12,838
drf-gunicorn: 4,271
drf-uvicorn: 1,582
20x performance difference between fastest and slowest.
Real Database - Paginated Articles (/articles?page=1&page_size=20) - RPS
litestar-uvicorn: 253
litestar-granian: 238
bolt: 237
fastapi-uvicorn: 225
drf-granian: 221
Performance gap shrinks to just 1.7x when hitting the database. Query optimization becomes the bottleneck.
Real Database - Article Detail (/articles/1) - RPS
Single article with all nested data (author + tags + comments):
fastapi-uvicorn: 550
litestar-granian: 543
litestar-uvicorn: 519
bolt: 487
fastapi-granian: 480
Gap narrows to 1.3x - frameworks perform nearly identically on complex database queries.
Resource Usage Insights
Memory:
Most frameworks: 170-220MB
DRF-Granian: 640-670MB (WSGI interface vs ASGI for others - Granian's WSGI mode uses more memory)
CPU:
Most frameworks saturate the 1 CPU limit (100%+) under load
Granian variants consistently max out CPU across all frameworks
Server Performance
Uvicorn surprisingly won for Litestar (31,745 RPS), beating Granian
Granian delivered consistent high performance for FastAPI and other frameworks
Gunicorn + gevent showed good performance for DRF on simple queries, but struggled with database workloads
Key Takeaways
Performance gap collapse: 20x difference in JSON serialization → 1.7x in paginated queries → 1.3x in complex queries
Litestar-Uvicorn dominates simple workloads (31,745 RPS), but FastAPI-Uvicorn wins on complex database queries (550 RPS)
Database I/O is the equalizer: Once you hit the database, framework overhead becomes negligible. Query optimization matters infinitely more than framework choice.
WSGI uses more memory: Granian's WSGI mode (DRF-Granian) uses 640MB vs ~200MB for ASGI variants - just a difference in protocol handling, not a performance issue.
Bottom line: If you're building a database-heavy API (which most are), spend your time optimizing queries, not choosing between frameworks. They all perform nearly identically when properly optimized.
I am currently learning backend, particularly Django, FastAPI, etc.. Are you into programming, web development and things like that? Are you a learner too? If so, let's connect. I would love to help and be helped, motivate each other in the process, and help when we get stuck here and then.
And of you are thinking about building projects, let's connect too. I would love to collaborate and help, just for experience and nothing more 🙌.
I would like to share my new project: Dokku-API. This is a RESTful API built with FastAPI for managing a Dokku server — and it just reached the version 1.3.0 — published on PyPI!! 🚀🚀
I have been working on it for over a year of work, and I’m still actively improving it. I’m hoping for contributions from the community! So if you find a bug or want to add a feature, feel free to open a PR! 😊
The code is on my GitHub --> JeanExtreme002/Dokku-API. I’d also appreciate it if you could leave a ⭐️ on the repo page if you like the project and want to see more updates!
After starting several FastAPI projects, I realized that I was always repeating the same configuration: project structure, basic configuration, Docker, CI/CD, and the usual module structure. So, I decided to automate this process.
FastGear CLI helps to initialize a FastAPI project with a clean and structured base, already including integration with FastGear (a library I've been developing), optional Docker support, CI/CD templates, and structure for common layers such as entities, services, repositories, and controllers.
The idea is: less boilerplate code, faster setup, and a more organized starting point for APIs.
If you try out this CLI, I'd love to hear your feedback.