简体   繁体   English

限制* nix进程的CPU和内存

[英]Limit CPU & Memory for *nix Process

Is it possible to limit CPU & Memory for the *nix Process? 是否可以限制* nix进程的CPU和内存?

The CPU limit may look like "use no more than 10% of one core". CPU限制可能看起来像“使用不超过一个核心的10%”。

The memory limit may look like "use no more than 100Mb", the OS may limit it or kill the process if it try to exceed the limit, both ways are fine. 内存限制可能看起来像“使用不超过100Mb”,操作系统可能限制它或者如果它试图超过限制则终止进程,两种方式都可以。

Any *nix that could do that would be fine. 任何可以做到这一点的* nix都没问题。

It seems it is possible to implement it with virtual machines, but it is not acceptable because the overhead is too huge. 似乎可以用虚拟机来实现它,但这是不可接受的,因为开销太大了。

If you happen to use Solaris, the ability to limit resource usage is a native feature. 如果您碰巧使用Solaris,则限制资源使用的能力是本机功能。

Memory (RAM) usage can be capped per process using the rcap.max-rss setting while CPU usage can be limited per project using the project.cpu-caps . 使用rcap.max-rss设置可以限制每个进程的内存(RAM)使用率,而使用project.cpu-caps可以限制每个项目的 CPU使用率。

Note that Solaris also allows OS level virtualization (aka zones) which have no significant overhead, if any, compared to a bare metal OS instance. 请注意,Solaris还允许操作系统级虚拟化(也称为区域),与裸机OS实例相比,它没有显着的开销(如果有的话)。

Resource capping is part of Solaris zones configuration. 资源上限是Solaris区域配置的一部分。

Try CPULimit 试试CPULimit

cpulimit is a simple program which attempts to limit the cpu usage of a process (expressed in percentage, not in cpu time). cpulimit是一个简单的程序,它试图限制进程的CPU使用率(以百分比表示,而不是以cpu时间表示)。 This is useful to control batch jobs, when you don't want them to eat too much cpu. 这对于控制批处理作业很有用,当你不希望它们吃太多的cpu时。 It does not act on the nice value or other scheduling priority stuff, but on the real cpu usage. 它不会对nice值或其他调度优先级的东西起作用,而是对真正的cpu使用情况起作用。 Also, it is able to adapt itself to the overall system load, dynamically and quickly. 此外,它能够动态,快速地适应整个系统负载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM