configuring lighttpd for large downloads
Posted
by
ahmedre
on Server Fault
See other posts from Server Fault
or by ahmedre
Published on 2011-06-20T15:36:44Z
Indexed on
2011/06/20
16:25 UTC
Read the original article
Hit count: 277
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"
}
© Server Fault or respective owner