75秒后nginx访问日志中有大量499个状态码

时间:2014-01-17 13:08:37

标签: nginx

我们在长轮询场景中使用nginx。我们有一个用户安装的客户端,然后与我们的服务器通信。该服务器中的nginx进程将该请求传递给后端,这些后端是Python进程。 Python进程持有最多650秒的请求。

在nginx访问日志中有很多499个条目。记录$ request_time表明客户端在75秒后超时。没有nginx超时设置为75秒。

一些研究表明,后端进程可能太慢,但包含进程的服务器中没有很多活动。添加更多服务器/进程也没有帮助,也没有升级nginx所在的实例。

以下是nginx配置文件。

nginx.conf

user nobody nogroup;
worker_processes 1;
worker_rlimit_nofile 131072;
pid /run/nginx.pid;

events {
       worker_connections 76800;
}

http {

       sendfile on;
       tcp_nopush on;
       tcp_nodelay on;
       types_hash_max_size 2048;
       keepalive_timeout 65;

       server_names_hash_bucket_size 64;

       include /usr/local/openresty/nginx/conf/mime.types;
       default_type application/octet-stream;

log_format combined_edit '$remote_addr - $remote_user [$time_local] '
                    '"$request" $status $body_bytes_sent '
                    '"$http_referer" "$http_user_agent" "$request_time"';

       access_log /var/log/nginx/access.log combined_edit;
       error_log /var/log/nginx/error.log;

       gzip on;
       gzip_disable "msie6";

       include /usr/local/openresty/nginx/conf.d/*.conf;
       include /usr/local/openresty/nginx/sites-enabled/*;
}

backend.conf

upstream backend {
  server xxx.xxx.xxx.xxx:xxx max_fails=12 fail_timeout=12;
  server xxx.xxx.xxx.xxx:xxx max_fails=12 fail_timeout=12;
}

server {
  listen 0.0.0.0:80;
  server_name host;
  rewrite ^(.*) https://$host$1 permanent;
}

server {
  listen 0.0.0:443;
  ssl_certificate /etc/ssl/certs/ssl.pem;
  ssl_certificate_key /etc/ssl/certs/ssl.pem;
  ssl on;
  server_name host;
  location / {
    proxy_connect_timeout 700;
    proxy_buffering off;
    proxy_redirect off;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_read_timeout 10000; # something really large
    proxy_pass http://backend;
  }
}

0 个答案:

没有答案