简体   繁体   中英

Nginx and Apache

使用Apache使用Nginx(图像,css,js)和动态数据(应用程序代码+数据库)服务静态数据是否有用?

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.

It is useful. Some benchmarks have shown nginx to be at least twice as fast as Apache at static content.

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'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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM