Have You Tried Turning It Off and Again?

If your app has never experienced memory issues, is it really in production?

An Erlang-Inspired Node.js project I deployed at work runs out of memory randomly. It maintains a relatively flat memory usage profile at about 10% of the server’s RAM, but it will suddenly spike to 1.5x ~ 2x RAM.

Excessive Memory Usage on Heroku
Dotted line is my allowed memory usage. Definitely not the way I hoped to start the weekend 🙁

Thankfully Heroku is flexible enough to tolerate spikes under 2x of the allotted RAM so in most cases the app continues to do its job and the worst that happens is I get notified about it. Despite its ability to elegantly recover from crashes, my pride felt like it was being curb-stomped whenever Slack notified me the server ran out of memory again.

slack memory alert
Redacted so much it looks like a CIA release

After determining to redeem my self-respect by fixing the issue, I quickly realized I had no idea where to begin!

Continue reading Have You Tried Turning It Off and Again?