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
精彩评论