当前位置: 动力学知识库 > 问答 > 编程问答 >

ruby - How many Rails apps on 1 Heroku dyno?

问题描述:

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

网友答案:

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.

网友答案:

One App per Dyno / subdomain.heroku.com.

网友答案:

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

网友答案:

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

分享给朋友:
您可能感兴趣的文章:
随机阅读: