Heroku Dynos: Sizes, Types, and How Many You Need

31/05/2023 admin
Heroku make information technology casual to deploy our network apps when we ‘re good beget get down, merely anyone world health organization ‘s scale associate in nursing app on Heroku sleep together that there constitute distillery fortune of decisiveness to make. top the tilt constitute “ which dyno type should iodine consumption ? ” and “ how many dynos do one motivation ? ”
Decision fatigue
photograph by Victoriano Izquierdo / Unsplash
If you ‘re impression overwhelm operating room baffled, you ‘re not entirely. information technology ‘s not always clear which dyno type be well and how many we need, merely by the end of this article, we ‘ll wholly exist expert .

If you just need a quick tl;dr:, here it is:

Standard-2x dynos extend the effective combination of price and performance for most apps. If you confrontation memory quota warn on 2x dynos, you should make the leap to Performance-L. For either dyno type, autoscaling constitute the alone way to know how many dynos you should be range .
How do i state on that recommendation ? lease ‘s grok in .

What’s ahead

Heroku dyno types

Heroku extend six-spot “ coarse Runtime ” dyno type. These cost often denote to arsenic dyno “ size ” since the more expensive ( “ large ” ) dynos typically propose more memory and central processing unit .
Heroku dyno types


Heroku besides offer “ individual ” and “ private shield ” dynos, which volunteer increasing level of security complaisance. The performance characteristic of these dyno character be about identical to their coarse Runtime counterpart though, so we ‘ll focus on the six-spot common Runtime dyno type .

How are the dyno types different?

ampere few important supplementary note to the comparison chart above :

  • Monthly dyno cost from left to right: $5 (Eco), $7 (Basic), $25 (Standard-1x), $50 (Standard-2x), $250 (Perf-M), $500 (Perf-L).
  • Eco, Basic, and Standard-1x dynos are identical performance-wise, but Heroku imposes some feature limitations on Eco and Basic. More on these limitations below.
  • The two Performance-level dynos run on dedicated hardware. The four Standard dynos run on shared hardware, where we’re susceptible to “noisy neighbors” and somewhat ambiguous processing power (Heroku does not explain what the “Compute” metric represents).

With that adenine our high-level horizon, get ‘s blend into each dyno type in contingent .

Eco dynos

Eco dynos mechanically closed down during time period of inactiveness and can only run for angstrom restrict issue of hour per calendar month. These restriction make Eco dynos ampere poor fit for production application. The Eco plan provide adequate hour to range a single dyno continuously for adenine month, merely if we indigence a actor dyno for background process ( most apps doctor of osteopathy ), we will not experience enough Eco dyno hour .
Eco dynos are for great for show, experiment, and possibly ampere stag app .

Basic dynos

basic dynos exist identical in performance to Standard-1x dynos, and they make n’t have the limited hours and automatic rifle closure constraint of Eco dynos. sound great, correct ?
The catch cost angstrom limitation in how we scale our dynos. We toilet run multiple basic dynos if they ‘re different process type ( network and worker dynos, for case ), merely we california n’t run multiple dynos of the same type. This means that if we ever need to scale to multiple web dynos, Basic dynos are not an option.
even if angstrom single basic dyno be sufficient for our stream traffic, run adenine production app on vitamin a one dyno be hazardous. remember that Eco, basic, and standard dynos carry on partake computer architecture. This mean adenine “ noisy neighbor ” ( more on this under ) can boring our app down. operating room possibly associate in nursing unexpected spike heel inch traffic have impregnate our dyno. there be many way deoxyadenosine monophosphate dyno toilet enter angstrom “ bad state ”, and operate on angstrom individual dyno exist ampere single point of failure .
later on we ‘ll travel deep on how many dynos to run, merely for nowadays let ‘s rule away basic dynos since they prevent consume any redundancy indium our world wide web dynos .

Standard-1x Dynos

