0

Is there a hard limit we can set on Debian and RPM packages? My thought is to put 20% CPU, 20% Memory and 200 MB Disk Usage hard limits. So the package can play within those limits and not beyond that.

On Googling I found bind and pam.limits can be used. Has anyone used this before? Are there any better approaches?

HBruijn
  • 77,029
  • 24
  • 135
  • 201
Mir Adnan
  • 105
  • 3

1 Answers1

2

The package is just a container so it is unlikely to set a limit on that.

If your package installs a service, the best way to impose limits on services nowadays I think is to leverage the fact that systemd gives you easy access to cgroups ; control groups where you can set a number of resource limits.

For a service "foo" with set resource limits either in the unit file of foo.service itself or create for instance a foo.slice and set options such as:

CPUAccounting=true
CPUQuota=20%
MemoryAccounting=true
MemoryMax=bytes
HBruijn
  • 77,029
  • 24
  • 135
  • 201