Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Switching to heroku cedar-14 leads to continous increase in memory consumption

Heroku recently announced that cedar-10 will no longer be supported after this year in November. Switching to cedar-14 led to an increase in memory consumption until I experienced R14 "Memory Quota exceeded" errors and had to restart heroku. The same problem with increase in memory usage occured with unicorn before I started using unicorn_worker_killer gem. Is there a known issue with cedar-14 and unicorn/unicorn_worker_killer? I didn't find anything.

like image 610
floriansuchan Avatar asked Mar 23 '15 10:03

floriansuchan


People also ask

How to solve R14 error Heroku?

If your application immediately starts to throw R14 errors as soon as it boots it may be due to setting too many workers. You can potentially fix this by setting your WEB_CONCURRENCY config var to a lower value. For some applications two Puma workers will cause you to use more RAM than a standard-1x dyno can provide.

What is heroku cedar?

Cedar features a streamlined HTTP stack allowing for advanced HTTP capabilities, heroku run for execution of arbitrary one-off dynos, Procfile and the process model for execution of any type of worker process. Most importantly, Cedar is a polyglot platform with official support for Clojure, Java, Node.


1 Answers

Here is a nice link for your 'problem' : http://blog.codeship.com/debugging-a-memory-leak-on-heroku/

It describe perfectly the continous increase in memory over time. The same 'problem' happen with Puma, there is also a Puma Worker Killer Gem

One thing to note is that you can tune your garbage collector Configuration to be more agressive. Just be careful, you can mess pretty everything with a single bad configuration.

There is -at the moment- no magic solution for this problem. We encounter it too in production, however the memory usage sometimes stabilize, just below the limit where swapping start.

As an immediate action, we choose to reduce the number of workers per dyno, reducing it to 2, and increasing the number of dyno dynamically with HireFire.

You have a loot of tools that can help, here is a list we use each days to track expensive queries / allocations :

  • https://github.com/brynary/rack-bug/
  • https://github.com/binarylogic/memorylogic

Good luck, it's not a simple problem to solve and I don't think that there is a universal true solution for it right now.

like image 171
Erowlin Avatar answered Oct 23 '22 20:10

Erowlin