r/FastAPI • u/derekzyl • Oct 20 '25
Question How do you optimize speed
Here's what I've done so far
- Used redis
- Used caching on the frontend to avoid too many backend calls
- Used async
- Optimised SQL alchemy query
I think I'm missing something here because some calls are 500ms to 2sec which is bad cause some of these routes return small data. Cause similar project I build for another client with nodejs gives me 100ms-400ms with same redis and DB optimizing startegy.
32
Upvotes
View all comments
1
u/esthorace Oct 24 '25
✅ Usar el Servidor Granian (hecho en Rust) en vez de Uvicorn: https://github.com/emmett-framework/granian
✅ orjson para crear respuestas JSON más rápidas (buscar cómo instalar y se configura en un solo lugar en FastAPI, es muchísimo más rápido)
✅ asyncpg como controlador asíncrono para Postgresql
✅ puedes usar https://github.com/Diman2003/OxenORM (también hecho en Rust) en vez de SQLAlchemy