5

In order to try and reduce memory usage on our web server, I've had to set the max-requests property on my uwsgi config to 50.

What are the down sides of this?

We've got 10 workers on the site and it looks like workers are being recycled every 20 minutes or so but, so far at least, it seems to be having the desired effect of us not getting near our memory limit.

I'm just slightly concerned that it might side effects for users but I'm not sure. Any ideas?

2 Answers 2

3

As far as i know, the only downside of setting max-requests is that when running apps that load on the first request to the server instead of the worker initialization (like Django), every time a worker hits the max-requests limit, the next request that it answers will have a delay. If that delay is short or long, depends on your server specs and the complexity of your app.

2

Something I experienced using max-requests is that, as requests were distributed equally between workers, then all my workers were being recycled at the same time, they all reached max-requests at the same time. This could be a disadvantage if your application takes too much time to load.

If you want to reduce the amount of memory used by uWSGI, you should consider:

  • Setting options reload-on-rss and/or reload-on-as. They allow you to set a max amount of memory a worker can use, if it reaches the maximum it is recycled.

  • If your application is thread safe, try using threads and reducing the amount of workers. This approach uses less memory, but some testing needs to be done.

2
  • 4
    You can also set max-requests-delta to spread out the restarts more
    – augurar
    Mar 13, 2020 at 19:05
  • Only in uwsgi 2.1 though. 2.0.x does not support that (yet?), as some of us have learned by using "strict" mode. May 8, 2020 at 19:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .