hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : VPS Hosting : Optimizing nginx for a VPS environment
Reply

Forum Jump

Optimizing nginx for a VPS environment

Reply Post New Thread In VPS Hosting Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 05-30-2010, 12:12 AM
danclough danclough is offline
Web Hosting Master
 
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




Sponsored Links
  #2  
Old 05-30-2010, 12:30 AM
dyna! dyna! is offline
Web Hosting Evangelist
 
Join Date: Oct 2006
Location: canada
Posts: 528
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  
Old 05-30-2010, 12:40 AM
danclough danclough is offline
Web Hosting Master
 
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


Sponsored Links
  #4  
Old 05-30-2010, 01:00 AM
fwaggle fwaggle is offline
Web Hosting Master
 
Join Date: Mar 2008
Posts: 1,715
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.

__________________
Jamie @ Sabrienix
Now with Mumble Hosting!

  #5  
Old 05-30-2010, 01:27 AM
travislopes travislopes is offline
Junior Guru Wannabe
 
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  
Old 05-30-2010, 01:31 AM
danclough danclough is offline
Web Hosting Master
 
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  
Old 05-30-2010, 01:36 AM
devonblzx devonblzx is offline
Web Hosting Master
 
Join Date: Nov 2005
Location: Michigan, USA
Posts: 3,705
Most likely the fastcgi config is in /etc/nginx/conf.d/

maybe fastcgi.conf?

  #8  
Old 05-30-2010, 01:40 AM
danclough danclough is offline
Web Hosting Master
 
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  
Old 05-30-2010, 02:40 AM
netroby netroby is offline
Aspiring Evangelist
 
Join Date: Jan 2010
Posts: 388
was that true?
but at our server, seems nginx got better performance.

Reply

Similar Threads
Thread Thread Starter Forum Replies Last Post
If I need a help with optimizing a vps where can I get it ToBlEr0nE VPS Hosting 10 03-03-2010 09:20 PM
VPS hosting NGinx Fully spupported? roy250 VPS Hosting 5 12-03-2009 02:53 AM
Optimizing a VPS server brkonthru VPS Hosting 6 09-17-2008 07:22 AM
Shared Hosting Environment: nginx LuckyBambu Hosting Security and Technology 0 08-02-2008 11:32 PM
VPS Optimizing Website Hosted Hosting Security and Technology 1 02-13-2007 05:49 PM

Related posts from TheWhir.com
Title Type Date Posted
Nginx to be Included in Upcoming Ubuntu Release Web Hosting News 2014-01-08 15:17:12
Nginx Raises $10M to Extend Commercial Support Web Hosting News 2013-10-15 11:20:26
Inside NGINX's First Commerical Product Web Hosting News 2014-05-09 12:40:27
nginx Version 1.4.0 Supports SPDY Protocol Web Hosting News 2013-04-29 15:08:14
Nginx Aims to Grow Market Share Under New CEO Gus Robertson Web Hosting News 2013-04-08 14:28:48


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?