目前,我们的队列大小为 3000 个请求。
location /api/v2 {
limit_req zone=bursted burst=3000;
include /etc/nginx/proxy.conf;
}
Run Code Online (Sandbox Code Playgroud)
速率限制为每秒 10 个请求。
limit_req_zone $limit zone=api_slow:10m rate=1r/s;
limit_req_zone $server_name zone=bursted:10m rate=10r/s;
Run Code Online (Sandbox Code Playgroud)
保持活动超时为 30 秒。换句话说,当队列已满时,每 30 秒应拒绝 2700 个请求,并显示错误代码 408。
reset_timedout_connection on;
client_body_timeout 10;
send_timeout 2;
keepalive_timeout 30;
Run Code Online (Sandbox Code Playgroud)
在高峰时段,我在日志中找不到任何请求,由于超时,该请求被 NGINX 拒绝,错误代码为 408,而请求正在队列中等待转发到 servlet 容器。仅拒绝并返回 503 错误代码,这与请求速率开销相对应。
delaying request, excess: 2958.320, by zone "bursted"
limiting requests, excess: 3000.730 by zone "bursted"
Run Code Online (Sandbox Code Playgroud)
如果此类队列中的请求挂起时间过长,NGINX 是否会通过超时拒绝这些请求?这个超时是什么?它的配置在哪里?
nginx reverse-proxy 503-error high-load http-status-code-408