Forums

Multiprocessing

Looks like each console has access to only two CPUs:

from multiprocessing import cpu_count
cpu_count()
>> 2

Is there a way to access more than 2 CPUs for CPU intensive tasks? ..outside a webapp.

Alternatively, is there a way to launch multiple consoles via API or bash/python script.

Yes, that is correct. There are 2 CPUs on the machines that run consoles.

It's not possible to launch a console from an API.

Just my two cents: it would be nice to have access to more than two CPUs.

Glenn wasn't quite correct in what he said previously; our virtualisation system appears to be reporting the number of CPUs that were available at the time the system image you're using was created rather than the real CPU count on the machine where your code is running. We build system images on a two-core machine, but consoles actually run on a system with four cores. I believe that all systems where your code runs will have the same number, apart from always-on tasks, which do run on two-core machines.

OK, thanks. So if I have a program that uses multiprocessing, are you saying that program has access to 4 virtual cores and so it makes sense that I spawn 4 processes?

Yes, exactly.

Thank you. That is most helpful to know.

How to make them run faster even after have 4 processes ? Which plan will be the best for beautifulsoup to download html page faster ?

BeautifulSoup won't go any faster if you use multiprocessing -- it's single-threaded, so while you can run more simultaneous download/parse programs with more processes, each individual one will not run any faster.

if the always-on tasks run on 2 cores, how many cores do the scheduled tasks run on? And is there a way to get the always-on task to run on 4?

There is no guarantee about the number of available cores. Your tasks could be run on different machines with different specs.