Rafael Steil
Rafael Steil

Reputation: 4697

Why run many webservers instances per node?

I often see setups of (Rails | Java | PHP | Node.js | nginx | etc..) where there are many instances of the webserver software (nginx, apache, mongrel, it doesn't matter) running per server and serving the same application, instead of a single, "huge" instance.

Why would one choose such approach? It is not clear for me why many smaller instances serving the same application could be better than one instance tuned to use the max available ram and threads.

To make myself clear, I often see statements like "... we have 10 servers, running 20 instances of <some webserver> each". Why not "10 server, running 1 instance of <some webserver> each"?

Upvotes: 0

Views: 419

Answers (2)

Gil
Gil

Reputation: 3334

I would add to the excellent reply of Steve that an event-based multi-threaded servers combines the benefits of being able to process many requests per thread - while at the same time beeing able to use all the available CPU Cores of a system.

Besides CPU Cores, having one single program instance instead of many is saving memory (duplicated code and data) and CPU Caches from constant trashing.

Upvotes: 1

stewe
stewe

Reputation: 42642

Running multiple instances of a webserver only makes sense if it is single-threaded (like node.js or mongrel) to take advantage of multiple CPU cores.

Upvotes: 2

Related Questions