# Nginx Wordpress php-fpm fastcgi_cache + Google Nginx PageSpeed



## eva2000 (May 23, 2013)

Hi folks, wondering if anyone here has tested Nginx php-fpm fastcgi_cache with Google ngx_pagespeed module ?

 

I am testing Centmin Mod v1.2.3 beta install of Nginx 1.4.1 + PHP 5.3.25 (php-fpm) with ngx_pagespeed 1.5.27.3 beta and wanting to see how it would fair with a fresh Wordpress 3.5.1 install at localhost/wp. 

 

*Results:*

 


I successfully tried setting up fastcgi_cache for php for wordpress http://centminmod.com/nginx_configure_wordpress.html#fastcgicache

Enabling ngx_pagespeed enabled top of this, works fine for ngx_pagespeed itself http://centminmod.com/nginx_configure_wordpress.html#pagespeed
But, with ngx_pagespeed enabled, it drops Siege benchmark performance back to non-fastcgi_cache levels as if ngx_pagespeed rendered fastcgi_cache useless ? Curious if anyone has experienced the same ?
 

Below is nginx restart output along with curl header for localhost/wp and siegebenchmark results for wordpress fastcgi_cache php-fpm

 


With ngx_pagespeed off, Siege benchmark = *2,403 requests/s*

With ngx_pagespeed enabled + memcached, Siege benchmark only manages *266 requests/s*
With ngx_pagespeed enabled and memcached disabled, Siege benchmark results in *225 requests/s*
 

*###################*

With ngx_pagespeed off, Siege benchmark = 2,403 requests/second

 



```
[[email protected] ~]# pscontrol off
Setting option from ("off")
Setting option from ("FileCachePath", "/var/ngx_pagespeed_cache")
Setting option from ("MessageBufferSize", "100000")
Setting option from ("XHeaderValue", "ngx_pagespeed")
Setting option from ("MemcachedThreads", "1")
Setting option from ("MemcachedServers", "localhost:11211")
Setting option from ("RewriteLevel", "CoreFilters")
Setting option from ("EnableFilters", "collapse_whitespace,remove_comments")
Setting option from ("EnableFilters", "combine_javascript")
Setting option from ("EnableFilters", "rewrite_images")
Setting option from ("EnableFilters", "convert_png_to_jpeg")
Setting option from ("EnableFilters", "convert_jpeg_to_webp")
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
Stopping nginx:                                            [  OK  ]
Starting nginx: Setting option from ("off")
Setting option from ("FileCachePath", "/var/ngx_pagespeed_cache")
Setting option from ("MessageBufferSize", "100000")
Setting option from ("XHeaderValue", "ngx_pagespeed")
Setting option from ("MemcachedThreads", "1")
Setting option from ("MemcachedServers", "localhost:11211")
Setting option from ("RewriteLevel", "CoreFilters")
Setting option from ("EnableFilters", "collapse_whitespace,remove_comments")
Setting option from ("EnableFilters", "combine_javascript")
Setting option from ("EnableFilters", "rewrite_images")
Setting option from ("EnableFilters", "convert_png_to_jpeg")
Setting option from ("EnableFilters", "convert_jpeg_to_webp")
                                                           [  OK  ]
```



```
[[email protected] ~]# curl -I http://localhost/wp/
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 23 May 2013 08:00:07 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Vary: Accept-Encoding
X-Pingback: http://localhost/wp/xmlrpc.php
X-Cached: HIT
```



```
siege -q -b -c50 -r50 http://localhost/wp/
      done.


Transactions:                   2500 hits
Availability:                 100.00 %
Elapsed time:                   1.04 secs
Data transferred:               8.11 MB
Response time:                  0.02 secs
Transaction rate:            2403.85 trans/sec
Throughput:                     7.79 MB/sec
Concurrency:                   48.58
Successful transactions:        2500
Failed transactions:               0
Longest transaction:            0.06
Shortest transaction:           0.00
```

 

*###################*

With ngx_pagespeed enabled + memcached, Siege benchmark only manages 266 requests/s

 



```
[[email protected] ~]# pscontrol on
Setting option from ("on")
Setting option from ("FileCachePath", "/var/ngx_pagespeed_cache")
Setting option from ("MessageBufferSize", "100000")
Setting option from ("XHeaderValue", "ngx_pagespeed")
Setting option from ("MemcachedThreads", "1")
Setting option from ("MemcachedServers", "localhost:11211")
Setting option from ("RewriteLevel", "CoreFilters")
Setting option from ("EnableFilters", "collapse_whitespace,remove_comments")
Setting option from ("EnableFilters", "combine_javascript")
Setting option from ("EnableFilters", "rewrite_images")
Setting option from ("EnableFilters", "convert_png_to_jpeg")
Setting option from ("EnableFilters", "convert_jpeg_to_webp")
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
Stopping nginx:                                            [  OK  ]
Starting nginx: Setting option from ("on")
Setting option from ("FileCachePath", "/var/ngx_pagespeed_cache")
Setting option from ("MessageBufferSize", "100000")
Setting option from ("XHeaderValue", "ngx_pagespeed")
Setting option from ("MemcachedThreads", "1")
Setting option from ("MemcachedServers", "localhost:11211")
Setting option from ("RewriteLevel", "CoreFilters")
Setting option from ("EnableFilters", "collapse_whitespace,remove_comments")
Setting option from ("EnableFilters", "combine_javascript")
Setting option from ("EnableFilters", "rewrite_images")
Setting option from ("EnableFilters", "convert_png_to_jpeg")
Setting option from ("EnableFilters", "convert_jpeg_to_webp")
                                                           [  OK  ]
```


