PHP-FPM High Memory Usage
- by Ruel
I have a wordpress blog, that uses WP-SuperCache, and normally I get 100 visitors per day. With nginx + php-fpm it's blazing fast, and I have no regrets.
One thing i noticed, php-fpm takes a lot of memory:
top - 09:20:43 up 5 days, 15:53, 1 user, load average: 0.00, 0.00, 0.00
Tasks: 26 total, 1 running, 25 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 1048576k total, 329956k used, 718620k free, 0k buffers
Swap: 0k total, 0k used, 0k free, 0k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
10226 www-data 15 0 145m 52m 4584 S 0.0 5.1 0:07.55 php-fpm
10223 www-data 16 0 141m 48m 4692 S 0.0 4.8 0:08.70 php-fpm
20277 www-data 15 0 138m 46m 4368 S 0.0 4.5 0:07.55 php-fpm
20259 www-data 15 0 133m 41m 4600 S 0.0 4.0 0:06.68 php-fpm
12201 www-data 15 0 133m 41m 4632 S 0.0 4.0 0:08.31 php-fpm
11586 www-data 15 0 132m 40m 4292 S 0.0 3.9 0:03.27 php-fpm
29822 www-data 15 0 128m 36m 4356 S 0.0 3.6 0:05.26 php-fpm
28427 mysql 15 0 200m 7300 4764 S 0.0 0.7 0:47.89 mysqld
10202 root 18 0 98.3m 4320 1204 S 0.0 0.4 0:03.80 php-fpm
22524 root 18 0 86064 3396 2652 S 0.0 0.3 0:16.74 sshd
9882 www-data 18 0 42052 2572 804 S 0.0 0.2 0:27.52 nginx
9884 www-data 18 0 42052 2560 804 S 0.0 0.2 0:26.26 nginx
9881 www-data 18 0 42064 2524 804 S 0.0 0.2 0:29.24 nginx
9879 www-data 18 0 42032 2480 804 S 0.0 0.2 0:29.58 nginx
23771 root 15 0 12176 1820 1316 S 0.0 0.2 0:00.08 bash
28344 root 22 0 11932 1416 1184 S 0.0 0.1 0:00.00 mysqld_safe
18167 root 16 0 62628 1208 648 S 0.0 0.1 0:00.55 sshd
25941 root 15 0 12612 1192 928 R 0.0 0.1 0:02.21 top
11573 root 15 0 20876 1168 592 S 0.0 0.1 0:00.67 crond
9878 root 18 0 41000 1112 284 S 0.0 0.1 0:00.00 nginx
21736 root 23 0 21648 936 716 S 0.0 0.1 0:00.00 xinetd
11585 root 18 0 46748 816 428 S 0.0 0.1 0:00.00 saslauthd
14125 root 12 -4 12768 768 452 S 0.0 0.1 0:00.00 udevd
1 root 18 0 10352 728 616 S 0.0 0.1 0:17.93 init
24564 root 15 0 5912 680 544 S 0.0 0.1 0:01.90 syslogd
11618 root 18 0 46748 548 160 S 0.0 0.1 0:00.00 saslauthd
Here's my php-fpm config:
[global]
pid = run/php-fpm.pid
error_log = log/php-fpm.log
log_level = notice
[www]
listen = 127.0.0.1:9000
user = www-data
group = www-data
pm = dynamic
pm.max_children = 50
pm.start_servers = 3
pm.min_spare_servers = 3
pm.max_spare_servers = 10
pm.max_requests = 500
Sometimes it goes up to 400MB. And I'm planning to add a new website on my VPS. Is this normal?