Spawn workers to use up nearly all available CPU

Greendrake

Say I have a CLI app that I want to do some work (e.g. process some media files). When I run one instance of the app it takes say 20% CPU. The rest 80% is idle.

I want some sort of process manager that will run as many app instances as it takes to use nearly all the CPU up. The app knows what to do and how not to interfere with its siblings, but it can't spawn/manage itself.

Is there any manager like that? I've been using supervisor to run fixed sets of different apps one instance each, but I don't know if it can be used to run variable amount of instances of the same app depending on CPU availability.

thrig

For maximum overkill there is software such as HTCondor though such frameworks typically have a high setup cost and longer learning curve than your case may need.

A simpler but less flexible solution would be to write a small script that checks the current CPU load and from that decides whether to wait for a process to exit or to spawn one or more jobs (and then to wait for a process to exit). This sort of script is probably where things like HTCondor evolved from.

Even simpler might be to have a Makefile and then use make -j 4 ... where one knows that each "job" takes up 20% - 25% of the CPU. This assumes you know how much CPU the jobs take up, and that you know the jobs and can list them all in a Makefile. So not very flexible, unless you maybe generate the Makefile from a jobs list.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Tell Sidekiq to use all available Heroku workers

Optimizing Keras to use all available CPU resources

Steam game does not use all available CPU power

How to know when all cluster workers are up?

Julia parallel programming - Making existing function available to all workers

Number of threads Workers in NodeJS will spawn

Julia is not using all of the available CPU threads

Ejabberd is using all available CPU, how to debug

Possibility to NOT hook all available CPU power?

Tomcat spiking and consuming all available CPU

Finder Using Nearly 100% CPU

How can I speed up C program in terminal (use all of CPU speed)

How to use all available memory

How to use all voices available?

Vbox not filling up all of the available space in a gridpane

What is the best approach to make all the imports with in the service available across all dask workers?

Performing grid search on sklearn.naive_bayes.MultinomialNB on multi-core machine doesn’t use all the available CPU resources

ImageCaptureService using up all my CPU resources

Python is taking up all of my CPU!

Dask does not use all workers and behaves differently with different number of nodes

Dataflow workers are not spinning up

Linux - system call not using all available CPU resources

multiprocessing with HF's transformers uses all CPU cores despite being limited num_workers

How to force tensorflow to use all available GPUs?

Java does not use all available CPUs

Ffmpeg subtitle use all available frame

Does my system use all available RAM?

How can I set up a default powershell profile for all my co workers at work as simple as possible?

Kill all "workers" on "listener" error (multiprocessing, manager and queue set-up)