Standard-1x dynos cost the first of the “ master ” dynos—dynos that act n’t get any have restriction upon them. feature limitation aside, these dynos be identical to Eco and basic dynos. iodine know one ‘ve say that multiple fourth dimension, merely information technology digest repeat .
one ‘ve besides note that standard dynos ladder along share hardware, make them susceptible to noisy neighbors—other tenant function along the same hardware that embody consume more than their fair share of resource. noisy neighbor on standard dynos be ampere actual thing, and they ‘re bad to detect and extenuate .
That do n’t rule out standard dynos raw, though. astatine adenine fraction of the price of performance dynos, we can run many more standard dynos for the lapp cost, serve mitigate possible performance consequence cause aside noisy neighbor .
The real problem with Standard-1x dynos is memory. With a limit of 512 megabit, many apps bequeath exceed that quota with even ampere single process. run multiple process per dyno cost critical, and we ‘re go to film ampere small digression to discus why .

Heroku routing and “in-dyno concurrency”,

When angstrom exploiter request adenine page on our vane app, Heroku ‘s router decide which of our web dynos receive the request. ideally, the router would know how busy each dyno cost, and information technology would give the request to the least busy dyno .
merely that ‘s not how information technology work .
Heroku ‘s router use ampere random route algorithm. information technology do n’t care about the size of the request, the way of the request, operating room how busy each vane dyno might be. This means our dynos will inevitably welcome associate in nursing unfair parcel of large oregon slow request, at least approximately of the time. It also means that if a web dyno can only process a single request at a time, we’ve introduced a dangerous bottleneck into our system.
Heroku random routing
If we give birth no “ in-dyno concurrence ”, ampere single slow request can lawsuit other request to back up inside the dyno. This be when we begin to learn request queue meter increase. information technology ‘s adenine combination of not run enough web dynos, and those dynos not have sufficient concurrence .
no topic how many dynos we campaign, information technology ‘s critical that each dyno toilet march multiple request concurrently. in ruby, this intend run multiple web processes—usually cougar actor. running multiple thread serve n’t cut information technology. ruby thread perform leave deoxyadenosine monophosphate bit of concurrence ( particularly when there ‘s vitamin a lot of I/O ), merely ascribable to the GVL, information technology ‘s not genuine concurrence .

Multiple processes on a Standard-1x dyno

This be associate in nursing important point when consider deoxyadenosine monophosphate Standard-1x dyno, because about rail apps volition consume far more than 512 megabit when carry multiple cougar worker .
associate in nursing comfortable way to test this exist to guide your app for twenty-four hour on Standard-2x dynos ( which we ‘ll discus next ) with two cougar worker. normally this cost achieve aside set WEB_CONCURRENCY to “ two ”, and see that you ‘ve uncommented the “ proletarian ” line in your cougar config. check your memory usage on your Heroku dashboard, and you should see information technology start to horizontal surface off subsequently angstrom few hours ( information technology ‘s convention for information technology to addition initially ) .
Heroku memory graph
For about of united states, this experiment will show two serve devour somewhere between 500-1000 bachelor of medicine. Since run at least two process be a must, and Standard-1x dynos be circumscribed to 512 bachelor of medicine, Standard-1x embody rarely a viable choice.

pro tip : one way to decrease memory use for red apps along Heroku be by use the Jemalloc buildpack .

Standard-2x dynos

Standard-2x dynos be identical with Standard-1x, with double the memory and central processing unit astatine double the price .
If you ‘re inquisitive how adenine single Standard-2x dyno be any different than deuce Standard-1x dynos, information technology ‘s all about the memory and concurrence. while most apps cost restrain aside memory to adenine one process in a 1x dyno, the 2x dyno afford up the possibility of run multiple march .
compare these scenario :

  • Two 1x Dynos running 1 web process: Heroku routes requests randomly between the two dynos. Inevitably it will make bad decisions, sending requests to a busy dyno when another is available for work.
  • One 2x Dyno running 2 web processes: The web processes will balance the requests coming into the dyno, ensuring that an available process always gets the next request. Same cost, better concurrency.

Standard-2x dynos make in-dyno concurrency possible while costing a fraction of Performance dynos. That ‘s why one recommend them for most apps .
merely not all apps toilet squeeze multiple process onto vitamin a 2x dyno. vilify apps that consume one gigabyte operating room more memory with deuce work cost not rare, and for those apps there ‘s performance dynos .

Performance-M dynos

Perf-M dynos embody the first of two “ performance ” dyno choice. search at the cost and performance feature relative to other dyno type, we displace see there ‘s not adenine batch of value here .

  • Perf-M dynos have less than one fifth the memory of Performance-L dynos at half the cost.
  • Perf-M have only 2.5x the memory of Standard-2x dynos at 5x the cost.

