Reputation: 9276
Does NGINX or Apache benefit from a server that has either:
Multi-cores, or
Multiple processors?
If so, why?
Upvotes: 3
Views: 8363
Reputation: 56
Using several CPUs/CPU-Cores gives server applications the opportunity to process several client connections (and requests) in parallel (achieving higher performance).
In a world of multi-Core CPUs, the question has been subject of extensive research.
There are 3 ways of addressing parallelism (like multi-Core CPUs):
using several processes;
using several threads in a single process;
using several threads in several processes.
Apache has explored several models, and Nginx is using option #1.
Which model performs better is generally considered as being a matter of implementation (at least under Unix where processes are very light so they can compete with threads).
Now, back to the question my guess (based on reading tests published here) would be that the proper (multi-thread) Apache architecture should scale better than Nginx on multi-Core CPUs.
Paradoxally, it does not mean that Apache is faster than Nginx: it just means that on 1, 2, 3, ... 16 Cores, Apache would scale better than Nginx WHILE Nginx would process more client requests:
Performance is to be fast (processing more requests per second on a single-Core CPU)
Scalability is the ability to process more requests per seconds as the number of CPU Cores grows (the ideal is to scale linearly: doubling the requests per second as you double the number of CPU Cores).
Scaling without performance is pointless if the number of requests per second of the server which scales is inferior to the speed of the server which does not scale (note that if the server REALLY scales well, there's a point where having MANY Cores should make it perform better than the server that does not scale).
Performing without scaling is making a server unable to take advantage of multi-Core CPUs.
The future will certainly be made of server applications which do both correctly, to provide the best performance under all conditions (just a few Cores or many-many Cores).
Upvotes: 4
Reputation: 2328
Only multi-threaded systems will benefit from multi-cores. I know Apache is multi-threaded and its performance does increase with multi-core. Typically performance goes up with multi-core if the work to be done is divided into small chunks of work which do not need to depend on each other. Apache starts processes to serve web requests and different requests can run concurrently on multiple cores, thereby improving performance. If NGINX is single-threaded, then it will not leverage multi-core.
Multi-core/multi-processor are the same thing in this context.
Upvotes: 0
Reputation: 40799
Yes.
I assume your question is whether one or the other is better?
In which case it's a fairly complicated question, but generally I'd expect that multiple processors will perform better.
Here's a good answer describing the architecture of both: nginx : Its Multithreaded but uses multiple processes?
Nginx fires up new processess for each client request, so although it's not multithreaded (good... avoids threading issues), the operating system can take advantage of multiple cores/cpu's by scheduling each process on a different cpu.
Upvotes: 0