我已经在Linode使用1024 MB RAM,Ubuntu 11.04和Nginx + PHP-FPM + APC Varnish + Memcached主动运行VPS。 我已经用WordPress 3.2.1设置了几个testing博客,一切正常,性能testing看起来很有希望:
# 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)
在安装Memcached和php5-memcache软件包并启用WP Memcache插件之后,我可以看到memcache服务器已经启动并运行了大约50%的命中。memcache服务使用了64 MB的内存:
# ps xa |grep memcached 12259 ? Sl 0:01 /usr/bin/memcached -m 64 -p 11211 -u memcache -l 127.0.0.1
但是,我所看到的是主存和交换的高消耗,我想知道这是否正常。 服务器大部分时间都处于闲置状态(testing博客正在运行,但是没有人关心它们,所以我是唯一的访问者),所以我不明白为什么内存和交换是如此之高。
#free -m total used free shared buffers cached Mem: 927 906 21 0 6 58 -/+ buffers/cache: 840 87 Swap: 255 255 0
有任何想法吗?
更新:似乎Memcached不是原因。 我已经停止了服务器,该网站当然在运行,但mem / swap消耗仍然几乎是100%。 所以应该有一个问题,也许用PHP-FPM或Varnish?
更新2:似乎PHP-FPM是问题,看看这个(感谢命令,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
看到…如何减lessPHP-FPM的内存使用?
它不是PHP-FPM,它是在PHP-FPM中加载的Wordpress实例。 限制php-fpm worker的数量,或者减lesswordpress安装的内存占用。