nginx做代理,后端tomcat响应时间很快,但nginx的响应时间很慢

u010570150 2014-10-27 04:58:36
1,网站用nginx做前端代理,动态请求指向后端的tomcat,tomcat的响应时间为0.005秒,nginx响应为60.006秒。
2,此时捕捉到的nginx tcp:
TIME_WAIT 2992
SYN_SENT 2
FIN_WAIT1 55
ESTABLISHED 356
FIN_WAIT2 433
SYN_RECV 7
CLOSING 1
LAST_ACK 13
表明 nginx连接没有问题
3,nginx的buffer配置proxy_ignore_client_abort on;
client_header_buffer_size 128k;
large_client_header_buffers 4 128k;
proxy_buffer_size 32k;
proxy_buffers 50 64k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 128k;
4,系统已经做了/etc/sysctl.conf优化
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 90
net.ipv4.tcp_keepalive_probes = 2
net.ipv4.tcp_keepalive_intvl = 2

5,nginx.conf 中 keepalive_timeout 65;

...全文
24724 15 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
kidkissed 2017-05-22
  • 打赏
  • 举报
回复
请求头,响应头有问题把,配置下就OK了
oaoutoaout 2017-02-20
  • 打赏
  • 举报
回复
[root@local senginx]# ps aux|grep "nginx: worker process" | awk '{print $1}' nobody nobody nobody nobody nobody nobody nobody nobody nobody nobody nobody nobody nobody nobody nobody nobody root [root@local senginx]# 你好,我这边执行出来有很多行,其中最后一个是root用户,适用于你说的情况吗?
happyboygd 2015-10-19
  • 打赏
  • 举报
回复
解决办法是: ps aux | grep "nginx: worker process" | awk '{print $1}' 如果得到结果是root的话,那就改一下proxy_temp的权限 chown -R root:root proxy_temp 如果结果是www 那就chown -R www:www proxy_temp
u010570150 2014-11-04
  • 打赏
  • 举报
回复
不设缓冲,也不行
u010570150 2014-11-04
  • 打赏
  • 举报
回复
actually,we use single-one at first, as PV becomming more , then we use the balance.
u010570150 2014-10-30
  • 打赏
  • 举报
回复
Our proxy configure is very easy. upstream tomcat{ server IPaddress1:8088; server IPaddress2:8088; ip_hash; } location / { index index.jsp; proxy_pass http://tomcat;
  • 打赏
  • 举报
回复
引用 7 楼 u010570150 的回复:
Our proxy configure is very easy. upstream tomcat{ server IPaddress1:8088; server IPaddress2:8088; ip_hash; } location / { index index.jsp; proxy_pass http://tomcat;
you are right, it's quite simple and plain config...Have you tried to disable the load balancing and see if that makes any difference?
过去的我 2014-10-30
  • 打赏
  • 举报
回复
不要设置缓存。试试。
  • 打赏
  • 举报
回复
引用 5 楼 u010570150 的回复:
worker_processes 8; worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000; error_log logs/error.log info; pid logs/nginx.pid; events { use epoll; worker_connections 32768; } http { include mime.types; default_type application/octet-stream; charset utf-8; include proxy_tomcat.conf; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for" "$request_time" '; access_log logs/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; server_tokens off; proxy_ignore_client_abort on; client_header_buffer_size 128k; large_client_header_buffers 4 128k; keepalive_timeout 5; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml image/jpeg image/gif image/png; gzip_vary on; gzip_disable "MSIE [1-6]\.";
these are all global configuration, where is the section for the proxy setup?
u010570150 2014-10-29
  • 打赏
  • 举报
回复
worker_processes 8; worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000; error_log logs/error.log info; pid logs/nginx.pid; events { use epoll; worker_connections 32768; } http { include mime.types; default_type application/octet-stream; charset utf-8; include proxy_tomcat.conf; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for" "$request_time" '; access_log logs/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; server_tokens off; proxy_ignore_client_abort on; client_header_buffer_size 128k; large_client_header_buffers 4 128k; keepalive_timeout 5; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml image/jpeg image/gif image/png; gzip_vary on; gzip_disable "MSIE [1-6]\.";
  • 打赏
  • 举报
回复
引用 3 楼 u010570150 的回复:
If anyone who could help us,if he need, we can share our Web Server's configure with him.
post ur nginx.conf
u010570150 2014-10-28
  • 打赏
  • 举报
回复
If anyone who could help us,if he need, we can share our Web Server's configure with him.
u010570150 2014-10-28
  • 打赏
  • 举报
回复
用的是nginx日志和tomcat的日志记录,request_time
  • 打赏
  • 举报
回复
how did you catch the response time info? tcpdump?

18,829

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 专题技术讨论区
社区管理员
  • 专题技术讨论区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