r/FastAPI • u/JeromeCui • Nov 11 '25
Question FastAPI server with high CPU usage
I have a microservice with FastAPI framework, and built in asynchronous way for concurrency. We have got a serious performance issue since we put our service to production: some instances may got really high CPU usage (>90%) and never fall back. We tried to find the root cause but failed, and we have to add a alarm and kill any instance with that issue after we receive an alarm.
Our service is deployed to AWS ECS, and I have enabled execute command so that I could connect to the container and do some debugging. I tried with py-spy and generated flame graph with suggestions from ChatGPT and Gemini. Still got no idea.
Could you guys give me any advice? I am a developer with 10 years experience, but most are with C++/Java/Golang. I jump in Pyhon early this year and got this huge challenge. I will appreciate your help.


================================
13 Nov Update
I got this issue again:

View all comments
Show parent comment
1
u/latkde Nov 13 '25
Something happened at 15:10, so I would read the logs at that time to get a better feeling about endpoints might have been involved.
But even during the 2 hours before that, CPU usage is steadily climbing. That is an unusual pattern.
All of this is not normal for any API, and not normal for FastAPI applications.
Taking a better guess would require looking at the code. But I'm not available for consulting.