Memory Configuration and Circuit Breakers
JVM heap sizing
MonkDB runs on JVM. Heap is set through MONKDB_HEAP_SIZE.
Practical baseline:
- Start at ~25% of node RAM.
- Keep heap not below
1GB. - Prefer staying at or below ~
30.5GBfor Compressed Oops efficiency.
Compressed Oops check
jcmd <pid> VM.info | grep "Compressed Oops"
If Compressed Oops is disabled, object pointer overhead increases.
Swap and memory locking
Swapping degrades latency and stability.
Set in config if your host limits permit:
bootstrap.memory_lock: true
Also configure OS memlock limits accordingly.
Circuit breaker model
Circuit breakers are preventive memory guards. They estimate memory before/while operations run and abort work before heap exhaustion.
Common breaker categories:
queryrequestjobs_logoperations_logtotal(parent)
Typical exception
CircuitBreakingException[Allocating ... failed, breaker would use ... Limit is ...]
Breaker incident response
- Identify heavy active jobs:
SELECT j.id, stmt, username, SUM(used_bytes) AS sum_bytes
FROM sys.operations op
JOIN sys.jobs j ON op.job_id = j.id
GROUP BY j.id, stmt, username
ORDER BY sum_bytes DESC;
- Check completed history in
sys.jobs_log/sys.operations_log. - Optimize queries (filters, partitions, joins, cardinality).
- Reduce concurrency for heavy workloads.
- Scale cluster resources if pressure is persistent.
Memory tuning checklist
- Validate heap setting against host RAM.
- Keep OS cache headroom for Lucene mmap access.
- Watch GC pauses after heap changes.
- Tune breaker limits only after query/profile analysis.