Skip to content

Commit 8899422

Browse files
authored
Run Puma in single mode on Render free tier (#22)
WEB_CONCURRENCY=1 was set with the comment "Single worker to fit in 512MB", but that's the opposite of what it does: WEB_CONCURRENCY is the *worker* count Puma forks *in addition to* the master, so =1 actually means master + 1 worker = 2 Puma processes in cluster mode. Adding SOLID_QUEUE_IN_PUMA on top spawns four more subprocesses (supervisor, dispatcher, worker, scheduler). That's six Ruby processes in one 512MB container: master (~150MB) + worker (~150MB) + 4 SQ procs (~80MB each) ≈ 620MB → exceeds 512MB → OOM-loop Setting WEB_CONCURRENCY=0 drops Puma into single mode (master serves HTTP directly, no fork). That saves the ~150MB worker process and brings steady-state RSS under the cap. With only one Puma process there's no throughput benefit from cluster mode anyway — the worker is pure overhead. Hit by: - raghubetina/aplace running an identical config (Puma cluster + SOLID_QUEUE_IN_PUMA on Render Starter, also 512MB). The deploy appeared green but the container OOM-restarted every ~90s, serving HTTP 502 most of the time. Fixed by the same change. Any student project on this template that adds memory-hungry gems (image_processing, ML/embedding clients, etc.) will hit the same wall — best to fix it in the template before more forks inherit the bug.
1 parent e5532fc commit 8899422

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

render.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ services:
1111
sync: false
1212
# Memory optimization for Render free tier (512MB RAM)
1313
- key: WEB_CONCURRENCY
14-
value: "1" # Single worker to fit in 512MB
14+
# 0 = Puma single mode (the master process serves HTTP directly,
15+
# no forked workers). Any value ≥ 1 spawns that many worker
16+
# processes on top of the master, each adding ~150MB. Combined
17+
# with the four Solid Queue subprocesses below, anything above
18+
# single mode OOMs on the 512MB free tier.
19+
value: "0"
1520
- key: RAILS_MAX_THREADS
1621
value: "3" # Cap threads to reduce memory
1722
- key: MALLOC_ARENA_MAX

0 commit comments

Comments
 (0)