简体   繁体   English

gunicorn中max_requests和max_requests_jitter之间的机制是什么

[英]What is the mechanism between max_requests and max_requests_jitter in gunicorn

According to the official guide根据官方指南

https://docs.gunicorn.org/en/latest/settings.html#settings https://docs.gunicorn.org/en/latest/settings.html#settings

a worker will restart when it has handled max_requests requests.工作人员将在处理max_requests请求后重新启动。

But when max_requests_jitter is set, a worker will restart when it has handled randint(0, max_requests_jitter) request, to stagger worker restarts to avoid all workers restarting at the same time.但是设置max_requests_jitter ,一个worker会在处理randint(0, max_requests_jitter)请求后重启,错开worker重启,避免所有worker同时重启。

Is that means max_requests_jitter setting will override max_requests and make it be invalid?那是不是意味着max_requests_jitter设置会覆盖max_requests并使其无效?

From the docs -文档-

The jitter causes the restart per worker to be randomized by randint(0, max_requests_jitter) .抖动导致每个工作人员的重启由randint(0, max_requests_jitter)随机化。 This is intended to stagger worker restarts to avoid all workers restarting at the same time.这是为了错开工作人员重新启动以避免所有工作人员同时重新启动。

What I understand is that the jitter is a random addition to each worker and the term max_requests_jitter should be (though not necessary) smaller than max_requests .我的理解是抖动是每个工作人员的随机添加,术语max_requests_jitter应该(尽管不是必需的)小于max_requests

In other words, worker_1 will restart after max_requests + j1 requests, worker_2 will restart after max_requests + j2 requests etc. where the values of j1, j2, j3... are determined by the max_requests_jitter argument.换句话说,worker_1 将在max_requests + j1请求后重启,worker_2 将在max_requests + j2请求后重启等,其中j1, j2, j3...的值由max_requests_jitter参数确定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM