Barack Obama and Joe Biden: The Change We Need
 
Obama '08
art

geek

howto

music

politics

Home » geek, howto

HOWTO: determine optimal fastcgi settings for Lighttpd

Submitted by fak3r on Thursday, 28 February 2008No Comment

PHP Fast-cgiAnyone building a server with a LAMP stack today has tons of options, mine have evolved to using Varnish -> -> Xcache -> -> MySQL. Once I had Lighttpd (aka Lighty) installed and running pages I looked to optimize the configuration and push it as hard as possible for more speed. Of course lately I’ve been getting unexplained slowdowns, with many instances of -cgi appearing to be taking up almost all of my available CPU on `top`. Reading up on things it appears that I had , along with , set far too high for the load I’m getting. When you start it gives you the number of processes you’ve define, and then those in turn spawn the number of children you’ve specified. While my settings were too high, they were really overshooting things when you take into account that I’m using Xcache (which provides pre-caching) and Varnish (for HTTP acceleration). So even though one of my dynamic sites that I’m working on to ‘monetize’ things is getting 700-800 hits each day, my caching strategy is taking the load away from the ever available . Because of this, has much less to do, so giving it a ton of processes to just sit there and eat memory until they’re zombified is a waste. After reading the lighty FAQ and other posts specific to this, I’ve settled on the this for my fastcgi config block within my .conf file.

## Start an FastCGI server for  (needs the -cgi package)
fastcgi.server    = ( "." =>;
    ((
        "bin-path" =>; "/usr/bin/-cgi",
        "socket" =>; "/tmp/.socket",
        "max-procs" =>; 1,
        "idle-timeout" =>; 20,
        "bin-environment" =>; (
            "" =>; "2",
            "PHP_FCGI_MAX_REQUESTS" =>; "10000"
        ),
        "bin-copy-environment" =>; (
            "PATH", "SHELL", "USER"
        ),
        "broken-scriptfilename" =>; "enable"
    ))
)

Once I have this in place and running well for a few days I’ll shift over to MySQL and show how I have configured and optimized that for .

Related posts

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.