Deprioritising Tasks


Skatman

Recommended Posts

Hi all, 

 

Having some issues with Plex using up all the CPU when new media is added. I currently have it set to analyse media, download the metadata, and generate video thumbnails when new stuff is added/detected. 

 

Appreciate that I can solve this issue quickly by changing the settings and running them as scheduled tasks outside of regular 'working' hours, but I was also wondering if there was a way that I can change the CPU priority to certain tasks/processes or limit them to a maximum % of CPU? 

 

Best, 

Link to comment
5 hours ago, Squid said:

Depends upon what you're trying to prioritize over another, but this is a start https://forums.unraid.net/topic/57181-docker-faq/page/2/?tab=comments#comment-566087

 

Oh this is awesome. Thanks. I actually wanted to do this anyway with some of my other dockers.

 

But in this instance I was more taking about a specific process that happens *within* a docker. My assumption is that UnRAID can't do anything about that as it'll just see the Plex docker asking for resources, rather than the individual process within the Plex docker. Could be wrong though, just wanted some clarification. 

Link to comment
8 hours ago, Squid said:

Depends upon what you're trying to prioritize over another, but this is a start https://forums.unraid.net/topic/57181-docker-faq/page/2/?tab=comments#comment-566087

 

Hey @Squid,

 

Just trying to enter the parameters for docker priority as defined and I'm a bit confused on a number of parts:

 

  1. Where do I actually enter the "-c" or "--cpu-shares" flag? Is it in the docker/UnRAID console? Or do I add a variable? If I have to type it into the UnRAID console, how does it know which docker I'm referring to?
  2. What command do I type in and where do I type it to generate this output? I presume the UnRAID console?
    PID    container    CPU CPU share
    100    {C0}     0   100% of CPU0
    101    {C1}     1   100% of CPU1
    102    {C1}     2   100% of CPU2
  3. I understand that a value of '1' has double the priority of '2', which equates to 1024 and 512 respectively. But what should I use with the "-c" or "--cpu-shares" flag? The single digit (1, 2, etc) or the bit-offset (1024, 512, etc)?
  4. Is there any way to prioritise the 'system' over dockers? One thing I've noticed is that, when trying to access the Docker tab when Plex is using all of the CPU, it just hangs until it becomes less busy. Can I set the "system" as a higher priority so that I always have control?

 

Link to comment
1 minute ago, Squid said:

extra parameters in the template

@Squid I had it on Basic View and Extra Parameters wouldn't show. *facepalm*.

 

Is there a difference between using the "c" flag or the "--cpu-shares" flag? Presume I have to type the single digit with the "c" flag and the bit-offset with the "--cpu-shares" flag?

 

Anything on the last question? My idea was to try and implement the following priority:

  1. System
  2. UUD dockers (when I get around to implementing it)
  3. Plex
  4. My other Dockers

Just not sure if this is possible? Can you go down to 4? Again, I'm presuming you can go down to 10 given the mapping against bit-offsets?

Link to comment
7 minutes ago, Skatman said:

Is there a difference between using the "c" flag or the "--cpu-shares" flag?

You're 11 times more likely to break a nail when typing the latter.  Other than that, they're identical.  c is simply a shortcut for cpu-shares

 

To prioritize the OS over a container, you're best bet is to explore https://docs.docker.com/engine/reference/run/#cpu-share-constraint and below

 

You can set the priorities to anything you want.  Every container has a default setting of 1024.  The lower you go (down to 2), the lower the priority of the container is relative to other containers.  The higher you go (up to 2048) the higher the priority of the container is.  It's easiest to visualize it only considering 3 containers running on a single core CPU.

Quote

For example, consider three containers, one has a cpu-share of 1024 and two others have a cpu-share setting of 512. When processes in all three containers attempt to use 100% of CPU, the first container would receive 50% of the total CPU time. If you add a fourth container with a cpu-share of 1024, the first container only gets 33% of the CPU. The remaining containers receive 16.5%, 16.5% and 33% of the CPU.

 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.