Hello,
I have nginx fronting a tomcat 6.0 server, using APR connections.
I have nginx configured to communication with tomcat over HTTP/1.1:
http {
...
upstream tomcat {
server 127.0.0.1:8080;
keepalive 12;
}
server {
....
location ... {
proxy_pass http://tomcat;
proxy_http_version 1.1;
proxy_set_header Connection "Keep-Alive";
....
}
}
}
Tomcat is set to with a connectionTimeout of 60s and a keepAliveTimeout of 60s, and maxKeepAliveRequests set to "-1" (no limit).
I've been tracking sockets in TIME_WAIT state between nginx and tomcat, and noticed that once there are 500-600 established connections under moderate-to-heavy load, there are an equivalent number of TIME_WAIT sockets.
I collected a dump with tcpdump and analysed it with Wireshark, and noticed that it is always nginx that is initiating the TCP connection termination by sending a FIN to 127.0.0.1:8080.
Is there a way to keep the connections open? Increasing the keepalive setting to a large number (eg. 256) eliminates the TIME_WAIT sockets, but I would rather keep this value low and have nginx keep the connection open.
I could very well be misunderstanding how this is working, and the behaviour I am seeing is actually desirable, in which case I would appreciate some enlightenment.
Thanks,
Ben
PS. A link on how to format code snippets would be appreciate too.
I have nginx fronting a tomcat 6.0 server, using APR connections.
I have nginx configured to communication with tomcat over HTTP/1.1:
http {
...
upstream tomcat {
server 127.0.0.1:8080;
keepalive 12;
}
server {
....
location ... {
proxy_pass http://tomcat;
proxy_http_version 1.1;
proxy_set_header Connection "Keep-Alive";
....
}
}
}
Tomcat is set to with a connectionTimeout of 60s and a keepAliveTimeout of 60s, and maxKeepAliveRequests set to "-1" (no limit).
I've been tracking sockets in TIME_WAIT state between nginx and tomcat, and noticed that once there are 500-600 established connections under moderate-to-heavy load, there are an equivalent number of TIME_WAIT sockets.
I collected a dump with tcpdump and analysed it with Wireshark, and noticed that it is always nginx that is initiating the TCP connection termination by sending a FIN to 127.0.0.1:8080.
Is there a way to keep the connections open? Increasing the keepalive setting to a large number (eg. 256) eliminates the TIME_WAIT sockets, but I would rather keep this value low and have nginx keep the connection open.
I could very well be misunderstanding how this is working, and the behaviour I am seeing is actually desirable, in which case I would appreciate some enlightenment.
Thanks,
Ben
PS. A link on how to format code snippets would be appreciate too.