Heroku Basics: Dynos and Costs

A first approach to heroku PaaS and its entities

A few weeks ago we started an app migration from Rackspace to Heroku. We needed to go deep into the Heroku platform.

For those who are not familiar with Heroku, it’s a platform-as-a-service product. It allows you to serve web applications without having to take care of all the sysadmin tasks. But that doesn’t mean that it’s easy.

Before getting started and migrating the whole site, we needed to know what the cost of the service would be. We could not afford to go over our current budget. So this is how our research started and how we started understanding how Heroku works.

Let’s share what we learned.

Heroku dyno

First, we need to talk about the Dyno concept. You can think of it as a sandbox where a process will run. We could make an analogy with a process (like MySql) running in an operating system (like Ubuntu).

You can have different kind of dynos, but if you are working on web applications, you can’t forget the web dyno. Only this one is allowed to receive HTTP requests. Also, there are other kinds of dynos like: worker, clock and one-off.

Heroku dyno

Heroku dyno type

So, you have different dynos running. But you start to noticing that you need more resources. Here’s where the dyno type concept comes in.

Dyno’s type is related with the capability of processing and the amount of memory that your dyno will have. The existing types are: free, hobby, standard-1x, standard-2x, performance-m, and performance-l.

Each type has different features. The goal of this post is not to talk about them, but you need to know that with great power comes great responsibility (yes, I took that one from spider-man). And by great responsibility I mean higher costs. We will go deeper into prices later.

Heroku dyno type

Note: All dynos must be associated with the same dyno type. That is, for example: if you have a dyno associated with a standard plan, then all the other dynos need to be standard-1x or standard-2x. None could be performance-m or performance-l. And the same goes the other way around: if one dyno is associated with a performance plan they all need to be.

Heroku dyno size

The other option that you have to get better performance is changing the size of the dyno. This concept is related to the concurrency that your application will be able to handle. You can have different sizes for each dyno separately.

For example, the dyno web can be standard-x2 with size 4 and the dyno worker can be standard-x1 with size 2.

Heroku dyno size

Heroku cost structure

This is the last topic that I want to talk about (at least in this post). I think about heroku pricing as a connector between all the topics that I mentioned before. And something that you need to have a clear understanding of from the beginning.

Let’s see some examples.

Increasing the dyno size

It’s May 1 and I have my application with only a web dyno running. I configure it with a standard-1x and size=1. So, this dyno will always be up (that’s what we expect) and Heroku will charge me for the time that this dyno is up. At the time of this post, a standard-1x dyno cost $25. That means that we will pay $25 per month.

On May 10, I need to get more concurrency for my web dyno. Therefore, I decide to increase the size of my web dyno to 2. Heroku, after I change it, starts charging me based on the $50 monthly plan (1 standard-1x * 2 size = $50).

On May 20, my app is more chill 😛 so I decide to decrease the dyno size to 1 again. So Heroku starts to charge me $25 as in the beginning.

So, for the whole month of May, Heroku charges me: 10 days of 2 standard-1x and the rest 1 standard-1x. That is $34 approximately.

Heroku pricing for web dyno standard

Changing the dyno type

Sometimes, you may need to have more resources while you are working on a performance improvement that is taking down your site.Here is what happened to us once.

Our application was receiving a lot more users than usual. And they all wanted to buy through it. So I changed the dyno type from standard-1x ($25 per month) to performance-m ($250 per month) during 1 hour and that helped us a lot.

I think that that’s one of the biggest benefits from Heroku. Having more resources for just one hour helped a lot, and it cost less than $1.

Conclusion: manage resources and control costs

Understanding how Heroku works and its pricing, you can increase your resources easily (by paying more) and make your application run faster and better.

It is important to be aware that when you make changes to some of these variables, your changes will immediately impact the price that you will be charged. This gives you great flexibility while maintaining a controlled cost structure.