Did you know that you can run the old fart apache2 server as a “nginx + php5-fpm”? Will publish some blitz.io values for better comparison.
Here we’ll get a working apache2 server which will pass the php requests to php5-fpm, acting as a static file serving… server. Why not using nginx, you might ask? I’m too lazy to convert .htaccess to a .nginx-compatible-file.conf.
1. apt-get install apache2 apache2-bin apache2-data apache2-mpm-worker apache2-utils libapache2-mod-fcgid libapache2-mod-ruid2
This version does NOT understand php at all. If you’d like your “mpm” to dance with builtin php, go with apache2-mod-prefork + libapache2-mod-php5.
- Scroll inside apache config /etc/apache2/conf-available/php5-fpm.conf and paste these lines:
<IfModule mod_fastcgi.c> AddHandler php5-fcgi .php Action php5-fcgi /php5-fcgi Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /var/run/php5-fpm.sock -pass-header Authorization </IfModule>
<Directory /usr/lib/cgi-bin> Require all granted </Directory>
The IfModule explains to apache where it can find the php executable. Don’t forget to enable the necessary mods:
- a2enmod actions fastcgi alias
and to enable (activate) the config file above:
- a2enconf php5-fpm
- Go into /etc/php5/fpm/pool.d/www-conf and tweak the parameters to your desired needs. This may include
- setting a timeout
- setting a limit for spawned children & a total number of requests it will serve each and every one
Your phpinfo(); should work from this point.
Later edit:
Nginx + PHP5-FPM results:
This rush generated 7,651 successful hits in 30 seconds and we transferred 21.83 MB of data in and out of your app. The average hit rate of 310.93/second translates to about 26,864,640 hits/day.
The average response time was 599 ms.
This test was aborted at 28 seconds.
RESPONSE TIMES
- FASTEST: 276 MS
- SLOWEST: 1,081 MS
- AVERAGE: 599 MS
TEST CONFIGURATION
- REGION: VIRGINIA
- DURATION: 30 SECONDS
- LOAD: 1-1000 USERS
OTHER STATS
-
AVG. HITS: 311 /SEC
-
DATA TRANSFERED:21.83MB
HITS
This rush generated 7,651 successful hits. The number of hits includes all the responses listed below. For example, if you only want HTTP 200 OK responses to count as Hits, then you can specify --status 200
in your rush.
CODE | TYPE | DESCRIPTION | AMOUNT |
---|---|---|---|
200 | HTTP | OK | 2075 |
404 | HTTP | Not Found | 5576 |
Apache2-mod-worker + PHP5-FPM results
ANALYSIS
This rush generated 1,243 successful hits in 30 seconds and we transferred 11.73 MB of data in and out of your app. The average hit rate of 43.57/second translates to about 3,764,160 hits/day.
The average response time was 2,945 ms.
This test was aborted at 28 seconds.
You've got bigger problems, though: 51.41% of the users during this rushexperienced timeouts or errors!
RESPONSE TIMES
- FASTEST: 110 MS
- SLOWEST: 4,363 MS
- AVERAGE: 2,945 MS
TEST CONFIGURATION
- REGION: IRELAND
- DURATION: 30 SECONDS
- LOAD: 1-1000 USERS
OTHER STATS
- AVG. HITS: 44 /SEC
- DATA TRANSFERED: 11.73MB
- HITS 48.59% (1243)
- ERRORS 17.51% (448)
- TIMEOUTS 33.89% (867)
HITS
This rush generated 1,243 successful hits. The number of hits includes all the responses listed below. For example, if you only want HTTP 200 OK responses to count as Hits, then you can specify --status 200
in your rush.
CODE | TYPE | DESCRIPTION | AMOUNT |
---|---|---|---|
200 | HTTP | OK | 1243 |
- HTTP 200 OK 100% (1243)
ERRORS
The first error happened at 27.5 seconds into the test when the number of concurrent users was at 916. Errors are usually caused by resource exhaustion issues, like running out of file descriptors or the connection pool size being too small (for SQL databases).
CODE | TYPE | DESCRIPTION | AMOUNT |
---|---|---|---|
23 | TCP | Connection timeout | 448 ERRORS |
- CONNECTION TIMEOUT 100% (448)
This is the result i got on a 4vCores VPS, 1024MB RAM and 512MB vSwap along with 100GB HDD.
Good luck at learning nginx syntax!