~/talk

A pragmatic and simple approach to fixing a memory leak

Talkat RailsConf 2023 · 2023-04-24..04-26· [ruby-on-rails, observability]
links:none on file
slides:none on file

A Rails background worker on Heroku grows past 1GB despite scaling to 2.5GB and splitting queues; concurrency 25 lowered to 15 still shows slow growth. Investigation counts ~120 default jobs, then uses a quarantine queue and binary-split batches (seven to eight candidates) to isolate one leaking job. Memory reports via memory_profiler.report point to Segment client allocations. Fix is to instantiate the analytics client once in a Segment initializer instead of per job and the worker memory stabilizes.

AI-written summary · about

  1. 0:00Introduction
  2. 3:30Memory leak ticket investigation
  3. 7:23Testing config changes
  4. 9:31Worth the effort?
  5. 10:35Researching memory solutions
  6. 13:46Instrumenting suspect jobs
  7. 15:53Binary search approach
  8. 18:23Why binary search works
  9. 19:48Quarantine queue middleware
  10. 21:56Leaking job identified
  11. 23:01Simple fix resolved leak
  12. 23:42Post-fix root cause
  13. 27:12Key takeaways
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.