How many Rails apps on 1 Heroku dyno?

前端 未结 4 1123
逝去的感伤
逝去的感伤 2020-12-25 13:33

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

相关标签:
4条回答
  • 2020-12-25 13:49

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

    0 讨论(0)
  • 2020-12-25 13:56

    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

    0 讨论(0)
  • 2020-12-25 13:59

    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.

    0 讨论(0)
  • 2020-12-25 14:07

    One App per Dyno / subdomain.heroku.com.

    0 讨论(0)
提交回复
热议问题