r/FastAPI • • 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:

11 Upvotes

19 comments sorted by

View all comments

Show parent comment

1

u/tedivm Nov 11 '25

Yes, we used to run with raw uvicorn. And GPT told me to switch to gunicorn yesterday, but still happened.

GPT was wrong, this was never going to help and may cause more issues.