Tuning nginx

Hi all,

I've got NGINX running on maverick along with php5-fpm on a Linode 512 in a LEMP configuration (no apache).

The setup is running pretty well but I'm mystified about how some people claim to get hundreds/thousands of reqs/sec on a Linode 512.

To try to narrow down any performance bottlenecks I've switched off the php5-fpm service, mysql etc. and just have nginx serving up pure html pages to see what benchmarks I could get.

I setup 2 pages:

http://dev2.themesforge.com/hellojoe.html - simple hello world page - no html (1k approx.)

http://dev2.themesforge.com/statichp.html - static copy of a simple WordPress homepage (19k approx.)

I then run the following ab test on the first page (http://dev2.themesforge.com/hellojoe.html)

ab -n 1000 -c 100 http://dev2.themesforge.com/hellojoe.html

From 3 locations - results as follows:

Another linode machine in the same DC (NJ DC) -> anywhere between 3000-6000 reqs/sec

Another VPS in Europe-> approx. 1000-1500 reqs/sec

My macbook (also in Europe)-> approx. 400 reqs/sec from my mac book pro

So far so good.

Then I run the same ab on the second page (http://dev2.themesforge.com/statichp.html)

Results as follows:

Another linode machine in the same DC (NJ DC) -> anywhere between 40-50 reqs/sec

Another VPS in Europe-> approx. 40-50 reqs/sec

My macbook (also in Europe)-> approx. 11-12 reqs/sec from my mac book pro

Is it normal to see such a drop off by nginx when page size grows?

My nginx.conf is pretty standard (NGINX V1.0) as follows:

user www-data;
worker_processes 4;
pid /var/run/nginx.pid;

events {
    worker_connections 768;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

#mail {
#    # See sample authentication script at:
#    # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
# 
#    # auth_http localhost/auth.php;
#    # pop3_capabilities "TOP" "USER";
#    # imap_capabilities "IMAP4rev1" "UIDPLUS";
# 
#    server {
#        listen     localhost:110;
#        protocol   pop3;
#        proxy      on;
#    }
# 
#    server {
#        listen     localhost:143;
#        protocol   imap;
#        proxy      on;
#    }
#}

my vhost is also pretty simple (just the location blocks below)

    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to index.html
        try_files $uri $uri/ /index.html;
    }

        location ~ \.php$ {
                include fastcgi_params;
                fastcgi_pass  127.0.0.1:9000;
        }

2 Replies

The total "weight" of the statichp.html page is 218.5KB. And your HTML is 143.1K (not 19K). According to my test 143,361,000 bytes total were transferred.

Document Path:          /statichp.html
Document Length:        143148 bytes

Concurrency Level:      100
Time taken for tests:   24.249 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      143361000 bytes
HTML transferred:       143148000 bytes
Requests per second:    41.24 [#/sec] (mean)
Time per request:       2424.892 [ms] (mean)
Time per request:       24.249 [ms] (mean, across all concurrent requests)
Transfer rate:          5773.49 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       76  275 395.8    247    3384
Processing:  1126 2047 610.2   1900    6036
Waiting:       76  210 139.0    201    1829
Total:       1476 2322 701.6   2148    6534

That's out of Fremont. I wouldn't have any problem with those sorts of numbers.

@waldo:

The total "weight" of the statichp.html page is 218.5KB. And your HTML is 143.1K (not 19K). According to my test 143,361,000 bytes total were transferred.

Document Path:          /statichp.html
Document Length:        143148 bytes

Concurrency Level:      100
Time taken for tests:   24.249 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      143361000 bytes
HTML transferred:       143148000 bytes
Requests per second:    41.24 [#/sec] (mean)
Time per request:       2424.892 [ms] (mean)
Time per request:       24.249 [ms] (mean, across all concurrent requests)
Transfer rate:          5773.49 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       76  275 395.8    247    3384
Processing:  1126 2047 610.2   1900    6036
Waiting:       76  210 139.0    201    1829
Total:       1476 2322 701.6   2148    6534

That's out of Fremont. I wouldn't have any problem with those sorts of numbers.

ahh - penny drops - that might explain a lot! I was looking at the page size via firebug and it is showing the gzip compressed file size which is obviously not served up via ab - my bad!

The numbers make a lot more sense now.

Thanks waldo.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct