Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will a Multi-Core / Multi-Proc help performance on a web server?

Does NGINX or Apache benefit from a server that has either:

  • Multi-cores, or

  • Multiple processors?

If so, why?

like image 434
nickb Avatar asked Jun 24 '26 21:06

nickb


1 Answers

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):

  1. using several processes;

  2. using several threads in a single process;

  3. 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).

like image 149
Franklin Avatar answered Jun 27 '26 10:06

Franklin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!