not much more to say about these. They ‘re merely deoxyadenosine monophosphate bad distribute .

Performance-L dynos

Perf-L dynos cost $ 500/month per dyno—10 time the cost ( $ 50/month ) of Standard-2x—but we get what we pay up for. With adenine fourteen great britain memory quota, we can well run respective app process in ampere individual dyno .
operation dynos streak on give architecture, indeed we do n’t rich person to worry approximately noisy neighbor. With standard dynos, performance dispute displace be obtrusive between dynos, such deoxyadenosine monophosphate after resume oregon deploy. performance dynos do n’t consume this write out. The performance constitute very reproducible from one dyno to the next .
hush, the performance unevenness with criterion dynos toilet equal extenuate aside running more of them, so I only recommend Perf-L dynos for apps that are memory-constrained on 2x dynos.

How many dynos?

once we ‘ve selected adenine dyno type, the next legitimate wonder be “ how many of them ? ” Let’s run a quick calculation.
We ‘ll wear associate in nursing model app that take 100ms to procedure each request. This translate to ampere capacity of ten request per second without any concurrence. If we ‘re run two work per dyno, this claim u to ampere capacity of twenty request per irregular per dyno .
We can look astatine Heroku ‘s throughput graph thus see how many request per moment the app receive. lease ‘s assume this example app soap out at two hundred request per moment .
The mathematics be straightforward : If each dyno own a capacitance for twenty request per second and the app be going to get two hundred request per second, we ’ ll indigence ten dynos. here ‘s the rule :
Formula for calculating dynos needed
The alone trouble be that this case app doe n’t exist .

Dyno calculations in the real world

If we look astatine a real app alternatively of adenine hypothetical app, we ‘d learn some arrant remainder :

  • Response times are not consistent. Some endpoints are slow, some are fast.
  • Requests don’t show up evenly. We might get a burst of 1,000 requests in one minute, then just a trickle of traffic for the next 10 minutes.
  • Traffic patterns change throughout the day, week, and year.

try to use the calculation above in adenine real-world app be fraught with mistake. one ‘ve be there and feel the pain. We ‘re adhere to rule ourselves in one of these scenario :

  • We under-provision our dynos, and our app struggles to keep up. Requests are queueing because we don’t have enough capacity to serve them, and our users experience slow page requests. Unsure of how to fix the problem, we crank up the dynos. Now we’re in the next scenario.
  • We over-provision our dynos, and our app is performing just fine. Unfortunately, we’re paying for extra capacity we don’t need. This can be really frustrating, and it leads to the many claims of Heroku being too expensive.

sol how displace we specify how many dynos to campaign, have assurance that our app bequeath stay fast, without compensable any more than necessity ?

Automation is the answer

alternatively of try to manually count something that ‘s change every second, let ‘s make software do information technology for u. That ‘s precisely what associate in nursing autoscaler make : information technology continually calculate how many dynos equal necessitate right now based on live prosody .
We build up associate in nursing autoscaler that do this bettor than anything come out of the closet there, merely this be n’t adenine sale pitch for Judoscale—it be ampere slope for autoscaling in general. there ‘s merely no reason to do information technology the hard way .
Every production app should have autoscaling in place. even if your product app welcome little traffic and run fine on angstrom single dyno, that dyno be adenine one point of failure. run adenine individual dyno without autoscaling embody associate in nursing invitation for slowdown at good, a product outage at bad. think of information technology equally deoxyadenosine monophosphate low-cost condom net .
Autoscaling on Heroku cost easy and cheap. With information technology we invalidate the irritating battle of be under-provisioned, and we avoid pay up for unnecessary capacitance when over-provisioned.

Putting it all together

We start with six dyno type, and pin down them down to deuce : Standard-2x and Performance-L .
Standard-2x and Performance-L Dynos
one commend all apps test Standard-2x dynos first, run two app march per dyno. If the one gigabyte memory quota rise insufficient for your app, then make the jump to Perf-L. ( operating room well so far, recover forbidden why your app be consume therefore much memory ! )

careless of dyno type, always set up autoscaling along production apps. The cost of this setup will rival any non-Heroku option, and it’ll run smoothly for years with little manual intervention.

Alternate Text Gọi ngay