Results 1 to 9 of 9
  1. #1
    Join Date
    Apr 2005
    Location
    Under The Floor Tiles
    Posts
    566

    Optimizing nginx for a VPS environment

    I have a small dynamic web site (Wordpress) that I run on a VPS.net server with 376MB RAM. Web serving is the only thing the server in question does, as I've offloaded the database to another geographically separate VPS node.

    I'm stuck between running Apache 2 and nginx. Apache 2 is a royal RAM hog, but nginx is painfully slow on page loads.

    So, I decided to objectively test each web server by hammering them both with a 30-second siege of 15 concurrent sessions from my database server. Here are the results when serving via Apache 2:

    Code:
    Transactions:		         262 hits
    Availability:		      100.00 %
    Elapsed time:		       29.69 secs
    Data transferred:	        4.04 MB
    Response time:		        1.11 secs
    Transaction rate:	        8.82 trans/sec
    Throughput:		        0.14 MB/sec
    Concurrency:		        9.77
    Successful transactions:         262
    Failed transactions:	           0
    Longest transaction:	        1.63
    Shortest transaction:	        0.86
    And nginx/FastCGI:
    Code:
    Transactions:		         150 hits
    Availability:		      100.00 %
    Elapsed time:		       30.14 secs
    Data transferred:	        2.56 MB
    Response time:		        2.34 secs
    Transaction rate:	        4.98 trans/sec
    Throughput:		        0.09 MB/sec
    Concurrency:		       11.67
    Successful transactions:         150
    Failed transactions:	           0
    Longest transaction:	        3.06
    Shortest transaction:	        1.10
    Apache is handling twice as many transactions per second than nginx. What gives? Is nginx just not that great at serving dynamic content?
    "When a man begins to doubt himself, he does something incredibly stupid and thereby is reassured."
    ::http://www.dustytech.net/:: Personal Website

  2. #2
    Join Date
    Oct 2006
    Location
    canada
    Posts
    529
    Posting just the results doesn't really say much. You need to at least post the relevant worker/prefork section of Apache config and likewise the core of nginx config and the FCGI settings.
    What did you expect was going to happen?
    6sync is where I've made my home ): // @tenkay

  3. #3
    Join Date
    Apr 2005
    Location
    Under The Floor Tiles
    Posts
    566
    Apache worker:
    Code:
    <IfModule mpm_worker_module>
        StartServers          2
        MaxClients          150
        MinSpareThreads      25
        MaxSpareThreads      75
        ThreadsPerChild      25
        MaxRequestsPerChild   0
    </IfModule>
    As for nginx, I've just got the baseline config straight from apt-get:
    Code:
    user www-data;
    worker_processes  2;
    
    error_log  /var/log/nginx/error.log;
    pid        /var/run/nginx.pid;
    
    events {
        worker_connections  1024;
    }
    
    http {
        include       /etc/nginx/mime.types;
        default_type  application/octet-stream;
    
        access_log  /var/log/nginx/access.log;
    
        sendfile        on;
        #tcp_nopush     on;
    
        #keepalive_timeout  0;
        keepalive_timeout  65;
        tcp_nodelay        on;
    
        gzip  on;
    
        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
    }
    Do you mean the FastCGI settings in nginx, or in PHP?
    "When a man begins to doubt himself, he does something incredibly stupid and thereby is reassured."
    ::http://www.dustytech.net/:: Personal Website

  4. #4
    Join Date
    Mar 2008
    Posts
    1,717
    Post the FastCGI settings for PHP from both Apache and nginx.

    Unless you're using mod_php, which would explain the boost right there.

    Come to think of it, activate caching with a plugin from WP and I bet nginx hauls ass.
    I used to run the oldest commercial Mumble host.

  5. #5
    Join Date
    Jul 2007
    Posts
    41
    Quote Originally Posted by fwaggle View Post
    Post the FastCGI settings for PHP from both Apache and nginx.

    Unless you're using mod_php, which would explain the boost right there.

    Come to think of it, activate caching with a plugin from WP and I bet nginx hauls ass.
    You definitely wanting to use a caching plugin when using WordPress and Nginx.
    I had a site get on Digg and it got 60K+ viewers in about 12 hours. Server didn't crash once and pages were loading as if no one else was accessing the site.

  6. #6
    Join Date
    Apr 2005
    Location
    Under The Floor Tiles
    Posts
    566
    WP Super Cache is installed and working, and brought nginx up to par with Apache in terms of response time.

    I'm using mod_php5 on the Apache side, and I'm not sure where to go on the nginx side to see my FastCGI settings. Is that synonymous with fastcgi_param?
    "When a man begins to doubt himself, he does something incredibly stupid and thereby is reassured."
    ::http://www.dustytech.net/:: Personal Website

  7. #7
    Join Date
    Nov 2005
    Posts
    3,944
    Most likely the fastcgi config is in /etc/nginx/conf.d/

    maybe fastcgi.conf?

  8. #8
    Join Date
    Apr 2005
    Location
    Under The Floor Tiles
    Posts
    566
    I've got this in /etc/default/php-fastcgi:

    Code:
    START=yes
    
    # Which user runs PHP? (default: www-data)
    EXEC_AS_USER=www-data
    
    # Host and TCP port for FASTCGI-Listener (default: localhost:9000)
    FCGI_HOST=localhost
    FCGI_PORT=8888
    
    # Environment variables, which are processed by PHP
    PHP_FCGI_CHILDREN=4
    PHP_FCGI_MAX_REQUESTS=1000
    "When a man begins to doubt himself, he does something incredibly stupid and thereby is reassured."
    ::http://www.dustytech.net/:: Personal Website

  9. #9
    was that true?
    but at our server, seems nginx got better performance.

Similar Threads

  1. Replies: 10
    Last Post: 03-03-2010, 09:20 PM
  2. VPS hosting NGinx Fully spupported?
    By roy250 in forum VPS Hosting
    Replies: 5
    Last Post: 12-03-2009, 02:53 AM
  3. Optimizing a VPS server
    By brkonthru in forum VPS Hosting
    Replies: 6
    Last Post: 09-17-2008, 07:22 AM
  4. Shared Hosting Environment: nginx
    By LuckyBambu in forum Hosting Security and Technology
    Replies: 0
    Last Post: 08-02-2008, 11:32 PM
  5. VPS Optimizing
    By GazCBG in forum Hosting Security and Technology
    Replies: 1
    Last Post: 02-13-2007, 05:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •