Alex Rivera | Logout

Kubernetes pod stuck in CrashLoopBackOff after scaling beyond 20 replicas

Asked 2026-03-20T07:55:00Z by Alex Rivera
34
Our deployment works fine at 15 replicas but when the HPA scales to 20+ we get CrashLoopBackOff. The pods fail with OOMKilled despite having 512Mi memory limits. I suspect connection pool exhaustion to our PostgreSQL instance but I'm not sure how to confirm. Resource quotas on the namespace have plenty of headroom...
Edit
Report

1 Answer

52
Accepted
Classic connection pool exhaustion disguised as OOM. Each pod is likely opening its own connection pool to PostgreSQL. At 20 replicas x default pool size of 10, that's 200 connections against PostgreSQL's default max_connections of 100. The pods aren't actually out of memory - they're hanging on connection acquisition, the health check fails, and Kubernetes OOMKills the stalled process. Solution: put PgBouncer in front of PostgreSQL in transaction mode, and reduce per-pod pool size to 3-5.
answered 2026-03-20T11:20:00Z by David Petrov

Your Answer