Nginx isn't as fast as i expect

Igor Clark igor at pokelondon.com
Thu Aug 16 14:38:18 MSD 2007


On 16 Aug 2007, at 11:16, somebody nobody wrote:

> i have tested nginx and apache with the "ab" tool. This is my results:
>
> Apache:
>    Requests per second:    6058.62 [#/sec]
>
>
> Nginx:
>    Requests per second:    1170.02 [#/sec]

Umm, what kind of request profile did you send from ab? What kinds of  
resources are being requested?

I find nginx to be noticeably faster than apache on static files with  
serial requests, and many times faster using high levels of  
concurrency. For dynamic requests to PHP over FastCGI/tcp, it's also  
faster, has better concurrency and uses very significantly less  
system resources.

On a dual-core 2ghz xeon with 4GB RAM nginx served nearly 500k PIs of  
a site with a ~1mb home page weight (yes, i know ;-) - designers ...)  
in one day without ever swapping and without system load going above  
2. Just trying to mimic that load using ab against Apache brought the  
machine to its knees in minutes. Turning up the concurrency on ab  
causes Apache to starting eating RAM and CPU like nobody's business,  
whereas nginx handles it smoothly and quietly.

> this is my nginx.conf:
>
> @@@@@
>
> user  nobody nogroup;
> worker_processes  10;
>
> error_log  logs/error.log;
> pid        logs/nginx.pid;
>
> events {
>     worker_connections  512;
>     use eventport; #sol 10+
> }

I'm relatively new to nginx but on the site mentioned above I run 2  
worker processes with 8192 worker_connections.

> http {
>     include       conf/mime.types;
>     default_type  application/octet-stream;
>
>     log_format  main  '$remote_addr - $remote_user [$time_local]  
> $request '
>                       '"$status" $body_bytes_sent "$http_referer" '
>                       '"$http_user_agent" "$http_x_forwarded_for"';
>
>     access_log  logs/access.log  main;
>
>     sendfile        off;
>     tcp_nopush on;
>     tcp_nodelay on;
>     keepalive_timeout  65;

This is interesting ... I use keepalive_timeout of 4 or 5 seconds

>     #gzip  on;
>
>     root /home/mywebsite;
>     index index.php;
>
>     client_max_body_size    128k;
>     client_body_buffer_size 128k;
>
>     server {
>         listen       80;
>         server_name  www.mywebsite.com;
>
>         #access_log off;
>
>     #
>     # PHP
>     #
>
>         location / {
>             client_max_body_size    128k;
>             client_body_buffer_size 128k;
>
>             root   /home/mywebsite;
>             index  index.php index.html;
>         }
>
>         location ~ \.php$ {
>             include /nginx/conf/fcgi.conf;
>             fastcgi_pass unix:/tmp/fastcgi.socket;
>             fastcgi_index index.php;
>         }
>
>
>         error_page  404              /404.html;
>
>         location /404.html {
>             root /home/mywebsite;
>             charset on;
>         }
>
> What can i do more to make it faster ??


--
Igor Clark // POKE // 10 Redchurch Street // E2 7DD // +44 (0)20 7749  
5355 // www.pokelondon.com

We've gone sub-zero with the TopGear Cool Wall: http:// 
www.topgear.com/coolwall/


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20070816/07ef11c6/attachment.html>


More information about the nginx mailing list