<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><div><br></div><div>I think I have already said everything about my config. nginx has very simple config.</div><div>Here's my config except all those variations of parameters I tried (ey-balancer is off)</div><div><br></div><div><div>worker_processes &nbsp;2;</div><div>events {</div><div>&nbsp;&nbsp; &nbsp;worker_connections &nbsp;8192;</div><div>&nbsp;&nbsp; &nbsp;accept_mutex off;</div><div>}</div><div>http {</div><div>&nbsp;&nbsp; &nbsp;include &nbsp; &nbsp; &nbsp; mime.types;</div><div>&nbsp;&nbsp; &nbsp;default_type &nbsp;application/octet-stream;</div><div>&nbsp;&nbsp; &nbsp;access_log &nbsp;off;</div><div>&nbsp;&nbsp; &nbsp;keepalive_timeout &nbsp;0;</div><div>&nbsp;&nbsp; &nbsp;server {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;listen &nbsp; &nbsp; &nbsp; 80;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;server_name &nbsp;localhost;</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;location / {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;root &nbsp; html;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;index &nbsp;index.html index.htm;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;location ~ \.jsp$ {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;root &nbsp; &nbsp; &nbsp; &nbsp; /usr/local/tomcat5.5;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;proxy_pass &nbsp; <a href="http://127.0.0.1:8080">http://127.0.0.1:8080</a></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp;}</div><div>}</div><div><br></div></div><div><br></div><div>I didn't want to include the config file since I don't think it reveals anything wrong</div><div>and there were so many variations of them as I already said.</div><div><br></div><div>I just wanted to share my nginx with Tomcat performance experience to see if anyone else</div><div>has the same problem or anyone else already have a solution.</div><div><br></div><div>Thank you for your reply.</div><div><br></div><div><br></div><br><div><div>On Sep 5, 2009, at 2:00 AM, István wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">well we can argue on the tools you are using but the point is that you have an obvious performance drop somehow :)<br><br><br>better to move to that direction to be able to find, fix it.<br><br>however i have no problem if you are using apache further, just don't see the point to share your experience here if you don't want to share the config <br>
<br><br>regards,<br>Istvan<br><br><div class="gmail_quote">On Fri, Sep 4, 2009 at 12:36 AM, Chang Song <span dir="ltr">&lt;<a href="mailto:changsong@me.com">changsong@me.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style="word-wrap: break-word;"><div><br></div><div><br></div>Hi, Istvan<div><br></div><div>It is not about 50K single node nginx throughput.</div><div>I have a standard TCP/IP tuning settings.</div><div><br></div><div>
We can reach 70K throughput in some workloads.</div><div>THey ALL depends on workloads.</div><div><br></div><div>I have not given all the details so that why you are saying that but</div><div>we are measure and capturing every possible system resource under /proc.</div>
<div><br></div><div>dstat does not tell you everything.</div><div>We are currently using collectl and collectd, and captures everything under /proc</div><div><br></div><div>This is a sample of nginx access log (proxy service time and nginx service time is there)</div>
<div><br></div><div><div>[03/Sep/2009:12:19:02 +0900] 10.25.131.46 200 8254 gzip:-% conns:199229 up_response_t:0.392 svc_t:0.831 "GET /index_think.jsp HTTP/1.1"</div><div>[03/Sep/2009:12:19:02 +0900] 10.25.131.48 200 20524 gzip:-% conns:199622 up_response_t:0.150 svc_t:0.668 "GET /static/20k.jsp HTTP/1.1"</div>
<div><br></div><div>I don't think we are in a position to debug deeper into nginx since we need to move on.</div><div>Thanks</div><div><br></div><div><br></div></div><div><div></div><div class="h5"><div><br><div><div>
On Sep 4, 2009, at 7:19 AM, István wrote:</div><br><blockquote type="cite">I see,<div><br></div><div>well I was able to reach about 50K req/s on a single node with nginx with tuning linux/tcp stack/nginx and i learned one thing:</div>
<div><br></div><div>measure instead of guess</div><div><br></div>
<div>(and as a side effect: debug instead of guess.)</div><div><br></div><div>So, if i were you i would start dstat(<span style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse;"><span style="background-color: rgb(199, 202, 204);">dstat</span>&nbsp;-cgilpymn)<span style="border-collapse: separate; font-family: arial; font-size: small;">&nbsp;on that host and see the different elements of you system, enable debug logging, even stracing nginx</span></span></div>

<div><br></div><div>This is the way I think.</div><div><br></div><div>Regards,</div><div>Istvan</div><div><div><br></div><div><br><br><div class="gmail_quote">On Thu, Sep 3, 2009 at 10:51 PM, Chang Song <span dir="ltr">&lt;<a href="mailto:changsong@me.com" target="_blank">changsong@me.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div style="word-wrap: break-word;"><div><br></div><div>Istvan.</div><div>It didn't really matter what config I used.</div>

<div><br></div><div>I tried all combinations of&nbsp;</div><div><br></div><div>worker_process (2-512)</div><div>worker_connections (512-16000)</div><div>accept_mutex (on/off)</div><div>tcp_nopush (on/off)</div><div>tcp_nodelay (on/off)</div>

<div>proxy_buffer* (various sizes)</div><div>and other proxy related parameters you can imagine.</div><div>The one I showed you has the best performance</div><div>The following showed the best performance across the board</div>

<div><br></div><div>worker_process 2; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # since we have 2 core machine</div><div>worker_connections 16000; &nbsp;&nbsp;</div><div>accept_mutex off;</div><div>max_connections 256; &nbsp; &nbsp; &nbsp; &nbsp;# ey-balancer (tomcat had 512 threads)</div>

<div>everything else default</div><div><br></div><div><div>Thank you.</div><div><br></div><div><br></div></div><div><div></div><div><br><div><div>On Sep 3, 2009, at 4:26 PM, István wrote:</div><br><blockquote type="cite">

I think it would be beneficial to show us your nginx config :)<br><br>Regards,<br>Istvan<br><br><div class="gmail_quote">On Thu, Sep 3, 2009 at 5:50 AM, Chang Song <span dir="ltr">&lt;<a href="mailto:changsong@me.com" target="_blank">changsong@me.com</a>&gt;</span> wrote:<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 clear="all"><br>-- <br>the sun shines for all<br>
</blockquote></div><br></div></div></div></blockquote></div><br><br clear="all"><br>-- <br>the sun shines for all<br>
</div></div>
</blockquote></div><br></div></div></div></div></blockquote></div><br><br clear="all"><br>-- <br>the sun shines for all<br>
</blockquote></div><br></body></html>