Alex Craft
Alex Craft

Reputation: 15416

Limit CPU & Memory for *nix Process

Is it possible to limit CPU & Memory for the *nix Process?

The CPU limit may look like "use no more than 10% of one core".

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.

Any *nix that could do that would be fine.

It seems it is possible to implement it with virtual machines, but it is not acceptable because the overhead is too huge.

Upvotes: 1

Views: 951

Answers (2)

jlliagre
jlliagre

Reputation: 30873

If you happen to use Solaris, the ability to limit resource usage is a native feature.

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.

Note that Solaris also allows OS level virtualization (a.k.a. zones) which have no significant overhead, if any, compared to a bare metal OS instance.

Resource capping is part of Solaris zones configuration.

Upvotes: 2

Kedar Parikh
Kedar Parikh

Reputation: 1271

Try CPULimit

cpulimit is a simple program which attempts to limit the cpu usage of a process (expressed in percentage, not in cpu time). This is useful to control batch jobs, when you don't want them to eat too much cpu. It does not act on the nice value or other scheduling priority stuff, but on the real cpu usage. Also, it is able to adapt itself to the overall system load, dynamically and quickly.

Upvotes: 1

Related Questions