is it useful to server static data using Nginx(Images,css,js) and dynamic data (App code+database) using Apache ?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
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.
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.
It is useful. Some benchmarks have shown nginx to be at least twice as fast as Apache at static content.
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.
good comparison, check here - http://wiki.dreamhost.com/Web_Server_Performance_Comparison