Jump to content

Docker "Nice" or CPU limit options


dtempleton

Recommended Posts

This is a different Q separate from my last message.

 

I have installed Sparkly's HandBrake Docker just to use the HandBrakeCLI interface to convert files placed in a watched folder.

 

I set up the watched folder and the folder monitoring script and then used docker commit to formalize the change in the image. 

 

This is working well, but while the docker is running handbrake, all of the CPU for the server is consumed by the conversion process.  I would prefer if it could be throttled back to 50 or 75% to leave time for other server activities.

 

I thought first about Nice, but in my reading, running Nice within a Docker restricts the processes *within* the docker, which would result in the docker as a whole running as much CPU as it wants, no different from now.  I believe that it is not possible to run Nice on the docker container itself, or am I wrong there?  Is that what --cap-add SYS_NICE is all about? (Manual says 'Raise process nice value (nice(2), setpriority(2)) and change the nice value for arbitrary processes.' but not sure what arbitrary processes means here.)

 

I've also seen the option to launch the docker with a CPU restriction, i.e.

docker run --cpuset="0" ...

  but Nice would be... nice. 

 

Also, if there is a special docker run command, is there a way to edit the default autostart or restart script?

 

I'd appreciate any advice you have.

 

Dennis

 

 

Link to comment

-cpuset is deprecated

You need to use -cpuset-cpus="0,1" and that would be the correct way to prevent one container from hogging all the resources

 

Thanks.  I had trouble at first because -cpuset-cpus works on docker run not docker start, for reasons I can't understand.  However using the docker run -cpuset-cpus="0,1" ... command the container installed and my cpu% is running between 60 and 80% with mover running, and handbrake is getting the job done too.

 

it would be great to have nice too.

 

Thanks

 

Dennis

 

Link to comment

Isn't CPU quota constraints doing the same thing as nice?

https://docs.docker.com/reference/run/#cpu-quota-constraint

 

I don't think it's the same.  The CPU quota throttles the usage (in their example " Set this value to 50000 to limit the container to 50% of a CPU resource.") rather than prioritizing processes.  My understanding of nice is that a process will burn 100% of all CPUs until there is a competing process with a higher priority, at which time the high-priority process runs and the nice process is slowed. When the high priority process is completed, the nice process goes back to being unthrottled.  Maybe I'm giving nice too much credit, but that's how I've always  understood it.

 

The --cpu-quota looks to be similar to the --cpuset-cpus suggested above that allocate one or a few cores to a process, it's just time managed instead of processor number managed.

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...