Docker Container Memory Calculator
Calculate the memory limit a container needs from its base footprint, per-request memory usage, concurrency and an overhead buffer.
Inputs
Idle memory footprint of the application runtime (e.g. JVM heap baseline, Node.js process).
Additional memory consumed while handling one in-flight request.
Expected number of requests being processed simultaneously.
Safety margin for GC pauses, connection pools and unexpected spikes.
Recommended Memory Limit
300MB
Recommended Memory Limit
0.29GiB
Recommended Memory Request
250MB
Overhead Buffer
50MB
Step by step
Working set: base + per-request × concurrency
150 + 2 × 50
= 250.0MB
Overhead buffer
250.0MB × 20%
= 50.0MB
Memory limit: working set × (1 + overhead)
250.0 × (1 + 20/100)
= 300.0MB
How it works
A container's memory limit should cover its baseline footprint plus the incremental memory each in-flight request consumes at your expected concurrency, with a buffer for garbage collection pauses, connection pools and traffic spikes. Formula: limit = (base + per_request × concurrent) × (1 + overhead / 100). Setting the limit too tight risks OOMKills under load; setting it too loose wastes cluster capacity.
Formula
memoryLimit = (baseMemory + perRequestMemory × concurrentRequests) × (1 + overhead / 100)
- B
- App base memory in MB
- R_m
- Memory per request in MB
- C
- Concurrent requests
- O
- Overhead buffer percentage
- M
- Recommended memory limit in MB
Frequently Asked Questions
What should I use for 'memory per request'?
Load test your service and observe RSS growth under increasing concurrency, or divide the delta between idle and peak memory by the number of concurrent requests during the test.
Should the Docker memory limit equal the request?
For predictable workloads, setting them equal avoids being throttled or evicted under memory pressure from neighboring containers. For bursty workloads, a limit 20-50% above the request gives headroom.
What happens if I exceed the memory limit?
The container's cgroup will trigger the OOM killer, terminating the process (or a process inside it) once usage exceeds the limit — this shows up as an OOMKilled container in Docker/Kubernetes.
How much overhead buffer is typical?
15-30% is common for most services. JVM-based services with significant GC pause behavior often need 30-50% to avoid GC-triggered spikes causing an OOMKill.
You might also need
- Docker CPU Limit CalculatorCommonly used together
- Docker Image Size CalculatorCommonly used together
- Docker Build Time EstimatorCommonly used together
- Docker Multi-stage Build Savings CalculatorCommonly used together
- Pod Resource CalculatorCommonly used together
- Istio Sidecar Memory CalculatorCommonly used together