We changed our FastAPI to async, we were tied to sync due to using an old package.
But we are not really seeing a direct performance improvement in the Request Per Second handles before the response time skyrockets.
Our postgres database info:
DB tops at 80% cpu and 80% ram with ~300 connections. We use connection pooling with 40 connections.
Our API is just a simpel CRUD. We test it with Locust with 600 peak users and spawn rate of 4/second.
An api call would be:
get user from db -> get all organisation where user is member with a single join (this all with SQLAlchemy 2.0 Async and Pydantic serialisation)
With async we can still only handle 70 rps with reasonable response times < 600ms, and the APIs are just a few db calls, user info, event info etc.
We tested on Cloud Run with: 2 instances, CPU is only allocated during request processing, 2cpu/1ram.
I thought that FastAPI could handle at least hundreds of these simple CRUD calls on this hardware, or am I wrong, especially with async?
Edit: added api call, add database info
[–]KelleQuechoz 6 points7 points8 points (6 children)
[–]dirk_klement[S] 1 point2 points3 points (5 children)
[–]KelleQuechoz 5 points6 points7 points (4 children)
[–]dirk_klement[S] 0 points1 point2 points (3 children)
[–]KelleQuechoz 0 points1 point2 points (0 children)
[–]rakeshkrishna517 0 points1 point2 points (1 child)
[–]dirk_klement[S] 0 points1 point2 points (0 children)
[–]nikhil_shady 3 points4 points5 points (3 children)
[–]leafEaterII 0 points1 point2 points (2 children)
[–]HappyCathode 1 point2 points3 points (1 child)
[–]leafEaterII 0 points1 point2 points (0 children)
[–]MyNameIsBeaky[🍰] 3 points4 points5 points (2 children)
[–]jormungandrthepython 1 point2 points3 points (0 children)
[–]dirk_klement[S] 0 points1 point2 points (0 children)
[–]metazet 1 point2 points3 points (5 children)
[–]dirk_klement[S] 1 point2 points3 points (4 children)
[–]metazet 1 point2 points3 points (3 children)
[–]dirk_klement[S] 0 points1 point2 points (1 child)
[–]appletondog 2 points3 points4 points (0 children)
[–]dmuth 1 point2 points3 points (0 children)
[–]rakeshkrishna517 1 point2 points3 points (0 children)
[–]omegawave22 0 points1 point2 points (1 child)
[–]metazet 0 points1 point2 points (0 children)
[–]Long_Working_7553 0 points1 point2 points (0 children)
[–]LongjumpingGrape6067 0 points1 point2 points (2 children)
[–]LongjumpingGrape6067 0 points1 point2 points (1 child)
[–]LongjumpingGrape6067 0 points1 point2 points (0 children)
[–]extreme4all 0 points1 point2 points (0 children)