Add max_requests_jitter configuration option.

An issue we've had when using max_requests is almost all of our workers would restart at the same time due to even balancing of requests to the workers. This would result in a resource spike during the wave of worker restarts and a bunch of queuing due to fresh workers getting slammed. This jitter splits up the restart of the workers, which will help prevent the above issue.

This is something we've been using at reddit for a while now. Not sure it is suitable for the main project, but I figured I'd pass it along. I'd be happy to alter the name of the option or any of the documentation to meet any standards or requirements of the project.
That's a great idea. I love when docs have that.
On Aug 23, 2014 4:37 PM, "Berker Peksag" <notifications@github.com> wrote:

> In docs/source/settings.rst:
>
> > @@ -145,6 +145,18 @@ to help limit the damage of memory leaks.
> >  If this is set to zero (the default) then the automatic worker
> >  restarts are disabled.
> >
> > +max_requests_jitter
> > +~~~~~~~~~~~~
> > +
> > +* ``--max-requests-jitter INT``
> > +* ``0``
> > +
> > +The maximum jitter to add to the max_requests setting.
> > +
> > +The jitter causes the restart per worker to be randomized by
> > +random(range(0, this_value)). This is intended to stagger worker
> > +restarts to avoid all workers restarting at the same time.
> > +
>
> We could add a versionadded directive: .. versionadded:: 19.2
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/benoitc/gunicorn/pull/862/files#r16633295>.
>