Skip to content
Tutorials Center
My learning

Topics

Lesson 24 of 37 ยท Scaling and Performance

Dyno Types, Autoscaling and Cost

Compare Eco, Basic, Standard and Performance dynos, learn how Heroku autoscaling works for Performance dynos, and estimate monthly dyno cost with a simple model.

Choosing a dyno type is a trade between memory, CPU consistency, features and price. The catalogue is stable in shape: a cheap tier for hobby apps, a standard tier for production, a performance tier for demanding apps, and private versions for isolated networks. Exact numbers and prices change, so this lesson gives you the structure and a way to compute with the current numbers. The CLI is read-only here; the cost models are runnable stand-ins with example numbers, not Heroku's price list.

The families

Family Typical use Notes
Eco Hobby projects, demos Shares a monthly pool of dyno hours across all Eco dynos; sleeps after about 30 minutes without web traffic
Basic Small apps Does not sleep; billed per second up to a monthly cap
Standard (1X, 2X) Production web and workers More predictable than Basic; 2X has twice the memory; metrics and preboot available
Performance (M, L, and larger memory variants) High traffic, big memory Dedicated resources instead of shared; supports autoscaling
Private / Shield Isolated networks, compliance Run inside Private Spaces

Memory is the figure that most often bites. Standard-1X dynos have a few hundred megabytes (512 MB at the time of writing), Standard-2X about double, and Performance dynos several gigabytes. Check the Dev Center "Dyno types" page for current values.

Sleeping dynos

An Eco dyno that gets no web traffic for about half an hour goes to sleep; the next request wakes it, and that first request can take many seconds while the dyno boots. This is fine for a demo and bad for anything users depend on. Move production apps to Basic or Standard.

Autoscaling

Autoscaling adds and removes web dynos automatically to hold the 95th percentile response time under a target you set. It is available for Performance (and Private/Shield) web dynos. You enable it in the dashboard or with:

Terminal
heroku ps:autoscale:enable --min 2 --max 10 --p95 400 --app my-app
heroku ps:autoscale:disable --app my-app

Heroku watches the p95 response time (the time within which 95 percent of requests finish). When it exceeds the target, more dynos are added, up to the maximum. When it falls well below the target, dynos are removed, never below the minimum. Notice the limits of the idea:

  • It reacts after users already feel slowness, so set a minimum that handles normal peaks.
  • It cannot fix a slow database; the maximum protects your connection budget and your bill.
  • Only web dynos scale this way; workers need their own approach, such as a script that reads queue depth and calls the Platform API.
Python Stand-in: a simple autoscaler

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The dyno count climbs to 5 as latency rises, holds, then drops back toward 2 when p95 stays under half the target. Heroku's real algorithm is its own; this shows the principle of a target, a band and limits.

Preboot

Normally, a deploy or restart stops old web dynos and starts new ones, with a short window where capacity is lower. Preboot (a Standard and higher feature, heroku features:enable preboot) starts the new dynos first and swaps traffic over after they are ready, so deploys cause no downtime. The side effect: for a moment old and new code both run, so database migrations must be backward compatible.

Estimating monthly cost

Dyno billing is per second of running time, capped at a monthly maximum per dyno. For a quick estimate multiply dynos x hours x hourly rate, then compare with the monthly cap. Use the real prices from the pricing page; the numbers below are invented.

Python Stand-in: monthly cost with a cap

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Output: 75.0, 56.94 and 6.94 with these example prices. A dyno that runs all month costs the cap and no more; a burst of a few dozen hours adds only a small amount, which is why scaling up for a launch is cheap compared with permanent over-provisioning.

Picking a type

  1. Start with Standard-1X for production web and workers.
  2. Watch memory in the Metrics tab. If memory repeatedly nears the limit (errors R14 then R15), move to Standard-2X or fix a memory leak.
  3. Move to Performance when you need dedicated CPU for consistent latency, a lot of memory, or autoscaling.
  4. Use Eco only where sleeping is acceptable.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which dyno family sleeps after about 30 minutes without web traffic?

    Eco dynos sleep when idle and wake on the next request, which is why they suit demos but not production.
  2. 2. What does Heroku autoscaling use as its target?

    You set a p95 latency target; Heroku adds or removes web dynos within your min and max to meet it.
  3. 3. Why set a maximum for autoscaling?

    More dynos multiply connections and costs; a maximum puts a safe ceiling on both.
  4. 4. What is the benefit of preboot?

    Preboot starts the new dynos first and then switches traffic, avoiding downtime during deploys.

Summary

  • Dyno families range from Eco (sleeps) through Basic and Standard to Performance and Private/Shield.
  • Memory limits decide when to go to a bigger type; check the current numbers.
  • Autoscaling (Performance and up) follows a p95 latency target between a minimum and a maximum.
  • Preboot avoids deploy downtime; cost is per second, capped monthly per dyno.

Next: Caching with the Key-Value Store