微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

为什么nginx不能接受来自Apache的1024多个连接

我有一个clojure / jetty服务器(端口8081),并用Nginx(端口8080)代理它。 我一直在试图对clojure应用程序进行基准testing,以及Nginx的代理angular色。

当我直接对clojure运行testing时,我可能会Connection reset by peer ,每10次运行一次。 一般来说,testing完成,性能是可以接受的。

$ ulimit -n 4096 $ ab -n 20000 -c 2048 -k localhost:8081 ... Concurrency Level: 2048 Time taken for tests: 8.713 seconds Complete requests: 20000 Failed requests: 0 Keep-Alive requests: 20000 Total transferred: 15160000 bytes HTML transferred: 11720000 bytes Requests per second: 2295.43 [#/sec] (mean) Time per request: 892.208 [ms] (mean) Time per request: 0.436 [ms] (mean,across all concurrent requests) Transfer rate: 1699.16 [Kbytes/sec] received ...

我开始testing完整的本地configuration,端口8080上的Nginx和8081上的clojure。事情进展良好,直到我超过了1024个并发连接。

我注意到,使用ss -tl ,接收队列不是尖峰,或者至less如果它在闪存中。 但是我发现,使用netstat -s ,有很多TCP RST正在发送。 有时, dmesg告诉我,它看起来像是一个SYN洪水。 另外,Nginx正在响应HTTP状态499,这应该表明客户端closures连接…

环境variablesCLAsspATH <> Clojure的CLAsspATH。 为什么?

试图与clojure离线使用lighttable – Windows 7 W / O互联网

Lein.bat无法在Windows XP中启动repl

在emacs中重新加载Clojure文件

在Windows的Git Bash中使用Leiningen

所以,我的诊断是交叉的,都是apache bench和Nginx声称对方closures了连接!

$ ulimit -n 4096 $ ab -n 20000 -c 2048 -k localhost:8080 This is ApacheBench,Version 2.3 <$Revision: 1528965 $> copyright 1996 Adam Twiss,Zeus Technology Ltd,http://www.zeustech.net/ Licensed to The Apache Software Foundation,http://www.apache.org/ Benchmarking localhost (be patient) apr_socket_recv: Connection reset by peer (104) Total of 26 requests completed

组态

我把Nginx和clojure的ulimit max打开文件设置为4096。

无用的networking变化

net.core.netdev_max_backlog=30000 # yes,we are using jumbo frames net.ipv4.tcp_mtu_probing=1 net.core.somaxconn=4096 net.ipv4.ip_local_port_range=4096 61000 net.ipv4.tcp_fin_timeout=30 net.ipv4.tcp_max_syn_backlog=2048

/etc/Nginx/Nginx.conf

user www-data; worker_processes 2; worker_rlimit_nofile 100000; error_log /var/log/Nginx/error.log; pid /run/Nginx.pid; events { worker_connections 2048; use epoll; } http { include /etc/Nginx/mime.types; default_type application/octet-stream; access_log /var/log/Nginx/access.log; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_requests 1000; keepalive_timeout 65; gzip on; gzip_http_version 1.0; gzip_comp_level 2; gzip_proxied any; gzip_vary off; gzip_types text/plain text/css application/x-javascript text/xml application/xml application/RSS+xml application/atom+xml text/javascript application/javascript application/json text/mathml; gzip_min_length 1000; gzip_disable "MSIE [1-6]."; variables_hash_max_size 1024; variables_hash_bucket_size 64; server_names_hash_bucket_size 128; types_hash_max_size 2048; types_hash_bucket_size 64; include /etc/Nginx/conf.d/*.conf; include /etc/Nginx/sites-enabled/*; }

在/ etc / Nginx的/启用的站点 – / UPS

upstream ups { server localhost:8081 fail_timeout=0; } server { listen 8080 backlog=1024; server_name example.com; proxy_buffer_size 128k; proxy_buffers 4 256k; proxy_busy_buffers_size 256k; client_max_body_size 3M; large_client_header_buffers 4 128k; proxy_read_timeout 300; proxy_send_timeout 300; send_timeout 300; keepalive_timeout 300; server_tokens off; access_log /var/log/Nginx/ups_access.log enhanced-combined; error_log /var/log/Nginx/ups_error.log; root /apps/ups/current/public/; error_page 403 /errors/403_maintenance.html; error_page 500 /errors/500.html; location ^~ /errors/ { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-Request-Id $request_uuid; satisfy any; allow all; } location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-Request-Id $request_uuid; if ($http_x_forwarded_proto = 'http') { rewrite ^ https://$host$request_uri? permanent; } if (-f $request_filename/index.html) { rewrite (.*) $1/index.html break; } if (-f $request_filename.html) { rewrite (.*) $1.html break; } if (!-f $request_filename) { proxy_pass http://ups; break; } } }

将Light Table连接到远程REPL

因为java类没有发现exception,所以leiningen不能运行

Leiningen在项目中回报EOFexception

更新swank / slime的Clojure版本

如何在Windows上为Clojure代码生成文档?

@Terra几乎得到了解决问题的答案。

accept_mutex off;

worker_connections 4096;

我尝试添加每个更改,本身,并重新加载,但我仍然看到了同样的错误。 直到我改变了两个,我可以推动超过1024个连接。

看来,由于代理人的原因,我需要有两倍的工人关系,我打算接受。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