```
[[email protected] ~]# curl -I http://localhost/wp/              
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 23 May 2013 08:18:55 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Vary: Accept-Encoding
X-Pingback: http://localhost/wp/xmlrpc.php
X-Cached: HIT
Cache-Control: max-age=0, no-cache
X-Page-Speed: ngx_pagespeed
```


```
siege -q -b -c50 -r50 http://localhost/wp/
      done.


Transactions:                   2500 hits
Availability:                 100.00 %
Elapsed time:                   9.38 secs
Data transferred:               9.21 MB
Response time:                  0.18 secs
Transaction rate:             266.52 trans/sec
Throughput:                     0.98 MB/sec
Concurrency:                   48.01
Successful transactions:        2500
Failed transactions:               0
Longest transaction:            0.43
Shortest transaction:           0.00
```

 

*###################*

With ngx_pagespeed on and memcached disabled, Siege benchmark results in 225 requests/s

 



```
[[email protected] ~]# pscontrol on                                                 
Setting option from ("on")
Setting option from ("FileCachePath", "/var/ngx_pagespeed_cache")
Setting option from ("MessageBufferSize", "100000")
Setting option from ("XHeaderValue", "ngx_pagespeed")
Setting option from ("RewriteLevel", "CoreFilters")
Setting option from ("EnableFilters", "collapse_whitespace,remove_comments")
Setting option from ("EnableFilters", "combine_javascript")
Setting option from ("EnableFilters", "rewrite_images")
Setting option from ("EnableFilters", "convert_png_to_jpeg")
Setting option from ("EnableFilters", "convert_jpeg_to_webp")
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
Stopping nginx:                                            [  OK  ]
Starting nginx: Setting option from ("on")
Setting option from ("FileCachePath", "/var/ngx_pagespeed_cache")
Setting option from ("MessageBufferSize", "100000")
Setting option from ("XHeaderValue", "ngx_pagespeed")
Setting option from ("RewriteLevel", "CoreFilters")
Setting option from ("EnableFilters", "collapse_whitespace,remove_comments")
Setting option from ("EnableFilters", "combine_javascript")
Setting option from ("EnableFilters", "rewrite_images")
Setting option from ("EnableFilters", "convert_png_to_jpeg")
Setting option from ("EnableFilters", "convert_jpeg_to_webp")
                                                           [  OK  ]
```


```
[[email protected] ~]# curl -I http://localhost/wp/
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 23 May 2013 08:23:23 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Vary: Accept-Encoding
X-Pingback: http://localhost/wp/xmlrpc.php
X-Cached: HIT
Cache-Control: max-age=0, no-cache
X-Page-Speed: ngx_pagespeed
```


```
[[email protected] ~]# siege -q -b -c50 -r50 http://localhost/wp/
      done.


Transactions:                   2500 hits
Availability:                 100.00 %
Elapsed time:                  11.10 secs
Data transferred:               9.21 MB
Response time:                  0.14 secs
Transaction rate:             225.23 trans/sec
Throughput:                     0.83 MB/sec
Concurrency:                   31.82
Successful transactions:        2500
Failed transactions:               0
Longest transaction:            8.06
Shortest transaction:           0.00
```


----------



## acd (May 23, 2013)

<Edit: After actually reading how nginx handles upstreams, this can't possibly be the case (fcgi caching pagespeed). Let this be a lesson to anyone who would post w/o sleeping.>


----------



## eva2000 (May 23, 2013)

cheers acd, had a hard time even finding documentation for that setting until https://developers.google.com/speed/docs/mod_pagespeed/install#ModifyCachingHeaders 

will test it out


----------



## ICPH (Sep 6, 2015)

Hello, i see "ngx_pagespeed" is included in Your Centmin Mod LEMP stack if im correct. Does it mean that if pagespeed is enabled, requests/second is lower than when module is disabled ?



> with ngx_pagespeed enabled, it drops Siege benchmark performance back to non-fastcgi_cache levels as if ngx_pagespeed rendered fastcgi_cache useless ?
> With ngx_pagespeed off, Siege benchmark = *2,403 requests/s*
> With ngx_pagespeed enabled + memcached, Siege benchmark only manages *266 requests/s*
> With ngx_pagespeed enabled and memcached disabled, Siege benchmark results in *225 requests/s*



Thank you


----------



## eva2000 (Sep 6, 2015)

Well ngx_pagespeed module has overhead involved as there's no free lunch for faster page loading benefits ngx_pagespeed gives. However, ngx_pagespeed has come along way since back when i posted those benchmarks. ngx_pagespeed also supports downstream caching for proxy cache and varnish caching see https://developers.google.com/speed/pagespeed/module/downstream-caching


----------

