Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have this web server running on nginx + MySQL + php5 + Wordpress. The thing is, the server is to slow and I think it's due to the number of php5-fpm running.

Look at the numbers of php5-fpm processes I have. It's too much! The server can't handle that much (I think). How do I decrease the number of processes?

top - 18:38:26 up  2:45,  3 users,  load average: 59.34, 47.33, 25.20
Mem:    498320k total,   492616k used,     5704k free,      484k buffers
Swap:  2096124k total,  2064080k used,    32044k free,    12772k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
  719 root      20   0     0    0    0 D    0  0.0   1:01.73 kswapd0
11242 www-data  20   0  318m 5240  552 D    0  1.1   0:11.12 php5-fpm
11239 www-data  20   0  318m 5424   88 D   10  1.1   0:10.37 php5-fpm
11250 www-data  20   0  315m 4692  500 D    0  0.9   0:10.16 php5-fpm
11245 www-data  20   0  320m 5020   40 D    0  1.0   0:09.60 php5-fpm
11241 www-data  20   0  319m 5148   56 D   10  1.0   0:09.29 php5-fpm
 3233 root      20   0 58688 1120  736 D    0  0.2   0:09.27 vmtoolsd
11256 www-data  20   0  318m 5272   76 D    0  1.1   0:08.93 php5-fpm
11247 www-data  20   0  318m 5648   48 D    0  1.1   0:08.73 php5-fpm
11251 www-data  20   0  314m 4312  316 D    0  0.9   0:08.63 php5-fpm
14751 www-data  20   0  315m 4240   76 D    0  0.9   0:08.25 php5-fpm
11244 www-data  20   0  318m 5056   48 D    0  1.0   0:07.83 php5-fpm
14967 mysql     20   0  252m 8328    0 S    2  1.7   0:07.81 mysqld
14817 www-data  20   0  307m 4616   36 D    0  0.9   0:07.79 php5-fpm
14758 www-data  20   0  307m 4580   16 D    0  0.9   0:07.70 php5-fpm
14786 www-data  20   0  307m 4076   20 D    0  0.8   0:07.29 php5-fpm
11243 www-data  20   0  318m 6896  104 D    0  1.4   0:07.16 php5-fpm
11252 www-data  20   0  310m 4532   68 D    0  0.9   0:07.01 php5-fpm
11255 www-data  20   0  318m 5028   88 D    0  1.0   0:06.79 php5-fpm
14761 www-data  20   0  308m 4688   16 D    0  0.9   0:06.46 php5-fpm
14834 www-data  20   0  306m 4760  404 D    0  1.0   0:06.39 php5-fpm
14757 www-data  20   0  307m 4340   20 D    0  0.9   0:06.34 php5-fpm
14762 www-data  20   0  307m 4068   20 D    0  0.8   0:06.27 php5-fpm
    1 root      20   0 23760    0    0 S    0  0.0   0:06.18 init
11240 www-data  20   0  318m 5868   72 D    0  1.2   0:06.01 php5-fpm
11249 www-data  20   0  319m 4908  544 D    0  1.0   0:05.94 php5-fpm
14825 www-data  20   0  305m 6368  648 D    0  1.3   0:05.69 php5-fpm
11246 www-data  20   0  313m 3984   40 D    0  0.8   0:05.11 php5-fpm
14812 www-data  20   0  307m 4084   20 D   10  0.8   0:05.08 php5-fpm
 3274 bind      20   0  213m    0    0 S    0  0.0   0:04.70 named
14827 www-data  20   0  305m 7000  604 D    0  1.4   0:04.62 php5-fpm
14832 www-data  20   0  307m 3768  100 D    0  0.8   0:04.50 php5-fpm
14872 www-data  20   0  295m 6124  756 D    0  1.2   0:04.45 php5-fpm
  845 root      20   0     0    0    0 S    0  0.0   0:04.21 kworker/3:1
14769 www-data  20   0  309m 9472   16 D   10  1.9   0:03.71 php5-fpm
14755 www-data  20   0  307m 4056   20 D    0  0.8   0:03.53 php5-fpm
14823 www-data  20   0  307m 4256   36 D    0  0.9   0:03.47 php5-fpm
14833 www-data  20   0  307m 4764  688 D    0  1.0   0:03.29 php5-fpm
14818 www-data  20   0  307m 4628   36 D    0  0.9   0:03.17 php5-fpm
14884 www-data  20   0  267m  11m  692 D    0  2.4   0:03.03 php5-fpm
14697 www-data  20   0 30840  540  312 S    0  0.1   0:02.59 nginx
14936 www-data  20   0  276m 8420  572 D    0  1.7   0:02.34 php5-fpm
14696 www-data  20   0 30868  228    0 S    0  0.0   0:02.29 nginx
14820 www-data  20   0  307m 4728   36 D    0  0.9   0:02.02 php5-fpm
14882 www-data  20   0  276m   9m  628 D    0  2.1   0:02.00 php5-fpm
14815 www-data  20   0  306m 4300   44 D    0  0.9   0:01.92 php5-fpm
14693 www-data  20   0 30736  416  188 S    0  0.1   0:01.63 nginx
14698 root      20   0 19268  504  180 R    0  0.1   0:01.62 top
15143 www-data  20   0  257m 4524  176 S    0  0.9   0:01.60 php5-fpm
14695 www-data  20   0 30872  648  372 S    0  0.1   0:01.59 nginx
15149 root      20   0 33712  920  408 S    0  0.2   0:01.52 mysql
14694 www-data  20   0 30840  360  108 S    0  0.1   0:01.28 nginx
14883 www-data  20   0  263m 6332  652 D    0  1.3   0:01.27 php5-fpm
11236 root      20   0  253m  304  172 S    0  0.1   0:01.25 php5-fpm
14935 www-data  20   0  276m 8500  272 D    0  1.7   0:01.09 php5-fpm
14939 www-data  20   0  257m 2968  108 S    0  0.6   0:01.07 php5-fpm
14934 www-data  20   0  276m 7996  612 D    0  1.6   0:00.97 php5-fpm
  788 root      20   0     0    0    0 S    0  0.0   0:00.91 kworker/2:1
share|improve this question

2 Answers 2

Depending on how you have configured php5-fpm, you need to look at the max_children setting.

share|improve this answer
    
This is my /etc/php5/fpm/pool.d/www.conf: pastebin.com/YWfBve32 /////// and here is my /etc/nginx/nginx.conf: pastebin.com/ttgjQe34 ////// The website is at casamento10.com ///////// As you can see above, I've made some changes but now the site is not even loading. HALP! –  Marcio Matielo Aug 5 '11 at 17:19

Pay attention to S column, you will see that almost of them are in "D" state (uninterruptible sleep). Are there any special in the nginx log?

share|improve this answer
    
Can I filter the only active processes? See only those that are actually consuming any memory and are not at a sleep state? –  Marcio Matielo Aug 5 '11 at 17:30
    
Notice that this is D - uninterruptible sleep, it is different from S - interruptible sleep. You can filter all the running or runable processes with ps -eo pid,user,state,comm | awk '$4 == "php5-fpm" && $3 == "R" { print $0 }'. –  quanta Aug 5 '11 at 17:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.