Project

General

Profile

Actions

Feature #72

closed

evaluate nginx for gucky web server

Added by Florian Effenberger over 10 years ago. Updated about 10 years ago.

Status:
Closed
Priority:
Normal
Category:
-
Target version:
-
Start date:
Due date:
% Done:

0%

Tags:

Description

Our current setup doesn't seem to allow enough multiple connections, even on dedicated, powerful hardware. Therefore, we should evaluate nginx.
Robert is willing to help if we want :-)

Actions #1

Updated by Florian Effenberger over 10 years ago

  • Tracker changed from Bug to Feature
Actions #2

Updated by Christian Lohmaier over 10 years ago

Simple php benchmark results: requesting the download page 40000 times, with concurrency of 3 with ab tool:

  • apache prefork with mod_php:
    54,4 #/sec 55,11 ms/req 3,07 5-minute-load
  • apache prefork with mod_fcgid
    55,7 #/sec 53,85 ms/req 3,00
  • apache worker with mod_fcgid
    56,9 #/sec 52,68 ms/req 3,02

→ As expected no significant difference in php performance or load, however memory usage with prefork/mod_php combination is "insane", since every apache worker needs RAM for running php, while with mod_fcgid apache processes themselves need almost no ressources, only the php workers consume RAM. Especially when running multiple vhosts (wiki and silverstripe), and each using different php, this adds up.

  • for comparison nginx with php-fpm
    58,16 #/sec 51,58 ms/req 3,05

→ confirms that the time spent is php - cannot be faster than that/is cpu bound. (similar with mod_fcgid nginx itself doesn't consume resources, only the php-fpm pool's processes consume memory

Where nginx kicks apache's butt however is in connection handling/serving static content from disk, especially with https:

  • serving static copy of the download page from disk via https (http)
    nginx: ~ 660 #/sec 4,5 ms/req (> 32000 #/sec 0,09ms)
    apache: ~ 450 #/sec 6,7 ms/req (~ 10000 #/sec 0,30ms)
  • even more apparent when keepalive is turned on:
    nginx: > 16000 #/sec 0,18 ms/req (> 70000 #/sec 0,04ms)
    apache: 6800 #/sec 0,43 ms/req (~ 10500 #/sec 0,28ms)

Serving static files via plain http is a no-brainer for both configuration, although nginx easily outperforms apache in this regard).
Serving content via https however introduces quite a bit of computational overhead in the connection-handling, and here nginx with keepalive really makes apache look old.

Conclusion: The Load issues from the current server could not be reproduced by just checking silverstripe in isolation, with requesting one page a lot of time. Nevertheless it is clear that apache prefork with mod_php is the clear looser - not so much because of CPU usage (after all neither has noteworthy impact on php execution), but because of memory usage.

fast-cgi / php-fpm definitely is the way to go. And if we have the choice to use either apache or nginx, I'd go for nginx, due to the mixed nature of the site (many static files from disk in addition to the php).
If (contrary to expectations) the load is still high, we can still enable creating static html from silverstripe for many page-types and avoid php-roundtrip for those completely.

Actions #3

Updated by Florian Effenberger over 10 years ago

Thanks so much for investigating this, Christian! It indeed looks
promising, and I support the plan to move to nginx. Let's discuss
details via e-mail.

Actions #4

Updated by Florian Effenberger about 10 years ago

  • Status changed from New to Closed
  • Assignee set to Christian Lohmaier
Actions

Also available in: Atom PDF