How many Rails apps on 1 Heroku dyno?

浪尽此生 提交于 2019-12-18 11:06:09

问题


I just can't find how many apps you can host on heroku with one dyno?

I plan to host a lot of small apps with little traffic.

Thanks for your answers


回答1:


Dynos are calculated on a per application basis.

However, this doesn't mean you need to buy 3 dynos to run 3 apps. You can create 3 application each with 1 dyno.




回答2:


One App per Dyno / subdomain.heroku.com.




回答3:


Some explanation here: http://docs.heroku.com/performance#backlog-too-deep




回答4:


I believe you can spin up another web process inside a web dyno. I've done it with workers. One worker dyno had 3 sub-processes. each a copy of the rails app, and each running independently on the database. How you'd manage to spin up the correct application, I'm not sure... And you'd need a controller application.
I don't want to say it's not possible, because I don't believe that statement is at all constructive. I will say, spawning a new application with a 34$ a month extra dyno fee would be a better use of you time/money.

An additional concern. each web dyno allows for a limited amount of memory, and rails isn't exactly known for being light on memory. When I spawned sub-workers I ran into heaps of memory issues. So many that I eventually rolled the feature out. If I work for an afternoon to try to 'tweak' for the constrains, I've spent more of my bosses money than 4 months of extra dyno's, so I have to weigh it up.

Anyway... Here's how I forked workers

require 'heroku-api'

...

  def self.fork_workers(iDesired = 5, iQueue = nil)
    cmd = "rake jobs:work WORKER=MY_SERF"
    cmd += " QUEUES=#{iQueue}" if(iQueue)
    p cmd  
    if(RUBY_PLATFORM["mingw32"].nil?)  #DON'T WORK ON WINDOWS
      currentCount = Rush::Box.new.processes.filter(:cmdline => /#{cmd}/ ).size;
      iDesired -= currentCount;
      if(iDesired > 0)
        iDesired.times { Rush::Box.new[Rails.root].bash( cmd, :background => true ) }
      elsif(iDesired < 0)

      end
    end    
  end

Last note: One dyno apps will go to sleep if left alone for an hour... Your users will feel the delay during wake up. https://devcenter.heroku.com/articles/dynos#dyno-idling



来源:https://stackoverflow.com/questions/2250771/how-many-rails-apps-on-1-heroku-dyno

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!