18
votes

I want to host a static website on Heroku, but not sure how many dynos to start off with.

It says on this page: https://devcenter.heroku.com/articles/dyno-requests that the number of requests a dyno can serve, depends on the language and framework used. But I have also read somewhere that 1 dyno only handles one request at a time.

A little confused here, should 1 web dyno be enough to host a static website with very small traffic (<1000 views/month, <10/hour)? And how would you go about estimating additional use of dynos as traffic starts to increase?

Hope I worded my question correctly. Would really appreciate your input, thanks in advance!

3
Why would you host a static site with Heroku? It seems like you'd get more bang for your buck with Amazon S3 or a shared host or something.Brendan Long
@brendan-long, can you explain how/why? Or link to some source where I can learn more?Gbert90
Heroku is designed for dynamic websites, and priced accordingly. Each dyno is ~$35/month, and is basically one thread doing whatever you want. For the same price, Amazon S3 will transfer 300 GB of files for you (most likely the storage price is negligible for you), and it will do it as fast as you want (not limited to one thread). Basically it will scale much better, and be cheaper too.Brendan Long

3 Answers

50
votes

A little miffed since I had a perfectly valid answer deleted but here's another attempt.

Heroku dynos are single threaded, so they are capable of dealing with a single request at a time. If you had a dynamic page (php, ruby etc) then you would look at how long a page takes to respond at the server, say it took 250ms to respond then a single dyno could deal with 4 requests a second. Adding more dynos increases concurrency NOT performance. So if you had 2 dynos, in this scenario you be able to deal with 8 requests per second.

Since you're only talking static pages, their response time should be much faster than this. Your best way to identify if you need more is to look at your heroku log output and see if you have sustained levels of the 'queue' value; this means that the dynos are unable to keep up and requests are being queued for processing.

3
votes

Since most HTTP 1.1 clients will create two TCP connections to the webserver when requesting resources, I have a hunch you'll see better performance on single clients if you start two dynos, so the client's pipelined resources requests can be handled pipelined as well.

You'll have to decide if it is worth the extra money for the (potentially slight) improved performance of a single client.

If you ever anticipate having multiple clients requesting information at once, then you'll probably want more than two dynos, just to make sure at least one is readily available for additional clients.

3
votes

In this situation, if you stay with one dyno. The first one is free, the second one puts you over the monthly minimum and starts to trigger costs.

But, you should also realize with one dyno on Heroku, the app will go to sleep if it hasn't been accessed recently (I think this is around 30 minutes). In that case, it can take 5-10 seconds to wake up again and can give your users a very slow initial experience.

There are web services that will ping your site, testing for it's response and keeping it awake. http://www.wekkars.com/ for example.