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.

My server is a Linode 512, and on it I run a Wordpress MU with 3 websites (they don't get a lot of visitors) and a couple of NodeJS apps.

I need to switch to Lighttpd because Apache 2 was using about 59% of the server's RAM, and now I have the php-cgi processes taking up about 43.6% of the server's RAM:

  • most often 2 processes use 16.5% of the RAM each,
  • 4 processes use 1.8% of the RAM each, and
  • 4 more processes use 0,8% of the RAM, each

How can I have less of these processes ? I'm almost sure they're not all needed for the trafic this server gets...

I tried only allowing 2 children, but I still have those 10... This is my fastcgi.server section in lighttpd.conf.

fastcgi.server = ( ".php" =>
                    ( "localhost" =>
                      (
                        "socket" => "/var/run/lighttpd/php-fastcgi.socket",
                        "bin-path" => "/usr/bin/php-cgi",
                        "bin-environment" => (
                          "PHP_FCGI_CHILDREN" => "2",
                          "PHP_FCGI_MAX_REQUESTS" => "4000"
                         )
                      )
                    )
                  )

What else can I do to tune lighttpd to use less RAM ?

share|improve this question
    
Simple, don't run Wordpress, it uses lots of memory. –  Zoredache Feb 10 '12 at 22:37
    
The solution to most tech problems is "be less poor." –  Joel E Salas Feb 10 '12 at 22:39
    
Yep, having a Linode 4096 would solve every problem I have... But I'm so poor that I share this linode 512 with another guy that needs that wordpress installation so none of that is a possible solution lol... –  João Pinto Jerónimo Feb 10 '12 at 22:42
    
@Zoredache sure, that is a simple solution, when you don't know what you are doing. using Apache2, and FasCGId, with proper configuration (meaning RTFM, and Trial & Error) it is easily possible to run a few hundred word-press sites on one machine. memory usage is factored by cache, configuration, extensions, plugins, and more. it has little to do with what CMS you run. he clearly expressed his issue: he was having trouble lowering the amount of children in the worker pool. –  RapidWebs Jul 5 at 2:27
    
@joel E Salas: be less poor is an incredibly poor comment. how about, learn how to use the software as it was intended? or give a reasonable answer? fastcgid can easily be configured to use the very little memory per website, while being scalable. this was its intention. and that is, better management of worker pools and processes. you can't fix everything by throwing money, or RAM at it. the problem will STILL persist. –  RapidWebs Jul 5 at 2:29
add comment

2 Answers

up vote 3 down vote accepted

If you set bin-path then lighttpd is responsible for spawning fcgi processes, limited by:

"max-procs" => <integer>,             # optional - when omitted, default is 4

Environment variable PHP_FCGI_CHILDREN is an additional hint to php executable to internally spawn more processes, you can set it to zero.

You don't specify max-procs so there is 4 procs spawned by lighty and each of them has two additional childrens -- 4[max-procs] * (1+2[PHP_FCGI_CHILDREN]).

share|improve this answer
    
Thanks :) I now have only 1 php-cgi process and the whole thing is taking about 19.4% of the RAM and is taking 200 concurrent connections quite well! –  João Pinto Jerónimo Feb 11 '12 at 1:07
add comment

Check out the lighttpd documentation regarding php-cgi. It seems that you may need to set the max-procs directive to limit the total number of children processes.

share|improve this answer
add comment

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.