Welcome! Log In Create A New Profile

Advanced

Bad performance of nginx with Tomcat vs. Apache with Tomcat

Chang Song
September 03, 2009 02:36AM
Sometime ago, I posted an message about Nginx performance when paired
with Tomcat.
We recently did extensive in-house testing of various workload against
Nginx with Tomcat vs Apache vs Tomcat.

Apache wins hands down.

Here's the basic setup

1. Nginx (2 proc/8192 connections) -> http/1.0 -> Tomcat (HTTP
connector)
2. Apache (512 prefork) -> AJP -> Tomcat (AJP)

Both KeepAlive off (we don't use KeepAlive due to L4 switch)

The physical server is 2 core Intel Xeon, which is typical web server
config here.
We have three grinder 3.2 load generators.
We tested 4K and 20K Tomcat simple HTML file, 20K simple HTML with
intentional 10% 200ms
sleep in Tomcat serving (emulate slow DB query), etc.

Every single case, Apache wins by at least 10-15%.
Throughput and response time.
Nginx uses a bit less CPU cycles (10-20%), but it is not able drive
Tomcat to 100% CPU.

Here's my take on this performance problem.

1. Lack of AJP support, which is an optimized HTTP protocol
First of all, this is a serious bottleneck.

* AJP has much less communication overhead than HTTP

2. Lack of HTTP KeepAlive support for proxy

* Lack of AJP may be compensated with HTTP keepalive support since
there are
at least twice the number of TIME_WAIT sockets (connection
establishment mean time
is at least twice - three times slower than that of Apache)

3. Lack of connection pooling

* Ey-balancer makes things a bit easier, response times are
stable, but still the same
average TPS and response time.

4. There seems to be a huge bug in connection management code

Two mix of transactions: 20K HTML serving and 8K HTML with
intentional 200ms delay in Tomcat logic

With Apache, 20K HTML serving took 36 ms on average while 8K HTML
took 258 ms
With Nginx, 20K HTML serving took 600 ms on average while 8K HTML
took 817 ms

I really cannot explain these difference. Not even TCP connection
overhead or lack of AJP.

My questions is "should I abandon nginx at this point"?
I know nginx is great proxy and static file server but I cannot prove
my point with Tomcat over and over again.

Thank you

Chang
Subject Author Posted

Bad performance of nginx with Tomcat vs. Apache with Tomcat

Chang Song September 03, 2009 02:36AM

Re: Bad performance of nginx with Tomcat vs. Apache with Tomcat

István September 03, 2009 03:50AM

Re: Bad performance of nginx with Tomcat vs. Apache with Tomcat

Chang Song September 03, 2009 06:14PM

Re: Bad performance of nginx with Tomcat vs. Apache with Tomcat

István September 03, 2009 06:42PM

Re: Bad performance of nginx with Tomcat vs. Apache with Tomcat

Chang Song September 03, 2009 08:02PM

Re: Bad performance of nginx with Tomcat vs. Apache with Tomcat

István September 04, 2009 01:42PM

Re: Bad performance of nginx with Tomcat vs. Apache with Tomcat

Chang Song September 05, 2009 10:24AM

Re: Bad performance of nginx with Tomcat vs. Apache with Tomcat

István September 05, 2009 10:32AM

Re: Bad performance of nginx with Tomcat vs. Apache with Tomcat

imcaptor September 03, 2009 07:26AM

Re: Bad performance of nginx with Tomcat vs. Apache with Tomcat

Chang Song September 03, 2009 06:26PM

Re: Bad performance of nginx with Tomcat vs. Apache with Tomcat

Chang Song September 03, 2009 10:12PM

Re: Bad performance of nginx with Tomcat vs. Apache with Tomcat

anomalizer September 27, 2009 05:16AM

Re: Bad performance of nginx with Tomcat vs. Apache with Tomcat

Maxim Dounin September 03, 2009 07:10PM

Re: Bad performance of nginx with Tomcat vs. Apache with Tomcat

Chang Song September 03, 2009 08:10PM

Re: Bad performance of nginx with Tomcat vs. Apache with Tomcat

Maxim Dounin September 04, 2009 06:30AM

Re: Bad performance of nginx with Tomcat vs. Apache with Tomcat

Chang Song September 05, 2009 10:10AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 288
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready