Performance problem with Tomcat


#1

Hi, folks.

I have been testing nginx with Tomcat backend server, and I was
disappointed
with the result. 30-40% worse than apache front web server setup.
I think the culprit of the performance problem is the absence of
persistent
connection (KeepAlive HTTP/1.1) to Tomcat like Apache’s AJP connection.

Does anyone has the same problem?
Anyone with a good solution?

Thank you.

Chang


#2

I was getting more than 70-80,000 sockets in TIME_WAIT.
I had to use tcp_timestamp to recycle them faster otherwise I get huge
dip in performance
once in a while (along with IP port range all open)

Since MSL is 60 second, that is more than 1200 TCP connections/sec.
All there is to my nginx config is upstream and proxy_pass config.
that’s it.

1/19/09, ¿ÀÈÄ 10:45, Dave C. ÀÛ¼º:


#3

I find that hard to believe. In practice the overhead of setting up a
tcp connection on the same machine (or on the local network) is
negligible.

Post your config and lets see what can be done.

Cheers

Dave


#4

Chang S. wrote:

Hi, folks.

I have been testing nginx with Tomcat backend server, and I was
disappointed
with the result. 30-40% worse than apache front web server setup.
I think the culprit of the performance problem is the absence of
persistent
connection (KeepAlive HTTP/1.1) to Tomcat like Apache’s AJP connection.

Does anyone has the same problem?
Anyone with a good solution?

Thank you.

Chang

Hey, Im using tomcat, its running on localhost port 8180, without AJP
and works quite fine. I dont see any actual issue with it.

Maybe try to eliminate AJP connector, just use it the clasic way and it
might work better, try also this kernel settings:

net.ipv4.tcp_timestamps=0
net.ipv4.tcp_fin_timeout = 1
net.ipv4.tcp_tw_recycle = 1


#5

Thank you, Robert.

Maybe I wasn’t articulate enough.
I am not using AJP port, I am simply using Tomcat directly.
And I have all those sysctl setting correct, except tcp_timestamps.
With tcp_timestamps=0, I am overflowing with too many sockets in
TIME_WAIT. I have to use timestamps=1 to reduce the number of
sockets in TIME_WAIT.

1/20/09, ¿ÀÀü 12:15, Robert G. ÀÛ¼º:


#6

Chang S. wrote:

Thank you, Robert.

Maybe I wasn’t articulate enough.
I am not using AJP port, I am simply using Tomcat directly.
And I have all those sysctl setting correct, except tcp_timestamps.
With tcp_timestamps=0, I am overflowing with too many sockets in
TIME_WAIT. I have to use timestamps=1 to reduce the number of
sockets in TIME_WAIT.

1/20/09, ���� 12:15, Robert G. �ۼ�:

Well for me work… I dont know about timestamps, but I have to check a
bit on it, maybe you are right, but the rest of them will be usefull.
Also I use tomcat without keep-alive… meaning in nginx I have
keep-alive=0 and seems to work, faster and quite well… but I dont know
how good it is. :slight_smile:


#7

Robert G. wrote:

Chang S. wrote:

Thank you, Robert.

Maybe I wasn’t articulate enough.
I am not using AJP port, I am simply using Tomcat directly.
And I have all those sysctl setting correct, except tcp_timestamps.
With tcp_timestamps=0, I am overflowing with too many sockets in
TIME_WAIT. I have to use timestamps=1 to reduce the number of
sockets in TIME_WAIT.

1/20/09, ���� 12:15, Robert G. �ۼ�:

Well for me work… I dont know about timestamps, but I have to check a
bit on it, maybe you are right, but the rest of them will be usefull.
Also I use tomcat without keep-alive… meaning in nginx I have
keep-alive=0 and seems to work, faster and quite well… but I dont know
how good it is. :slight_smile:

P.S. I dont think tcp_timestamps is such a good idea to be set to 1…
try to search it only, but I wouldnt recommend it.


#8

Robert G. wrote:

Some aditional tweaks might help :slight_smile:

net.ipv4.tcp_syncookies=1
net/ipv4/tcp_keepalive_time = 900
net/ipv4/tcp_keepalive_probes = 5
net.ipv4.tcp_sack = 0

Sorry net.ipv4.tcp_sack = 1, its better to be turned on.


#9

Some aditional tweaks might help :slight_smile:

net.ipv4.tcp_syncookies=1
net/ipv4/tcp_keepalive_time = 900
net/ipv4/tcp_keepalive_probes = 5
net.ipv4.tcp_sack = 0


#10

Usually tcp_timestamps=1 is not a good idea since it adds overhead to
TCP
processing, but my case is that if I don’t have that one, sockets in
TIME_WAIT
grows unboundedly in such a way that the system runs out of port or
cannot allocate more sockets (throughput drops dramatically
periodically)

1/20/09, 오후 4:54, Robert G. 작성:


#11

These do not have ANY effect on local testing at all.
I have my own sets of sysctl settings.
thanks

1/20/09, ¿ÀÈÄ 4:56, Robert G. ÀÛ¼º: