The Blog

GimmeSoda.com Server Move: XCache, W3-Total-Cache and Nginx = Awesome

2

I’ve moved this site (gimmesoda.com) over to a test server (Private Server) I’ve got running on DreamHost. This server is running Nginx instead of Apache, both machines (the PS it was running on before, and the PS it is now running on) are set to 2GB of memory and the software setup of WordPress is exactly the same.

Why:

Apache can be a memory hog.

As more and more traffic comes into a website the Apache process continues to spawn memory hogging worker processes and during my basic testing I saw over 90 apache worker processes spawned at one time. Each of those processes were taking about 23MB worth of memory when spawned (23 x 90 = 2070MB) which maxed out the $100/month PS machine and returned several hundred errors at 100 concurrent connections.

Nginx handles concurrency much better and requires far less memory.

When the site was moved over to Nginx I ran the same test (1000 requests with 100 concurrency) and memory usage was under 800MB, it also returned 0 errors compared to the 664 from the use of Apache. Also, you should take note of the speed between the two in the results below, Nginx returned all requests in under 1s.

WordPress Cache Settings:

I’ve switched off the use of WP-SuperCache, which uses disk based caching and provides no further options such as opcode caching (APC/XCache/eAccelerator) which W3-Total-Cache does provide! Not only does it provide a static page cache as well as opcode options but it incorporates minify options, database, and object caching among other features.

All cache options have been set to XCache rather then disk, after all reading from memory is faster then reading from disk.

The Setup:

  • WordPress v3.0.1
    • Theme
      • I am using the Mystique theme, which thankfully does NOT use the timthumb.php script (I am NOT a fan of it).
      • Plugins
        • Akismet
        • All in One SEO Pack
        • Categories to Tags Converter Importer
        • Clean-Contact
        • Dragon Design Sitemap Generator
        • DreamHost WordPress Backup
        • FeedBurner FeedSmith
        • Google XML Sitemaps
        • Paypal Donate Plugin for WordPress Widget Support
        • Permalinks Moved Permanently
        • Piwiks Analytics
        • Twitter for WordPress
        • W3-Total-Cache
        • WordPress.com Stats
        • WordPress Importer
        • WP-FLV
        • WP-PayPalDonate

AB (ApacheBench) Results:

Apache Results Nginx Results
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking www.gimmesoda.com (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests

Server Software:        Apache
Server Hostname:        www.gimmesoda.com
Server Port:            80

Document Path:          /
Document Length:        30876 bytes

Concurrency Level:      100
Time taken for tests:   6.912 seconds
Complete requests:      1000
Failed requests:        664
   (Connect: 0, Receive: 0, Length: 664, Exceptions: 0)
Write errors:           0
Non-2xx responses:      664
Total transferred:      10878952 bytes
HTML transferred:       10588808 bytes
Requests per second:    144.67 [#/sec] (mean)
Time per request:       691.234 [ms] (mean)
Time per request:       6.912 [ms] (mean, across all concurrent requests)
Transfer rate:          1536.96 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        1   15 164.4      7    3013
Processing:    24  511 782.2    190    4087
Waiting:       17  503 778.0    188    4074
Total:         46  526 792.6    196    4091

Percentage of the requests served within a certain time (ms)
  50%    196
  66%    266
  75%    499
  80%    744
  90%   2018
  95%   2703
  98%   2983
  99%   3060
 100%   4091 (longest request)
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking www.gimmesoda.com (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Finished 1000 requests

Server Software:        nginx/0.7.65
Server Hostname:        www.gimmesoda.com
Server Port:            80

Document Path:          /
Document Length:        30874 bytes

Concurrency Level:      100
Time taken for tests:   3.158373 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      31348328 bytes
HTML transferred:       30961170 bytes
Requests per second:    316.62 [#/sec] (mean)
Time per request:       315.837 [ms] (mean)
Time per request:       3.158 [ms] (mean, across all concurrent requests)
Transfer rate:          9692.65 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        1   22  11.8     20      63
Processing:    36  184 108.6    144     874
Waiting:        8   34  24.6     26     279
Total:         37  206 111.5    166     913

Percentage of the requests served within a certain time (ms)
  50%    166
  66%    209
  75%    251
  80%    273
  90%    347
  95%    405
  98%    569
  99%    641
 100%    913 (longest request)

More Information

Nginx: A web server written to address the C10K problem. http://wiki.nginx.org/Main

XCache: A fast opcode cacher, it’s a PHP extension. http://xcache.lighttpd.net/

W3-Total-Cache: A brilliant (and free) wordpress caching plugin that goes the extra mile. http://wordpress.org/extend/plugins/w3-total-cache/

Pardon the dust….

0

I’m working on reorganizing this entire blog, so yeah things may not be organized the way you may be used to, give me some time and it’ll all be sorted!

Looks like I finished much sooner then expected!

Go to Top