Opened 3 years ago
Closed 3 years ago
#2306 closed defect (invalid)
One limit_req_zone for multiple vhosts not working
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | nginx-module | Version: | |
Keywords: | ngx_http_limit_req_module | Cc: | |
uname -a: | Linux bnode01 4.19.0-18-amd64 #1 SMP Debian 4.19.208-1 (2021-09-29) x86_64 GNU/Linux | ||
nginx -V: |
nginx version: nginx/1.21.5
built by gcc 8.3.0 (Debian 8.3.0-6) built with OpenSSL 1.1.1d 10 Sep 2019 TLS SNI support enabled configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-g -O2 -fdebug-prefix-map=/data/builder/debuild/nginx-1.21.5/debian/debuild-base/nginx-1.21.5=. -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie' |
Description
Hello,
i tried to setup one big limit_req_zone for 20 vhosts. I used 250r/s as limit per ip. But all websites had problems with this. I get a lot of 'limiting requests, excess: 0.001 by zone "l-req-default"' entries in my logfiles.
I don't know where the problem is. My temporary fix was to add the 'burst' and 'nodelay' to the limit_req in vhost configs. But every websites have maybe 10-30 requests and the user never reaches the 250r/s. For testing i also tried 10000r/s - also not working.
Another working solution was to setup one limit_req_zone for every vhost. But i think this cannot be the right solution.
Change History (2)
comment:1 by , 3 years ago
comment:2 by , 3 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
The limit_req
is expected to be used with meaningful burst values. Without burst set (which effectively means burst=1), the next request will be rejected if it comes before 1/<rate> time passes. This is highly likely to happen in practice if you are using limit_req
to limit all requests, including requests to static resources: when a client requests a page, it usually requests several additional resources, such as images and CSS files, in a very short time, leading to rejects even with very high rates configured. In practice it is usually a good idea to configure burst at least as large as several seconds of the traffic to make sure such bursts are tolerated. Given rate=250r/s, something like burst=1000 might be a good starting value in your case.
Attached my config:
In http block:
limit_req_zone $binary_remote_addr zone=l-req-default:128m rate=250r/s;
In all server blocks:
limit_req zone=l-req-default;