Scaling Your Dyno Formation
Last updated October 16, 2024
This article has instructions for manually scaling your app by changing the dyno size or number of dynos in your formation. Autoscaling is also available for some dyno tiers.
For guidance on how to find the correct size and number of dynos to run for your app, see Guidance for Choosing a Dyno and Application Load Testing.
Change the Number of Dynos
Scaling a process type horizontally provides additional concurrency for performing the work handled by that process type. For example, adding more web
dynos allows you to handle more concurrent HTTP requests. Adding more worker
dynos lets you process more jobs in parallel.
See Dyno Scaling and Process Limits for the maximum number of dynos you can run per dyno type.
With the Heroku Dashboard
You can’t run more than one Eco or one Basic dyno per process type. Upgrade to a larger dyno first before adding more dynos.
- From the Heroku Dashboard, select your app.
- Go to the
Resources
tab. - Click the edit icon beside a process type, for example
web
. - Move the slider or manually type in the number of desired dynos.
- Click
Confirm
.
With the Heroku CLI
You can change the number of dynos with heroku ps:scale
. For example, heroku ps:scale web=3
.
You can also change the number of dynos for multiple processes at the same time. For example, heroku ps:scale web=1 worker=5
You can also change both the dyno size and the number of dynos for a process at the same time with heroku ps:scale
. For example, heroku ps:scale web=3:performance-l
.
With the Heroku API
See the Formation endpoints in the Heroku Platform API to change the dyno size or number of dynos in your dyno formation.
Autoscaling
Heroku offers Autoscaling for Performance-, Private- and Shield-tier dynos. If that feature doesn’t meet your needs, consider a third-party add-on from the Elements marketplace.
Change the Dyno Size
Scale vertically by changing its size to change the resources available to each dyno. For guidance on selecting the correct size, see Guidance for Choosing a Dyno.
With the Heroku Dashboard
Common Runtime Apps
- From the Heroku Dashboard, select your app.
- Go to the
Resources
tab. - Above your list of dynos, click
Change Dyno Type
. - Click the desired dyno tier.
- Click
Save
. - Click the icon beside your listed processes to open the dyno size dropdown menu.
- Select a size. Eco and Basic tiers only have one size.
Private Space Apps
- From the Heroku Dashboard, select your app.
- Go to the
Resources
tab. - Click the icon beside your listed processes to open the dyno size dropdown menu.
- Select a size.
With the Heroku CLI
You can change the dyno size for a process by using heroku ps:type
. For example, heroku ps:type worker=standard-2x
.
You can also change both the dyno size and the number of dynos for a process at the same time with heroku ps:scale
. For example, heroku ps:scale web=3:performance-l
.
With the Heroku API
See the Formation endpoints in the Heroku Platform API to change the dyno size or number of dynos in your dyno formation.
Considerations
Scaling Limits
See Dyno Scaling and Process Limits for the maximum number of dynos you can run per dyno size.
Mixing Dynos Tiers
An app can use a mix of Standard- and Performance-tier dynos. For example, an app can run its web
process type on performance-m
dynos while running a worker
on a standard-1x
dyno.
If your app uses any other dyno tier, it can only use dynos from that tier for all process types. For example, an app that uses Basic-tier dynos can only use basic
dynos for all its process types. An app that uses Private-tier dynos can only use private-*
dynos for all of its process types.
When Not to Add Dynos
Singleton Processes
Never scale singleton process types, such as a clock
/scheduler
process type beyond a single dyno. These process types don’t benefit from additional concurrency and can create duplicate records or events.
Backing Service Bottlenecks
Sometimes a bottleneck limits your app’s performance. This bottleneck can come from a backing service, most commonly the database. Adding more dynos in this case can make the problem worse. Fix your bottleneck issues first. For example, if it’s a database, you can try to:
- Optimize your database queries
- Upgrade to a larger database
- Implement caching to reduce database load
- Switch to a sharded configuration, or scale reads using followers
Long-Running Jobs
Adding more dynos can’t help with large, monolithic HTTP requests, such as a report with a database query that takes 30 seconds, or a job to email out your newsletter to 20,000 subscribers. Try dividing the work first so that adding more dynos makes sense as they run jobs in parallel. See Worker Dynos, Background Jobs and Queueing for more info.
Threads and Requests
A single dyno can serve thousands of requests per second, but performance depends greatly on the language and framework you use. A single-threaded, non-concurrent web framework, like Rails 3 in its default configuration, can process one request at a time. For an app that takes 100ms on average to process each request, it translates to about 10 requests per second per dyno, which isn’t optimal.
We don’t recommend single-threaded back-ends for production applications because of their inefficient handling of concurrent requests. Choose a concurrent backend whenever developing and running a production service. Multi-threaded or event-driven environments like Java, Unicorn, EventMachine, and Node.js can handle many concurrent requests. Load testing your app is the only realistic way to determine request throughput.