Remediation Hub (9)
Set Distinct Docker mem_limit Caps for Puma, Sidekiq & Postgres
Bounding rails and sidekiq with explicit cgroup mem_limit ceilings protects PostgreSQL shared_buffers and Redis queues from host-wide OOM freezes.
8 GB Budget: rails 1.8G | sidekiq 2.0G | postgres 2.0G | redis 512M
Preventing Cascading Database Crashes During Ruby Spikes
Without container mem_limit guards, a leaking Sidekiq job can consume all free RAM until the Linux OOM killer terminates PostgreSQL—forcing lengthy WAL crash recovery and downtime across the whole helpdesk. Assigning deterministic ceilings forces only the offending worker to restart cleanly.
Pairing mem_limit with Graceful Restart Policies
Use restart: unless-stopped on rails and sidekiq alongside healthchecks. On an 8 GB KVM 2 host, reserve at least 1.5 GB for the Linux kernel, Docker daemon, and OS page cache.
Measured Thresholds & Configuration
| Container Service | 8 GB KVM 2 Cap | 16 GB KVM 4 Cap |
|---|---|---|
| rails (Puma Web) | 1800m | 3584m |
| sidekiq (Workers) | 2048m | 4096m (across 2 pods) |
| postgres + pgvector | 2048m | 4608m |
| redis (Queues) | 512m | 1024m |