Skip to content

Commit f16ec0c

Browse files
authored
docs: provide guidance for resource restrictions (#95)
1 parent 581d4fb commit f16ec0c

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

docs/GUIDE.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,45 @@ writable (`o+r`, `o+rw`) modes.
2121

2222
For more details about OpenShift’s Security Context Constraints (SCCs), refer to
2323
the [official documentation](https://docs.openshift.com/container-platform/latest/concepts/policy/security-context-constraints.html).
24+
25+
## Resource Limits
26+
27+
Setting appropriate resource limits is essential to ensure the container behaves reliably, securely, and within predictable boundaries. This aligns with [OWASP
28+
Docker Security Cheat Sheet – Rule #7](https://cheatsheetseries.owasp.org/cheatsheets/Docker_Security_Cheat_Sheet.html#rule-7-limit-resources-memory-cpu-file-descriptors-processes-restarts),
29+
which advises enforcing constraints on memory, CPU, file descriptors, and processes.
30+
31+
Container resource limits fall into two main categories:
32+
33+
### Process-Level Limits (`ulimit`)
34+
35+
These limits apply at process level inside the container and are enforced via the Linux `ulimit` mechanism (i.e., `RLIMIT_*`). The following values are
36+
recommended:
37+
38+
* `nofile` (maximum number of open files): `16384`
39+
* `nproc` (maximum number of processes): `4096`
40+
* `core` (core dump size): `0`
41+
42+
These settings are generous and suitable for most workloads. You may consider tightening them further based on actual usage, after proper testing and
43+
monitoring.
44+
45+
While a high `nproc` limit is typically safe, be aware that it can occasionally trigger unexpected
46+
behavior depending on the container runtime or host configuration. For further details, see
47+
the [Docker documentation on `nproc` usage](https://docs.docker.com/reference/cli/docker/container/run/#for-nproc-usage).
48+
49+
Setting `core` to `0` disables core dumps, which can consume significant disk space and potentially expose sensitive information. This is especially important
50+
in production environments where security and data confidentiality are critical.
51+
52+
### System Resource Limits (Cgroups)
53+
54+
System-level resource limits control the overall consumption of CPU and memory by the container. These constraints are enforced by the Linux kernel using
55+
control groups (cgroups), ensuring that containers operate within defined boundaries and do not exhaust host resources.
56+
57+
#### Recommended Settings
58+
59+
* `memory` (maximum memory): At least **6 GB to 10 GB**, depending on the expected load. For detailed guidance, refer
60+
to [PaperMC’s memory recommendations](https://docs.papermc.io/paper/aikars-flags/#recommended-memory).
61+
* `cpu` (CPU allocation): Allocate **2 to 4 cores** as a baseline. Actual needs may vary depending on the number of players, active plugins, world complexity,
62+
and other workload characteristics.
63+
64+
Cgroup limits are especially important in multi-tenant environments or orchestrated systems like Kubernetes, where resource isolation, predictability, and
65+
fairness across containers are critical for system stability.

0 commit comments

Comments
 (0)