Forum: NGINX performance problem with Tomcat

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Chang S. (Guest)
on 2009-01-19 15:34
(Received via mailing list)
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
Dave C. (Guest)
on 2009-01-19 15:53
(Received via mailing list)
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
Chang S. (Guest)
on 2009-01-19 17:06
(Received via mailing list)
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. ÀÛ¼º:
Robert G. (Guest)
on 2009-01-19 17:15
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
Chang S. (Guest)
on 2009-01-19 22:37
(Received via mailing list)
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. ÀÛ¼º:
Robert G. (Guest)
on 2009-01-20 09:52
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. :)
Robert G. (Guest)
on 2009-01-20 09:54
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. :)

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.
Robert G. (Guest)
on 2009-01-20 09:56
Some aditional tweaks might help :)

net.ipv4.tcp_syncookies=1
net/ipv4/tcp_keepalive_time = 900
net/ipv4/tcp_keepalive_probes = 5
net.ipv4.tcp_sack = 0
Robert G. (Guest)
on 2009-01-20 10:03
Robert G. wrote:
> Some aditional tweaks might help :)
>
> 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.
Chang S. (Guest)
on 2009-01-20 15:18
(Received via mailing list)
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. ÀÛ¼º:
Chang S. (Guest)
on 2009-01-20 15:18
(Received via mailing list)
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. 작성:
This topic is locked and can not be replied to.