webkul
webkul

Reputation: 2864

Nginx and Apache

is it useful to server static data using Nginx(Images,css,js) and dynamic data (App code+database) using Apache ?

Upvotes: 6

Views: 2633

Answers (5)

cliff.wells
cliff.wells

Reputation: 745

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.

Upvotes: 6

shahinam
shahinam

Reputation: 680

good comparison, check here - http://wiki.dreamhost.com/Web_Server_Performance_Comparison

Upvotes: -1

Gregory Sitnin
Gregory Sitnin

Reputation: 693

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.

Upvotes: 0

pst
pst

Reputation: 1404

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.

Upvotes: 1

Glen Solsberry
Glen Solsberry

Reputation: 12320

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

Upvotes: 3

Related Questions