Search code examples
vagrantmultiprocessingtornadosupervisord

Supervisor : Why am I able to run more than 4 processes on a 4 core machine?


I'm working on a 4 core machine and using a vagrant box to host my application. I've configured Supervisor to spawn 5 processes on different ports and I can easily run all the processes independently. Does this mean that each processes spawned by Supervisor does not adhere to an individual core ?


Solution

  • Running processes is the OS job. It decides what to run and when to run it. The fact that you have 4 cores means that you can execute 4 different "codes" in parallel (4 different threads not necessarily from the same process)

    That means that if you put 4 processes on the same machine with 4 cores, chances are they will all run in parallel. If you have 5 processes than at any given moment, only 4 are running, but it will seem like they are all running in parallel, because they will do a "context switch", your cores will randomly stop running 1 process and switch to the other