0

I've got running a VPS at Linode with 1024 MB RAM, Ubuntu 11.04 and Nginx+PHP-FPM+APC Varnish+Memcached active. I've setup a couple of test blogs with WordPress 3.2.1 and everything works, and the performance tests seem promising:

# ab -n 1000 -c 100 http://mydomain.com/
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 mydomain.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:        nginx
Server Hostname:        mydomain.com
Server Port:            80

Document Path:          /
Document Length:        5677 bytes

Concurrency Level:      100
Time taken for tests:   0.186 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      5989000 bytes
HTML transferred:       5677000 bytes
Requests per second:    5376.14 [#/sec] (mean)
Time per request:       18.601 [ms] (mean)
Time per request:       0.186 [ms] (mean, across all concurrent requests)
Transfer rate:          31443.08 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        6    9   0.9      8      13
Processing:     4    9   1.3      9      14
Waiting:        1    5   2.5      5      13
Total:         12   18   1.6     18      22
WARNING: The median and mean for the initial connection time are not within a normal deviation
        These results are probably not that reliable.

Percentage of the requests served within a certain time (ms)
  50%     18
  66%     19
  75%     19
  80%     19
  90%     20
  95%     21
  98%     22
  99%     22
 100%     22 (longest request)

After installing Memcached and php5-memcache packages and enabling the WP Memcache plugin I can see the memcache server is up and running, with around a 50% of hits.The memcache service is using 64 MB of memory:

# ps xa |grep memcached
12259 ?        Sl     0:01 /usr/bin/memcached -m 64 -p 11211 -u memcache -l 127.0.0.1

What I can see, though, is a high consumption of main memory and swap, and I'd like to know if this is normal. The server is idle most of the time (the test blogs are running, but no one nows about them so I'm the only visitor), so I can't understand why the memory and swap are so high.

#free -m
             total       used       free     shared    buffers     cached
Mem:           927        906         21          0          6         58
-/+ buffers/cache:        840         87
Swap:          255        255          0

Any ideas?

Update: Seems Memcached is not the reason. I've stopped the server, the site is of course running, but the mem/swap consumption is still almost 100%. So there should be a problem, maybe with PHP-FPM or Varnish?

Update2: Seems PHP-FPM is the problem, look at this (thanks for the command, Tomtezky)

# ps aux --sort=-rss | head -15
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
www-data 12414  0.0  9.6 247840 91772 ?        S    01:25   0:06 php-fpm: pool www                                      
www-data 12405  0.0  9.5 244012 91212 ?        S    01:25   0:06 php-fpm: pool www                                      
www-data 12418  0.0  9.0 241820 86132 ?        S    01:25   0:05 php-fpm: pool www                                      
www-data 12417  0.0  8.5 236724 81500 ?        S    01:25   0:07 php-fpm: pool www                                      
www-data 12409  0.0  8.2 241980 78784 ?        S    01:25   0:05 php-fpm: pool www                                      
www-data 12407  0.0  8.1 236968 77880 ?        S    01:25   0:05 php-fpm: pool www                                      
www-data 12400  0.0  8.1 234344 77860 ?        S    01:25   0:06 php-fpm: pool www                                      
www-data 12408  0.0  8.1 237120 77700 ?        S    01:25   0:06 php-fpm: pool www                                      
www-data 12410  0.0  8.0 232248 76224 ?        S    01:25   0:06 php-fpm: pool www                                      
www-data 12413  0.0  7.6 242092 72452 ?        S    01:25   0:07 php-fpm: pool www                                      
www-data 12416  0.0  7.1 241812 68148 ?        S    01:25   0:05 php-fpm: pool www                                      
www-data 12412  0.0  7.0 220684 66644 ?        S    01:25   0:04 php-fpm: pool www                                      
www-data 12402  0.0  6.9 241556 66156 ?        S    01:25   0:05 php-fpm: pool www                                      
www-data 12419  0.0  6.2 238016 59304 ?        S    01:25   0:04 php-fpm: pool www

Seeing that... how to reduce PHP-FPM's memory use?

javipas
  • 1,332
  • 3
  • 23
  • 38
  • What is the output of `ps aux --sort=-rss | head -15`? – Tometzky Aug 19 '11 at 12:11
  • Output added TOmetzky, seems PHP-FPM is the responsible for that memory consumption, isn't it? – javipas Aug 19 '11 at 18:52
  • Would you mind posting your configs for nginx, php-fpm and memcached? Thanks. –  Dec 26 '11 at 17:52
  • JennyMac, doesn't matter, the problem was solved when I found where was the right path for the php5-fpm config files. Thanks! – javipas Dec 29 '11 at 16:04
  • javipas, I was actually trying to setup something similar to what you have, but I cannot get results similar or close to yours. Would you mind sharing your configs with me? I would appreciate it very much, hope you don't mind. Thank you. –  Dec 30 '11 at 01:51
  • Jenny Mac, there are several resources that you can follow, such as the guide published by Axel Segelbretch (http://www.axelsegebrecht.com/how-to/install-nginx-apc-varnish-wordpress-and-w3-cache-128mb-vps/) but you've got an easier path by using scripts such the fantastic ones on tuxlite (http://tuxlite.com/). Good luck ;) – javipas Dec 31 '11 at 09:16

1 Answers1

2

It isn't PHP-FPM, it's the Wordpress instance loaded in PHP-FPM. Limit the number of php-fpm workers, or trim down the memory footprint of your wordpress install.

MrTuttle
  • 1,176
  • 5
  • 5
  • I guessed changing the number of workers could work, but there is an additional problem, described in the AskUbuntu forum /http://askubuntu.com/questions/57875/php5-fpm-incomplete-install-on-ubuntu-11-04-no-config-file(. THe php5-fpm package does not install properly on Ubuntu 11.04, and it doesn't load the proper config file. So where do I have to create the php-fpm.conf file to restart php5-fpm with the right parameters? – javipas Aug 19 '11 at 23:33
  • I've finally found the config file. It's /etc/php5/fpm/pool.d/www.conf. There I can set up pm.start_servers and the rest of the parameters that allow me to reduce memory usage by PHP-FPM, but your suggestion is correct, thanks. – javipas Aug 19 '11 at 23:48