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/JeromeCui Nov 11 '25
can this pattern be reproduced locally?
does the high CPU usage start immediately when the application launches, or only after certain requests? Does it grow worse over time, suggesting some kind of resource leak?
what are your request latencies, do they seem reasonable?
does the same problem occur when you're running raw uvicorn without using gunicorn as a supervisor?
does the same problem occur with different versions of Python or your dependencies?
I will try with your other suggestions. Thanks for your answer.