is it useful to server static data using Nginx(Images,css,js) and dynamic data (App code+database) using Apache ?
问题:
回答1:
Not only is it useful to have Nginx serve static images, but having Nginx proxy to Apache is a big win as well. This is because slow clients cause Apache to keep threads busy for longer than needed. Nginx can deal with the slow client and allow Apache to finish the request as fast as possible, freeing the thread (and memory) for other requests. Nginx will accept the request as fast as your local connection will allow, and trickle the response back to the slow client.
回答2:
It is useful. Some benchmarks have shown nginx to be at least twice as fast as Apache at static content.
回答3:
Depending on your application it can be. The idea is, that your application may consist of multiple static requests per page. If you can answer these with a small memory footprint Nginx you may end up needing less Apache workers which will probably have a higher memory footprint for the same amount of traffic.
回答4:
It's also useful because of keep-alive tearing.
Imagine browser's http request for a big dynamic ammount of data. Client's network connection is much slower than internal networking (most frequent case when nginx and apache on a same host, so they communicates via loopback interface). Apache uploaded all data to the nginx and it's worker is ready to serve the next request very fast while nginx sending that data to the client.
Because of nginx's speed and footprint it can handle much more connections simultaniously so this symbiosis works great.
回答5:
good comparison, check here - http://wiki.dreamhost.com/Web_Server_Performance_Comparison