龙空技术网

有效的Tomcat、Nginx调优小妙招

清风徐月小咸鱼 356

前言:

眼前朋友们对“nginx157”大致比较看重,咱们都想要分析一些“nginx157”的相关文章。那么小编同时在网上汇集了一些对于“nginx157””的相关内容,希望大家能喜欢,我们一起来了解一下吧!

1. Tomcat相关参数修改

修改../conf/server.xml

<Connector executor="tomcatThreadPool"

port="8080" protocol="HTTP/1.1"

maxThreads="1500"

keepAliveTimeout="60000"

maxKeepAliveRequests="300"

minSpareThreads="300"

maxSpareThreads="1000"

acceptCount="200"

maxConnections="2000"

connectionTimeout="20000"

redirectPort="8443" />

增加初始化内存(初始2048M,最大3000M,以16G内存为例):

vi bin/catalina.sh

JAVA_OPTS="-Xms2048m -Xmx3000m -XX:PermSize=512m -XX:MaxPermSize=512m"

1. Nginx 参数优化

修改配置文件nginx.conf

user www www;

worker_processes 8;

error_log logs/error.log info;

pid logs/nginx.pid;

worker_rlimit_nofile 65536;

events {

use epoll;

worker_connections 65536;

}

http {

include mime.types;

default_type application/octet-stream;

proxy_buffer_size 256k;

proxy_buffers 32 64k;

proxy_busy_buffers_size 256k;

fastcgi_buffer_size 256k;

fastcgi_buffers 32 64k;

fastcgi_connect_timeout 300;

fastcgi_read_timeout 300;

fastcgi_send_timeout 300;

proxy_connect_timeout 300;

proxy_read_timeout 300;

proxy_send_timeout 300;

server_names_hash_bucket_size 128;

sendfile on;

tcp_nopush on;

keepalive_timeout 65;

tcp_nodelay on;

gzip on;

client_max_body_size 40m;

fastcgi_intercept_errors on;

对于后台访问配置,由于柜员一般一直在线,因此我们建议采用长链接方式,这可以用来减少TCP链接数。长链接配置参数参考下述红色字体部分:

upstream khgl.httest.com

{

server 10.10.10.157:38883;

keepalive 128;

}

location / {

#proxy_pass ;

proxy_pass ;

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header X-real-uri $request;

proxy_read_timeout 300s;

proxy_http_version 1.1;

proxy_set_header Connection "";

autoindex on;

}

}

标签: #nginx157 #nginxtomcatcgi问题