Skip to content

Commit cf1a909

Browse files
docs: memory leakage investigation report for SSR pipeline (#3296)
## Summary - Adds a comprehensive investigation report for the reported memory leak in react_on_rails_pro SSR workers (linear RSS growth under sustained traffic) - After building an in-repo reproducer and running 30,000+ requests over 68 minutes, **no reproducible heap leak was found** (1.63 KB/req post-warmup, well below the 15 KB/req "refuted" threshold) - The reported RSS growth is consistent with **memory fragmentation** — a well-documented phenomenon in Ruby processes under glibc malloc with large, variable-size allocations — not a simple heap-level object leak - This type of growth cannot be reproduced in synthetic benchmarks because it depends on specific allocator behavior (glibc malloc arena expansion), traffic pattern diversity, payload size variation, and runtime conditions that are rare in controlled environments - Includes recommendations: jemalloc adoption, `MALLOC_ARENA_MAX=2`, `--max-old-space-size` for Node workers, and worker rolling restarts as the primary safety net ## Report Contents 1. **Investigation methodology** — reproducer infrastructure, measurement approach, verification rubric 2. **SSR pipeline architecture** — memory allocation path from Rails through HTTPX to Node Renderer 3. **Experiment results** — small payload (refuted), large payload (inconclusive), 30K long run (refuted at 1.63 KB/req) 4. **Root cause analysis** — glibc malloc arena fragmentation, HTTP/2 amplification, CoW invalidation 5. **Why the leak cannot be reproduced** — deterministic data, uniform concurrency, GC noise floor 6. **Application-level patterns** — common Node-side leak patterns in user code (unbounded caches, saga middleware reuse, lodash memoize) 7. **Recommendations** — jemalloc, MALLOC_ARENA_MAX, heap snapshots, monitoring guidance Closes #3286 ## Test plan - [x] Report reviewed for accuracy against experiment data in `MEMORY_LEAK_EXPERIMENTS.md` - [x] No client-specific information included - [x] All referenced files and code paths verified against current codebase - [ ] Stakeholder review of findings and recommendations 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Added comprehensive investigation report documenting measurement methodology, experimental findings across multiple configurations, technical analysis of memory behavior patterns, and actionable operational recommendations for optimization. <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/shakacode/react_on_rails/pull/3296) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6167202 commit cf1a909

1 file changed

Lines changed: 466 additions & 0 deletions

File tree

0 commit comments

Comments
 (0)