How to increase memory on the hero?

My rails application has too much memory:

Process running mem=701M(136.9%) Error R14 (Memory quota exceeded) 

Until I solve the problem, how to increase the size of the memory on the hero?

Will more web speakers be added to share memory?

thanks

+7
source share
5 answers

I have the same problem with one of my clients. Digging into memory leaks can sometimes be challenging, especially when third-party code may be the source of the leak.

What I am doing is restarting several dinosaurs every few hours. I took not high hours of movement to complete the reboot.

  • create cron:

     namespace :utils do desc "Restart app by process and time table" task :restart => :environment do time_hash = { 1 => %w[web.1 web.2 web.3], 3 => %w[web.4 web.5 web.6], 5 => %w[web.7 web.8 web.9], 7 => %w[web.10 web.11 web.12], 16 => %w[web.13 web.14 web.1], 18 => %w[web.2 web.3 web.4], 20 => %w[web.5 web.6 web.7], 22 => %w[web.8 web.9 web.10], 0 => %w[web.11 web.12 web.13 web.14], } processes = time_hash[Time.now.hour] processes.each {|process| restart_process(process)} if processes end def restart_process(name) puts "restarting process #{name}:" heroku = Heroku::Client.new(ENV['APP_USERNAME'], ENV['APP_PASSWORD']) heroku.ps_restart(ENV['APP_NAME'], :ps => name) end end 
  • Use the clock scheduler (hero adler) to run this cron.

+8
source

You can not. Dynos has 512M.B quotas, even if you get more speakers, you will still encounter the same wall. Fix memory leaks.

Each speaker receives 512 MB of memory for working inside. Most applications will be comfortably within the scope of this tutorial, and as a developer you don’t have to worry about memory at all.

In some cases, your dynamometer may reach or exceed 512 MB. This usually happens due to a memory leak in your application, in which case you can use a memory profiling tool like Oink for Ruby or Heapy for Python to track the leak and fix it.

Speakers that exceed 512 MB of memory usage will display the R14 error in the logs, for example:

+5
source

You have a hard limit of 512 MB of RAM to play with no exceptions. This memory is stored on every dino. Therefore, you will not be able to deploy your application on Heroku, as it supports significant RAM usage.

I rarely see applications that take up a couple of hundred MB of RAM, so you really need to look at the source of the problem.

When using your RAM, even in a typical VPS, it will be difficult for you to start more than two processes at the same time.

+4
source

From the documents, yes. That should do it.

"Each dyno gets 512 MB of memory to work internally."

http://devcenter.heroku.com/articles/dynos

+2
source

Heroku has updated its API, so the comments above do not work. I made a simpler answer to the comments above (in the file: # {Rails.root} /lib/tasks/schedualer.rake ):

  class HerokuMaintenance def self.get_web_and_workers(get_ps_array) output = [] get_ps_array.each do |i| type = fetch('process',nil) if type.match(/^worker\.\d+$/) or type.match(/^web\.\d+$/) output << type end end return output end ######################################################################### def self.restart_all heroku_client.post_ps_restart(ENV['APP_NAME']) end ######################################################################### def self.get_ps_array(heroku_client) heroku_client.get_ps(ENV['APP_NAME']).body end ######################################################################### def self.heroku_client Heroku::API.new( :username => ENV['APP_USERNAME'] , :password => ENV['APP_PASSWORD']) end ######################################################################### desc "Restart app workers/web" task :my_restart => :environment do HerokuMaintenance.restart_all end 

Following the instructions at https://devcenter.heroku.com/articles/scheduler
1. heroku addons: create a scheduler: standard
2. Heroic runs my_restart rake
3. heroku addons: open scheduler (I run it every hour due to some unpleasant memory problems that I haven't solved yet).

0
source

All Articles