<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><style>body { line-height: 1.5; }blockquote { margin-top: 0px; margin-bottom: 0px; margin-left: 0.5em; }p { margin-top: 0px; margin-bottom: 0px; }body { font-size: 10.5pt; font-family: 'Microsoft YaHei UI'; color: rgb(0, 0, 0); line-height: 1.5; }</style></head><body>
<div><span></span>I want to set the<span style="font-size: 10.5pt; line-height: 1.5; background-color: window;"> </span><span style="font-size: 10.5pt; line-height: 1.5; background-color: window;">rate limiting for the entire server not for each client ip.</span></div>
<div><br></div><hr style="width: 210px; height: 1px;" color="#b5c4df" size="1" align="left">
<div><span><div style="MARGIN: 10px; FONT-FAMILY: verdana; FONT-SIZE: 10pt"><p style="margin: 3.75pt 0cm; orphans: 2; widows: 2; font-size: 14px; font-family: 微软雅黑; line-height: 21px;"><span style="font-size: 9pt; font-family: 微软雅黑, sans-serif;">童树山</span><span style="font-size: 9pt; font-family: 微软雅黑, sans-serif;"></span></p><p style="margin: 3.75pt 0cm; orphans: 2; widows: 2; font-size: 14px; font-family: 微软雅黑; line-height: 21px;"><span style="font-size: 9pt; font-family: 微软雅黑, sans-serif;">咪咕视讯科技有限公司 研发部</span></p><p style="margin: 3.75pt 0cm; orphans: 2; widows: 2; font-size: 14px; font-family: 微软雅黑; line-height: 21px;"><span style="font-size: 9pt; font-family: 微软雅黑, sans-serif;">Mobile</span><span style="font-size: 9pt; font-family: 微软雅黑, sans-serif;">:13818663262</span></p><p style="margin: 3.75pt 0cm; orphans: 2; widows: 2; font-size: 14px; font-family: 微软雅黑; line-height: 21px;"><span style="font-size: 9pt; font-family: 微软雅黑, sans-serif;">Telephone</span><span style="font-size: 9pt; font-family: 微软雅黑, sans-serif;">:021-51856688(81275)</span></p><div style="font-size: 13.3333px; orphans: 2; widows: 2;"><span style="font-size: 9pt; font-family: 微软雅黑, sans-serif; line-height: 21px; background-color: window;">Email</span><span style="font-size: 9pt; font-family: 微软雅黑, sans-serif; line-height: 21px; background-color: window;">:</span><a href="mailto:tongshushan@migu.cn" target="_blank" style="font-size: 10pt; line-height: 1.5; background-color: window;">tongshushan@migu.cn</a></div></div></span></div>
<blockquote style="margin-Top: 0px; margin-Bottom: 0px; margin-Left: 0.5em"><div> </div><div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm"><div style="PADDING-RIGHT: 8px; PADDING-LEFT: 8px; FONT-SIZE: 12px;FONT-FAMILY:tahoma;COLOR:#000000; BACKGROUND: #efefef; PADDING-BOTTOM: 8px; PADDING-TOP: 8px"><div><b>From:</b> <a href="mailto:lists@lazygranch.com">Gary</a></div><div><b>Date:</b> 2017-12-01 22:43</div><div><b>To:</b> <a href="mailto:nginx@nginx.org">nginx</a></div><div><b>Subject:</b> Re: How to control the total requests in Ngnix</div></div></div><div><div>Is this limiting for one connection or rate limiting for the entire server? I interpret this as a limit for one connection. </div>
<div> </div>
<div>I got rid of the trailing period. </div>
<div>https://en.wikipedia.org/wiki/Leaky_bucket</div>
<div> </div>
<div>A request is one line in the access log I assume, typically a html verb like "get". I use a single core VPS, so I don't have much CPU power. Unless the verb action is trivial, I doubt I would hit 2000/s. From experimentation, a burst of 10 gets the images going mostly unimpeded, and a rate of 10/s is where you see a page just start to slow down. I think a rate of 2000/s isn't much of a limit. </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> Original Message </div>
<div>From: mdounin@mdounin.ru</div>
<div>Sent: December 1, 2017 5:46 AM</div>
<div>To: nginx@nginx.org</div>
<div>Reply-to: nginx@nginx.org</div>
<div>Subject: Re: Re: How to control the total requests in Ngnix</div>
<div> </div>
<div>Hello!</div>
<div> </div>
<div>On Fri, Dec 01, 2017 at 11:18:06AM +0800, tongshushan@migu.cn wrote:</div>
<div> </div>
<div>> I configured as below:</div>
<div>> limit_req_zone "all" zone=all:100m rate=2000r/s;</div>
<div>> limit_req zone=all burst=100 nodelay;</div>
<div>> but when testing,I use tool to send the request at: Qps:486.1(not reach 2000) I got the many many 503 error,and the error info as below:</div>
<div>> </div>
<div>> 2017/12/01 11:08:29 [error] 26592#37196: *15466 limiting requests, excess: 101.000 by zone "all", client: 127.0.0.1, server: localhost, request: "GET /private/rush2purchase/inventory/aquire?productId=product1 HTTP/1.1", host: "localhost"</div>
<div>> </div>
<div>> Why excess: 101.000? I set it as 2000r/s ?</div>
<div> </div>
<div>You've configured "burst=100", and nginx starts to reject requests </div>
<div>when the accumulated number of requests (excess) exceeds </div>
<div>the configured burst size.</div>
<div> </div>
<div>In short, the algorithm works as follows: every request increments </div>
<div>excess by 1, and decrements it according to the rate configured. If </div>
<div>the resulting value is greater than burst, the request is </div>
<div>rejected. You can read more about the algorithm used in </div>
<div>Wikipedia, see https://en.wikipedia.org/wiki/Leaky_bucket.</div>
<div> </div>
<div>-- </div>
<div>Maxim Dounin</div>
<div>http://mdounin.ru/</div>
<div>_______________________________________________</div>
<div>nginx mailing list</div>
<div>nginx@nginx.org</div>
<div>http://mailman.nginx.org/mailman/listinfo/nginx</div>
<div>_______________________________________________</div>
<div>nginx mailing list</div>
<div>nginx@nginx.org</div>
<div>http://mailman.nginx.org/mailman/listinfo/nginx</div>
</div></blockquote>
</body></html>