Skip to content

Increase max requests for Gunicorn to 5000#12728

Merged
mekarpeles merged 2 commits into
masterfrom
fastapi-max-requests
May 14, 2026
Merged

Increase max requests for Gunicorn to 5000#12728
mekarpeles merged 2 commits into
masterfrom
fastapi-max-requests

Conversation

@mekarpeles

Copy link
Copy Markdown
Member

At 1500 requests, If FastAPI does 50 req/sec then each worker is doing a restart every 30 seconds. @jimchamp and I were seeing particularly frequent fastapi restarts in the logs (and each restart itself takes 5-10 seconds meaning increased saturation for the remaining workers)

Copilot AI review requested due to automatic review settings May 12, 2026 21:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts the production Docker Compose Gunicorn configuration for the FastAPI service to reduce disruptive worker recycling under sustained load.

Changes:

  • Increased Gunicorn --max-requests for the fast_web (FastAPI) service from 1500 to 5000 in production compose config.

Comment thread compose.production.yaml Outdated

@RayBB RayBB left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're actually doing 50 RPS on each worker then 5000 is still not even 2 minutes. I think this could be 10k.

It's not something Drini or I ever benchmarked it was just set to a lowish number when doing the first endpoints to be on the safe side.

The thing to keep an eye on would be memory usage. We might have memory leaks throughout the codebase. Other than that the restarts aren't particularly necessary.

@tfmorris

Copy link
Copy Markdown
Contributor

@mekarpeles 10 sec downtime after 30 seconds is only 75% availability. Are you actually seeing memory leaks in practice? If not, that would suggest using a max-requests value of 0.

@github-actions github-actions Bot added the Needs: Response Issues which require feedback from lead label May 14, 2026
@mekarpeles

mekarpeles commented May 14, 2026

Copy link
Copy Markdown
Member Author

Thank you @tfmorris and @RayBB -- I think as a first step I'd like to deploy the change from 1.5k to 5k with a jitter to understand how performance (and memory usage) changes along a step function. Both of your feedback is appreciated and noted and it's not inconceivable that we'd move to 0 max requests.

@mekarpeles

Copy link
Copy Markdown
Member Author

Merging our compromised solution

@mekarpeles mekarpeles merged commit 83ffc68 into master May 14, 2026
8 checks passed
@mekarpeles mekarpeles deleted the fastapi-max-requests branch May 14, 2026 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs: Response Issues which require feedback from lead

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants