Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure automatic gunicorn worker restart in the pulpcore-api service configuration #285

Closed
dralley opened this issue May 24, 2023 · 8 comments

Comments

@dralley
Copy link
Contributor

dralley commented May 24, 2023

This will help to address https://bugzilla.redhat.com/show_bug.cgi?id=2122872

Gunicorn provides --max-requests and --max-requests-jitter settings which will restart the web worker process after handling some number of requests. This will help to eliminate any memory leaks which may be present.

I advise to set

--max-requests 50 \
--max-requests-jitter 30 \

, which will restart workers after handling some random number of requests between 50 and 80.

https://github.com/theforeman/puppet-pulpcore/blob/master/templates/pulpcore-api.service.erb

@evgeni
Copy link
Member

evgeni commented May 24, 2023

this would apply to API only, right? the content app, while also being gunicorn, shouldn't leak?

@dralley
Copy link
Contributor Author

dralley commented May 24, 2023

Yes, that's correct.

I'm testing --max-requests-jitter currently, and actually it does not appear to necessarily be working? --max-requests 80 visibly does work well, but I cannot tell that --max-requests-jitter is doing anything.

@evgeni
Copy link
Member

evgeni commented May 24, 2023

do you call it with --max-requests-jitter J --max-request X or just --max-requests-jitter J?

https://docs.gunicorn.org/en/latest/settings.html#max-requests-jitter is not exactly clear in the wording, but I think that the restarts happen after X+rand(0, J) requests if you provide both, and if you don't provide --max-requests the jitter is just ignored (vs executed at rand(0,J))

@dralley
Copy link
Contributor Author

dralley commented May 24, 2023

Ah, you are correct, you have to provide both.

@evgeni
Copy link
Member

evgeni commented May 24, 2023

How did you get those numbers? They feel very low, but I can't really tell why.

@ekohl
Copy link
Member

ekohl commented May 24, 2023

They do feel very low, because if you serve just 10 requests/second you'll have a restart every 5 seconds. In really doubt you'll have memory leaks in such a short amount of time. You may be trading in better memory consumption for higher CPU usage. I'm not sure which one I'd rather have.

When you have these settings I often see values of 1000 or 10000 requests to start with and then tune them further.

@dralley
Copy link
Contributor Author

dralley commented May 24, 2023

They are pretty low, but unfortunately at the moment it seems we're leaking memory quite quickly during repository index operations.

The API server is easily the least sensitive to this sort of thing, so I think the low limits are OK, though of course we do want to be able to raise them later.

If you look at the BZ it's pretty clear we should prefer the lower memory usage at the moment.

@evgeni
Copy link
Member

evgeni commented May 25, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants