0

i run a web site that hosts pages that are just general scripts (php, etc) and mp3 downloads (some of which are fairly large - up to 200mb). i am running lighttpd on the servers on linux (ubuntu 64). everything is fine, but under high load, the server is not accessible (or very slow - even sshing in takes a while), and i am guessing this is due to a huge number of mp3 downloads at that time. consequently, dns sees the server as down and redirects all the traffic to the other servers, and after a while, it comes back up and things work again.

so what's the best way to fix this? ideally, i want the server to continue running (and the web pages - php etc - to always work, but downloads don't always have to work). should i just have 2 web servers running (one for the downloads and one for the php pages), or is it perhaps something i can fix in my lighttpd configuration?

here are the snippets from my configuration:

server.max-worker = 4
server.max-fds = 2048
server.max-keep-alive-requests = 4
server.max-keep-alive-idle = 4
server.stat-cache-engine = "fam"

fastcgi.server    = ( ".php" => 
        ((
                "bin-path" => "/usr/bin/php-cgi",
                "socket" => "/tmp/php.socket",
                "max-procs" => 1,
                "idle-timeout" => 20,
                "bin-environment" => ( 
                        "PHP_FCGI_CHILDREN" => "64",
                        "PHP_FCGI_MAX_REQUESTS" => "1000"
                ),
                "bin-copy-environment" => (
                        "PATH", "SHELL", "USER"
                ),
                "broken-scriptfilename" => "enable"
        ))
)

# normal php site
$HTTP["host"] =~ "bar.com" {
    server.document-root = "/usr/local/www/sites/bar.com/"
    accesslog.filename = "|/usr/sbin/cronolog /var/log/lighttpd/%m/%d/%H/bar.log"
}

# download site
$HTTP["host"] =~ "(download|stream).foo.com" {
   server.document-root = "/home/audio/"
   dir-listing.activate = "enable"
   dir-listing.hide-dotfiles = "enable"
   evasive.max-conns-per-ip = 1
   evasive.silent = "enable"
#   connection.kbytes-per-second = 256
   accesslog.filename = "|/usr/sbin/cronolog /var/log/lighttpd/%m/%d/%H/download.log"
}

1 Answer 1

0

Few things:

  1. Adjust your maximum write idle.

  2. Don't run FCGI/PHP on the server serving static content, it will slow you down and append garbage session data everywhere.

  3. Disable any sort of error/access logging.

  4. Add caching entries: setenv.add-response-header = ( "Cache-Control" => "public, max-age=86400" )

  5. Use mod_expire: expire.url = ("/mp3s/" => "access 2 years")

    Don't use connection.kbytes-per-second, it's a bit flaky. I would use OS/hardware level firewall for this.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .