How does Linux distribute load on multiple CPU cores

Solution 1:

A good answer to your question is much too complicated for SF. A short answer would be "yes", Linux and most modern OSes balance processes that are ready to run across available processors very efficiently.

There are techniques to modify how processes are allocated to resources, including changing schedulers are assigning processes to particular processors, but I wouldn't recommend using any of them without really understanding what they do or using them to solve a specific problem.

Also, both nginx and Apache httpd multithread/multiprocess by default. It would be very odd that they run as a single process. They don't poll network connections/flows, they use a kernel call to stop running when there's nothing to do and automatically wake up when there is something to do.

Solution 2:

Linux is primarily concerned with maximizing CPU utilization by load balancing the threads over all available cores. This dosen't mean to say that Linux arbitrarily decides to place certain threads on certain cores but it uses a process scheduling algorithm to decide what is the most efficient way to distribute the threads over all the cores. So the answer to your question is yes. If you would like to more I would suggest "Understanding the Linux Kernel" by Bovet & Cesati.