Container and CPU allocation

Hello all,

I’m trying to solve a problem with my Plex container, but it’s not exactly a Plex problem per se. I have way more details available in some Reddit posts I’ve made about this issue, but I don’t think they’re too relevant. Let me try to get to the heart of the matter. I’m running the latest Cobia version of TrueNAS Scale.

For reasons I don’t think are especially relevant, I’m trying to do some CPU transcoding in Plex, rather than hardware transcoding. What I’m finding is that despite trying to give a maximum of 20000m allocation of CPU to my Plex container (I have a 12700k with 20 threads, and I understand the max is 1000m * num_threads), I’m only able to use about 40% of my CPU in Plex. Plex ends up transcoding slower than the pace of the video, leading to constant buffering. The ‘speed’ param in the logs is about .8.

I am suspecting the issue is one of a few things:

  • There may be some global container configured CPU limitation, so the fraction I specify on the Plex container is a fraction of that overall max, rather than a fraction of the total CPU. If so, I’d love to change it, but I haven’t been able to find anything like this in the documentation or elsewhere.
  • Other containers may be holding onto a reservation for the CPU - even though the other containers allow me to specify a max CPU ceiling, they don’t allow me to control the floor. Maybe each container has a min CPU amount which it reserves, and that’s why it isn’t available to my Plex container?

I could test this by deleting the other containers but I’d prefer not to do that if I don’t need to. Any advice anyone can provide would be helpful. If you need the details behind my investigation, I can share the Reddit threads.


Probably not the solution you want to hear, but I had a similar issue with my Jellyfin install and was able to resolve by installing Jellyfin (which is like Plex) in a sandbox, which by default shared full host resources with the ffmpeg transcoder

In the jellyfin case, jellyfin is configured to not use 100% of the available resources by default too.

TrueNAS Scale: Setting up Sandboxes with Jailmaker


Interesting - so Jellyfin was CPU starved in a container, but when you put it into a sandbox, it was able to access the entirety of your CPU?

Do you happen to have any additional details, like the percentage of the CPU you were able to access when it was in a container? How many other containers were you running? I’m asking because I’m trying to determine if the issue is the container per se, or the other containers.

Thanks for the tip!

Interesting. I don’t follow the Alder Lake stuff, are CPU-Z cores working now in Scale?

For me, I have a custom app with Handbrake in it. I allocated 20000m, and, it used exactly that. So, I don’t think there’s an issue with the setting itself.

Were you running other containers? One possibility is that the other containers have reservations against part of the CPU, and that’s why my Plex container can’t allocate more of the CPU.

Regarding the 12700k, I’m unfamiliar with ‘cpu-z cores’. Are you referring to the performance vs. efficiency cores? I’m not an expert but I understood the current version of Cobia ran a kernel that knew how to manage Alder lake CPUs, but it is definitely possible that I’m wrong about this.

I have 21 containers. I don’t believe it’s an “allocation” at all, I believe it’s just a limit. I think the default is 4 threads IIRC. Yes, I was referring to efficiency cores, just had seen a bunch of messages about them not too long ago.

Interesting. Yes, I agree with you - if there were some minimum amount of CPU allocated per container, then you would have had the same issue, but even stronger.

The default is 4 threads - the container was originally configured with 4000m CPU. I noticed that I was able to increase it, but beyond about 6000m it didn’t seem to have any effect.

I think either a jail or a VM is going to be the way to go. Or, I’ll have to figure out if I can adjust the Kubernetes configs to allow me to push the CPU allocation in some way.

Hahaha I did some Googling and the 2nd result looked very promising, until I clicked and realized it was this post.

I am unable to find any direct answers as to what is going on. I did some more testing, and I found that the default CPU ceiling is 4000m. If I look at top while transcoding with the ceiling set to 4000m, I see the CPU utilization for the plex transcoder process sitting at about 400% CPU - that’s what I would expect.

However, if I try increasing the CPU allocation to the Plex container (say, 5000m, or 8000m, or all the way up to 20000m), then check ‘top’ again while transcoding, I see that the plex transcoder process is still using about 400% CPU.

It seems to me that something in the container is prohibiting me from going beyond the 4000m limit. I tried going under 4000m, and that is definitely working - I can see the transcoder process cap out at lower utilization. BUT - going beyond 4000m seems impossible, unless there is some other configuration i’m missing.

I don’t have a solution for this issue, but I did get some interesting feedback from the TrueCharts discord (even though I didn’t install Plex via TrueCharts).

They had me disable the iGPU passthrough and this “fixed” my issue. It allowed the CPU to ramp up and handle the transcoding with no buffering, and my CPU utlization was able to climb.

When the iGPU was re-added, I had the same issue - CPU utilization seemed capped at 40%, and the video would constantly buffer - 25 seconds of playback followed by about 10 seconds of buffering, and then repeat.

I’m not sure if this is an issue with Plex, or some chart configuration issue, but I think I’ll end up going the jail route to try to avoid this. Thanks to all who helped.

1 Like