21

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

Simone Carletti
  • 173,507
  • 49
  • 363
  • 364
Brandom
  • 211
  • 1
  • 2
  • 3

4 Answers4

13

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.

Simone Carletti
  • 173,507
  • 49
  • 363
  • 364
  • Great! How do you know when the dyno is getting too small? – Brandom Feb 12 '10 at 14:04
  • 2
    When your app start throwing 504 errors http://docs.heroku.com/errors#backlog-too-deep-http-504 – Simone Carletti Feb 12 '10 at 16:44
  • You can't operate a real site with one dyno, because it will go idle. – baash05 Jun 16 '13 at 22:50
  • 1
    Untrue. You can use Heroku Scheduler (or some other service) to run a task which performs an HTTP GET request and keeps your dyno allocated to your app. If it runs every 10 minutes it will not go idle. – rpearce Jul 16 '13 at 22:25
  • @Yarin, I got fed up with this costing me a few bucks per month and have created a free little service which queues up HTTP GET requests: http://keep-awake.herokuapp.com/ – rpearce Oct 13 '13 at 23:03
  • @rpearce this sounds awesome. Would this be something against heroku's policies? – Zubzob Oct 14 '13 at 14:40
  • 1
    @Zubzob https://www.heroku.com/policy/tos -- section 4.4. So I need to put this application on another stack. – rpearce Oct 23 '13 at 22:44
7

One App per Dyno / subdomain.heroku.com.

Marcel Jackwerth
  • 53,948
  • 9
  • 74
  • 88
  • 1
    Damn this mean, if I want to host 2 or 3 small apps with little traffic I'd have to pay for 3 dynos :/ I think I'll go VPS – Brandom Feb 12 '10 at 09:48
  • 1
    Exactly.. or use `n` free dynos by Heroku - if they are as small as you say they should fit in the `free` one. But I think VPS/Root is the better idea. – Marcel Jackwerth Feb 12 '10 at 10:04
  • Thanks! BTW can you recommend me some good ones (except slicehost)? – Brandom Feb 12 '10 at 10:21
  • 12
    The first dyno PER APP is free. So you don't pay for any dynos if your apps are small / have little traffic. But if you want to use a VPS regardless, I'd say 6Sync or Linode. These are easily the best in terms of server quality/specs/performance and support for the money. – Michael van Rooijen Sep 04 '11 at 13:07
  • 1
    What Michael said. See http://devcenter.heroku.com/articles/how-much-does-a-dyno-cost – Jo Liss Nov 12 '11 at 01:02
  • There is a problem however with the free dyno though. If you have only one DYNO, it times out (goes idle). So if you are thinking of keeping it free, you're not in luck. You need at least 2 web dynos to keep your sites responsive. – baash05 Jun 16 '13 at 22:48
  • @daveatflow Just find a Ping-monitor of your choice and let it query your app at least once every hour. That should prevent idling. – Marcel Jackwerth Jun 17 '13 at 09:01
  • Today is inpraticable for new commercial conditions of Heroku. Another solution for testing 24/7? –  Jun 22 '15 at 15:55
0

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

baash05
  • 4,394
  • 11
  • 59
  • 97
0

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

Artur Carvalho
  • 6,901
  • 10
  • 76
  • 105