Lighttpd es un webserver que nacio como un Proof of Concept de "The C10K problem": "It's time for web servers to handle ten thousand clients simultaneously".
Tres años despues, Lighttpd es un webserver estable, rapido e increiblemente flexible; lo que lo hace una opcion ideal para servir aplicaciones web hechas a medida.
1. Apache ha muerto Viva LIGHTTPD! [email_address] * No creo realmente que el Apache haya muerto, pero si que ahora hay mas opciones, algunas mucho mas interesantes, como Lighty. El titulo de la presentacion es para provocar, nomas.
15. Distribuyendo la carga $HTTP["url"] =~ "php$" { proxy-core.protocol = "fastcgi" proxy-core.backends = ( "10.0.0.1:1000" ) } else $HTTP["url"] =~ "^/images/[0-4]/" { proxy-core.protocol = "http" proxy-core.backends = ( "10.0.0.2:80" ) } else $HTTP["url"] =~ "^/images/[5-9]/" { proxy-core.protocol = "http" proxy-core.backends = ( "10.0.0.3:80" ) } The web is a pipe!
16.
17.
18.
19.
20. Un archivo al azar En PHP, PHP+X-Sendfile y LUA <?php header("Content-Type: image/png"); print file_get_contents("imgs/".rand(0,9).".png"); <?php header("Content-Type: image/png"); header("X-Sendfile: ".getcwd(). "/imgs/".rand(0,9).".png"); lighty.env["request.uri"]="/imgs/" .. math.random(9) .. ".png" return lighty.RESTART_REQUEST
21.
22.
23. magnet: cache html Guardar el output HTML en el archivo temporal: <?php function cache_html(){ function write_html($text){ $info = stat($_SERVER["SCRIPT_FILENAME"]); file_put_contents("/tmp/".$info['ino'].".html",$text); return false; } ob_start("write_html"); }
24. magnet: cache html Devolver el contenido del archivo temporal si existe y terminar la ejecucion (PHP): <?php function show_cached(){ $info = stat($_SERVER["SCRIPT_FILENAME"]); $cache_file = "/tmp/".$info['ino'].".html"; if (file_exists($cache_file)){ print file_get_contents($cache_file); exit; } }
25. magnet: cache html Devolver el contenido del archivo temporal si existe y terminar la ejecucion (LUA): info = lighty.stat(lighty.env["physical.path"]) cache_path = "/tmp/"..info["st_ino"]..".html" cache_info = lighty.stat(cache_path) if (cache_info) then lighty.env["physical.path"] = cache_path end