TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Restricting process CPU usage using nice, cpulimit, and cgroups

29 pointsby itsderek23over 10 years ago

4 comments

Arnavionover 10 years ago
&gt;This is because when a single process is running, it uses as much CPU as necessary, regardless of which cgroup it is placed in. The CPU limitation only comes into effect when two or more processes compete for CPU resources.<p>So doesn&#x27;t this mean cgroups can&#x27;t be used in the same way as cpulimit? cpulimit lets me limit the total max CPU usage of a process regardless of the rest of the system. The article makes it look like cgroups only allows setting the _partitioning of CPU_, not _total allowed CPU_.<p>Edit: Looks like the way to do it is to use cpu.cfs_period_us and cpu.cfs_quota_us instead of cpu.shares<p><a href="https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Resource_Management_Guide/sec-cpu.html" rel="nofollow">https:&#x2F;&#x2F;access.redhat.com&#x2F;documentation&#x2F;en-US&#x2F;Red_Hat_Enterp...</a>
评论 #8558934 未加载
arsover 10 years ago
I&#x27;ve used cpulimit to force slow down flash games but it causes them to crash randomly.<p>I&#x27;m hoping cgroups can do better.
kr0over 10 years ago
I think &#x27;nice&#x27; and &#x27;cpulimit&#x27; should change names
评论 #8559133 未加载
vezzy-fnordover 10 years ago
Isn&#x27;t writing to the cgroupfs yourself no longer recommended? Instead you should send requests to your system&#x27;s privileged cgroup writer (whether it be cgmanager, systemd or something else)? Or am I wrong?<p>That said, I&#x27;m pretty sure that niceness is mostly just a suggestion to the kernel. The scheduler&#x27;s heuristics have the final say.
评论 #8558939 未加载