Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Dynamic cpulimit based on load average
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Dynamic cpulimit based on load average

mhubudmhubud Member

What’s a program I can use/run within an ovz container that will dynamically alter the cpulimit of a process within the container based on the overall load average of the node?

Example: I’m in a container and run cpulimit on a process to ensure it only runs at 100% (of a 4 cpu) but most of the time the node load avg (reported by top) is around 1.5, so I could be taking advantage of more cycles but I only want to do so when the the load avg is low. There’s essentially only one process of note running in the container, so “nice” wouldn’t really factor in. Any suggestions? Doesn't need to use "cpulimit" if there's a different method. Thanks!

Comments

  • Run your heavy processes inside its own OVZ container, then put less cpuweight on that container.

  • Clarifying: I'm the vps client, no access to the manage the node/other containers.

  • I guess it would be a nightmare for providers to have users control load average from any container

  • exception0x876exception0x876 Member, Host Rep, LIR

    maybe I'm missing something, but how do you plan to check load average of the host node if you have an access to container only?

  • rds100rds100 Member
    edited April 2016

    What is this process doing? Do you have the source code? Does it need to stay responsive or can it be paused?

    If it's some computation (mining / whatever) and you have the source you could implement some checks inside - check load average ; if it's below threshold do a computational cycle, otherwise sleep 1 second

    Alternatively you can do an external program do this loop - check load average, if it's above threshold send SIGSTOP to the miner, otherwise send SIGCONT. However this is a kludge, there must be a more elegant solution to this, maybe something using cgroups.

  • ffmpeg. Not a lot, but am converting some things to be more html5 happy (mp4/aac). Trying to do slowly and nicely, but also not take an eternity.

    I had read on cgroups but again, it's only one process. I'll do more reading on it tho. I was hoping to avoid writing a prog, but if I need to. But I can't believe this hasn't already been done in a cleaner way.

    Regarding checking load average, well can we just say the 4cpu is the "pool" available&shared for this exercise. To my understanding, what's reported in top (within the container) is the shared load average (so not necessarily technically the node, but it's the load average I want to play nice with).

  • Checking load average by a program is easy - cat /proc/loadavg and you will figure out how to parse it.

  • exception0x876exception0x876 Member, Host Rep, LIR

    @mhubud said:
    To my understanding, what's reported in top (within the container) is the shared load average (so not necessarily technically the node, but it's the load average I want to play nice with).

    To my understanding it is the load average of your container. I think you should just set static cpulimit for your ffmpeg process.

Sign In or Register to comment.