Resource limits are enforceable ceilings that an operating system or runtime places on how much CPU time, memory, disk I/O, processes and open files a process, user, service or container may consume. In the management of server resources, they turn a shared machine into a set of predictable allocations, so that one workload cannot starve every other workload on the same host.
Limits are the counterpart of capacity planning: planning decides how much a server has, while limits decide who may use how much of it. They protect stability, enforce hosting plans and contain faults such as memory leaks or runaway loops before they become outages.
How resource limits are enforced
On Linux, resource limits are enforced by two main kernel mechanisms. The older rlimit interface, set with setrlimit and the shell command ulimit, applies per-process limits such as the maximum number of open file descriptors, the stack size or the number of processes a user may own.
The newer mechanism is control groups, usually called cgroups, which group processes and apply limits to the whole group. With cgroups v2, the unified hierarchy used by modern distributions, controllers such as memory.max, cpu.max, io.max and pids.max govern an entire service or container rather than a single process.
Higher-level tools sit on top of these primitives. systemd exposes cgroup settings as unit directives, container runtimes translate flags such as memory and CPU options into cgroup values, and Kubernetes converts requests and limits in a pod specification into the same kernel controls.
| Layer | Example interface | Scope of the limit |
|---|---|---|
| rlimit | ulimit -n, /etc/security/limits.conf | Single process or user session |
| cgroups v2 | memory.max, cpu.max, pids.max | Group of processes |
| systemd units | MemoryMax, CPUQuota, TasksMax | One service and its children |
| Containers | Docker memory and CPU flags | One container |
| Orchestrators | Kubernetes requests and limits | Pod or container in a cluster |
Types of resource limits and what happens at the ceiling
Each resource type reacts differently when its limit is reached, and this behavior determines how an application fails. CPU limits throttle a workload and make it slower, whereas memory limits terminate processes or force reclaim, which is far more disruptive.
The table below summarizes the main limit types, the usual unit and the typical consequence of hitting the ceiling.
| Resource | Typical unit | Effect when exceeded |
|---|---|---|
| CPU | Quota per period, for example 50 ms per 100 ms | Throttling and higher latency |
| Memory | Bytes, for example 2 GiB | Reclaim, then OOM kill |
| Disk I/O | IOPS or bytes per second | Requests queue and I/O wait rises |
| Processes | Number of tasks | fork fails with EAGAIN |
| Open files | Number of descriptors | Calls fail with EMFILE |
| Disk space | Bytes or inodes via quotas | Writes fail with EDQUOT |
Many limits distinguish a soft limit from a hard limit. With rlimits, a process may raise its soft limit up to the hard limit but cannot exceed the hard limit without privileges. In cgroups v2, memory.high acts as a throttling threshold that slows allocation, while memory.max is the absolute ceiling that triggers the out-of-memory killer.
Resource limits compared with related concepts
Resource limits are often confused with neighboring ideas such as reservations, quotas and scheduling weights. The distinction matters because a limit is a ceiling, not a guarantee, and a server with generous limits can still be overloaded.
| Concept | What it controls | Guarantee or ceiling |
|---|---|---|
| Limit | Maximum consumption | Ceiling |
| Request or reservation | Capacity set aside for scheduling | Guarantee |
| CPU weight or shares | Relative priority under contention | Proportional share |
| Disk quota | Storage per user or project | Ceiling |
| Memory overcommit | Total promised versus physical memory | Neither, a policy |
Limits also interact with symptoms tracked elsewhere in server monitoring. A container that reaches its CPU quota shows CPU throttling even when the host has idle cores, and a virtual machine that loses time to other tenants shows CPU steal time, which no limit inside the guest can fix. Limits are the main defense against the noisy neighbor problem on shared hosts.
Setting resource limits in practice
Good limits are based on measured peak usage plus headroom, not on guesses. A common approach is to observe a workload under realistic load, take the 95th or 99th percentile of usage and add a margin of roughly 20 to 50 percent, depending on how bursty the workload is.
The following decision table shows typical situations and the limit strategy that usually suits them.
| Situation | Recommended approach | Reason |
|---|---|---|
| Shared web hosting | Per-account CPU, memory and process caps | Keeps one site from slowing others |
| Database server | Generous memory limit, no tight CPU quota | Throttling hurts query latency |
| Batch jobs | Low CPU weight, firm memory limit | Yields to interactive work |
| High-connection proxy | Raised open file limit | Each connection uses a descriptor |
| Latency-sensitive API | Requests equal to limits | Avoids throttling and eviction |
Configuration should live in version-controlled files, such as systemd drop-ins or container manifests, rather than in interactive shell sessions. A ulimit typed in a terminal affects only that session and disappears at the next login or service restart.
Common mistakes and failure modes
Most problems with resource limits come from limits that are too tight, too loose or applied at the wrong layer. Typical errors include:
- Setting CPU limits too low for multithreaded applications, which causes heavy throttling during short bursts even when average usage looks modest.
- Sizing memory limits to average usage, so that normal peaks trigger out-of-memory kills.
- Editing limits.conf for a systemd service, which has no effect because systemd applies its own
LimitNOFILEand related directives. - Ignoring runtime awareness, for example a Java or Node.js process that sizes its heap from host memory instead of the container limit.
- Relying on limits instead of monitoring, so that silent throttling is never noticed.
Limits should therefore be paired with alerting on throttling counters, OOM events and limit utilization, so that operators adjust ceilings before users notice degraded performance.
The idea in brief
Resource limits work like portion sizes at a shared table. A server has a fixed amount of processing power, memory and storage, and many programs or customers want a share of it. Limits say how much each one may take.
If a program tries to take more, the system either slows it down or stops it. That may sound strict, but it protects everyone else on the same machine. The key point is that limits keep one misbehaving program from ruining the experience for all the others.
A practical scenario
A hosting provider runs about 200 small business websites on one server with 16 CPU cores and 64 GB of memory. One night, a poorly written plugin on a single site enters a loop and starts spawning PHP processes, each consuming memory.
Because the provider assigns every account a limit of one CPU core, 1 GB of memory and 40 processes, the runaway site hits its process ceiling within seconds. New requests to that site fail with errors, but the kernel never touches the memory of the other accounts, and the monitoring system raises an alert about repeated limit hits.
The administrator identifies the faulty plugin the next morning and disables it. The other 199 websites stayed fast throughout the incident, and nobody outside the affected account noticed any slowdown.