Another benefit of having Lighttpd in front of Apache
I have read in a site that another benefit of having Lighttpd in front of Apache is lower number of child processes. Lighttpd will handle keep-alive and client requests while child processes of Apache gets to serve dynamic pages faster because of the very low latency communication between Lighttpd and Apache. I am trying to find the link but I am having a hard time.
Given that I already have a dedicated Lighttpd server for my static contents (img, vid, css, js, html, etc.) and another dedicated Apache server for my dynamic pages (php), I would like to implement this technique if it really has some performance gain.
1) Has anybody put a Lighttpd in front of Apache for the 开发者_如何学运维same purpose as explained above?
2) Is there really a performance gain on this? How much? 3) What about the overhead of Lighttpd handling down the request to Apache, is it really worth it?Thanks!
Lighttpd is great for a static CDN, coupled with Apache for the database-interactive scripts.
In general I have seen this technique be very good, however, instead of lighthttpd, I'd use another Apache instance (don't increase the amount of software on the box unnecessarily).
The gain that you get is largely to do with memory. If you use an Apache which is very "fat" e.g. uses mod_perl or PHP or some other memory-intensive module in prefork, then you have to set MaxClients very low to avoid blowing the RAM up.
On the other hand, MaxClients can then be reached with keep-alive requests, SSL handshakes, image downloads and other trivial activities, which are consuming lots and lots of ram needlessly.
A small "thin" server in front (which can be another Apache instance without mod_perl, PHP etc) can handle keepalives, images, SSL, redirects etc, and then let the main instance handle all the heavy stuff.
Moreover, you protect your main instance from abusive clients who send requests very slowly or not at all (I have seen this from non-abusive clients using XMLHttpRequest on old broken versions of IE).
It's a good approach, and if your servers are running out of memory because they have too many fat apaches, which are spending all their time doing nothing, it will definitely help.
精彩评论