yoink@tumblr ~ % date

27th October 2005

yoink@tumblr ~ % less 1130385600.txt

Playing nice with Lighttpd

So it looks like I’m still getting the hang of Lighttpd and FastCGI, but I’m not alone. Lots of folks are jumping on the lighty wagon either for Rails or whatever reason. There’s been a number of bumps along the way and that in turn has caused more than a few collective BUMPs on some TextDrive servers. Of course the fix is easy and pretty reasonable.

When setting up the number of FCGI processes for a little blog like this or a modest website (or maybe as a general rule) start small and upgrade when necessary. In the beginning, I just grabbed what seemed to be a decent config file (it was actually the recommended config for quite awhile). It seems like such overkill now. Anyway, here’s some config details

# for php4/5
  fastcgi.server = ( ".php" => ( "php-stuff" => (
     "socket" => "/path/to/fcgi/socket",
     "bin-path" => "/path/to/php5-fcgi",
      "max-procs" => 1,
       "bin-environment" => (
            "PHP_FCGI_CHILDREN" => "1",
            "PHP_FCGI_MAX_REQUESTS" => "2500"
        )
   ) ) )

# ... somewhere further down

# for rails
  fastcgi.server = ( ".fcgi" => ( "railsapp" => (
     "socket"   => "/path/to/fcgi/socket",
     "bin-path" => "/path/to/railsapp/public/dispatch.fcgi",
     "bin-environment" => ( "RAILS_ENV" => "production" ),
       "max-procs" => 1,
       "idle-timeout" => 90
    ) ) )

Basically the key is managing the “max-procs” to suit your needs. Start with 1 or 2 and only move up if you needed. Before I made the adjustment lighty used to spawn 10 php5-fcgi’s on startup, now I get 2 (I think that’s one for each php site setup). Test it out for yourself and be a good neighbor.

yoink@tumblr ~ % notes -v $post