<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><div>imcaptor.</div><div>Man, you are a lifesaver.</div><div><br></div><div>That changes everything. I build tomcat with apr native, and nginx comes back alive and well!!</div><div><br></div><div>Nginx beats Apache by at least 10-20% and the response time better by 10-20%</div><div><br></div><div>I will have check other workloads as well, but nginx holds up pretty well.</div><div><br></div><div>This is great, Thank you very much.</div><div><br></div><div>For those who uses Nginx - Tomcat setup, Http11Apr is A MUST!!</div><div><br></div><br><div><div>On Sep 3, 2009, at 7:57 PM, imcaptor wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">You can use native Connector.<br>Http11AprProtocol try again.<br><br><div class="gmail_quote">2009/9/3 Chang Song <span dir="ltr">&lt;<a href="mailto:changsong@me.com">changsong@me.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Sometime ago, I posted an message about Nginx performance when paired with Tomcat.<br>
We recently did extensive in-house testing of various workload against Nginx with Tomcat vs Apache vs Tomcat.<br>
<br>
Apache wins hands down.<br>
<br>
Here's the basic setup<br>
<br>
1. Nginx (2 proc/8192 connections) -&gt; http/1.0 -&gt; Tomcat (HTTP connector)<br>
2. Apache (512 prefork) -&gt; AJP -&gt; Tomcat (AJP)<br>
<br>
Both KeepAlive off (we don't use KeepAlive due to L4 switch)<br>
<br>
The physical server is 2 core Intel Xeon, which is typical web server config here.<br>
We have three grinder 3.2 load generators.<br>
We tested 4K and 20K Tomcat simple HTML file, 20K simple HTML with intentional 10% 200ms<br>
sleep in Tomcat serving (emulate slow DB query), etc.<br>
<br>
Every single case, Apache wins by at least 10-15%.<br>
Throughput and response time.<br>
Nginx uses a bit less CPU cycles (10-20%), but it is not able drive Tomcat to 100% CPU.<br>
<br>
Here's my take on this performance problem.<br>
<br>
1. Lack of AJP support, which is an optimized HTTP protocol<br>
 &nbsp; First of all, this is a serious bottleneck.<br>
<br>
 &nbsp; * AJP has much less communication overhead than HTTP<br>
<br>
2. Lack of HTTP KeepAlive support for proxy<br>
<br>
 &nbsp; * Lack of AJP may be compensated with HTTP keepalive support since there are<br>
 &nbsp; &nbsp; at least twice the number of TIME_WAIT sockets (connection establishment mean time<br>
 &nbsp; &nbsp; is at least twice - three times slower than that of Apache)<br>
<br>
3. Lack of connection pooling<br>
<br>
 &nbsp; * Ey-balancer makes things a bit easier, response times are stable, but still the same<br>
 &nbsp; &nbsp; average TPS and response time.<br>
<br>
4. There seems to be a huge bug in connection management code<br>
<br>
 &nbsp; Two mix of transactions: 20K HTML serving and 8K HTML with intentional 200ms delay in Tomcat logic<br>
<br>
 &nbsp; With Apache, 20K HTML serving took &nbsp;36 ms on average while 8K HTML took 258 ms<br>
 &nbsp; With Nginx, &nbsp;20K HTML serving took 600 ms on average while 8K HTML took 817 ms<br>
<br>
 &nbsp; I really cannot explain these difference. Not even TCP connection overhead or lack of AJP.<br>
<br>
My questions is "should I abandon nginx at this point"?<br>
I know nginx is great proxy and static file server but I cannot prove my point with Tomcat over and over again.<br>
<br>
Thank you<br><font color="#888888">
<br>
Chang<br>
<br>
<br>
<br>
<br>
</font></blockquote></div><br><br><blockquote style="margin: 1.5em 0pt;">imcaptor</blockquote>
</blockquote></div><br></body></html>