Heroku App Lifecycle
Last updated April 16, 2025
Table of Contents
Heroku is a cloud platform that allows developers to deploy, manage, and scale applications effortlessly. It abstracts away much of the complexity involved in infrastructure management. To effectively use Heroku, it’s crucial to understand its app lifecycle. The lifecycle consists of several distinct stages that an app undergoes from development to deployment and beyond.
1. Develop the App
During the development phase, write the code and create an empty app on Heroku to deploy to it.
You must also prepare the app for deployment. While you don’t need to make many changes to run your app on Heroku, you must tell the platform which parts of your app are runnable.
If you use common language idioms or frameworks, Heroku can figure it out. For example, in Node.js it’s the main
field in package.json
. For other apps, or to declare multiple process types to execute, you must declare them in a text file called a Procfile.
Other common practices during development include integrating dependencies, installing add-ons for backing services like databases, and running apps locally.
2. Push Code to Heroku
The complete deployment process consists of pushing your code, which triggers a build, that then gets deployed in the form of a release to run on the Heroku platform.
Heroku simplifies the deployment process through Git-based deployment and CI/CD integrations. How you push code depends on your method of deployment, with git push heroku main
and the GitHub integration being the most popular.
3. Build the App
When the Heroku platform receives the source code, it initiates a build of the source app.
Heroku supports multiple buildpacks, which help configure the environment and dependencies for different languages, such as Node.js, Python, Ruby, and Java. For most apps, we automatically detect which buildpack to use.
The build mechanism is typically language-specific, but it follows the same pattern. It typically retrieves the specified dependencies and creates any necessary assets, such as processing style sheets or compiling code. The resulting build artifact contains your compiled, assembled app that is ready to run, and the instructions, the Procfile, of what you want to execute.
When performing a build for Fir-generation apps, we maintain a copy of the app source code solely for the purpose of facilitating user deployments. This copy updates with each build to reflect the most recent version.
4. Deploy the Release
A successful app build triggers the creation of a new release. Before creating the new release, Heroku runs any tasks that are specified in the release phase, if applicable.
If you have a successful app build, and all applicable release phase tasks run successfully, Heroku deploys the release. If you use Heroku CI or other CI/CD integration tools, you can require that your test run pass before deployment. Beyond pushing code, Heroku also creates a new release and restarts your app if you change a config var, or modify your app’s add-on resources.
Your release deploys to all app dynos, with Heroku’s Preboot and Rolling Deploys features enabling zero downtime deployments. To test your app thoroughly before making changes to production, consider using the Review Apps and Pipelines features to promote builds instead.
5. Run the App
By default, apps are accessible at their Heroku domains.
After deployment, the app enters the runtime phase, where it runs on compute resources called dynos that actively serve requests. Depending on your dyno formation, some of your dynos run the command associated with the web
process type, and some run other commands as declared in your Procfile.
The web
dynos are the only ones that receive HTTP traffic. Heroku’s HTTP routers distribute incoming requests for your app across your running web dynos. This routing handles both HTTP and HTTPS traffic, and it supports multiple simultaneous connections and timeout handling.
The dyno manager is a part of the platform responsible for running dynos. Its jobs include cycling, or restarting, dynos when it detects a fault in the running app or problems with the underlying hardware. It also cycles dynos on a daily basis to help maintain the health of apps, unless configured otherwise.
6. Scale the Resources
Scaling an app’s capacity to handle web traffic generally involves scaling the number of web
dynos. You can also scale up other process types, such as worker
dynos for handling your background jobs.
Heroku offers a robust scaling model with multiple dyno sizes so you can adjust resources as needed:
- Horizontal scaling: Adding more dynos to handle increased traffic.
- Vertical scaling: Changing to different sized dynos.
7. Monitor the App
To ensure the app runs smoothly, monitor its performance and debug issues when necessary. Heroku provides various monitoring tools, such as logs, metrics, OpenTelemetry (for Fir-generation apps only), and support for monitoring add-ons.
8. Update and Maintain the App
Apps require regular updates for bug fixes, security patches, and new features. Because Heroku manages and runs apps, the platform takes care of platform updates and maintenance as well as maintenance for Heroku’s own add-ons, like Heroku Postgres.
Beyond the updates and maintenance provided by Heroku, you can also make any changes you need to your codebase and enter maintenance mode if you must temporarily disable access to your app. You can also run one-off dynos to carry out admin tasks.
9. Optimize Your Resources
As you scale, monitor and update your app, find ways to optimize your code and resource usage. See tips on how to optimize your usage in this guide.
10. Decommission the App
When you no longer need an app, scale it down, remove its add-ons, and delete it from Heroku. Deleting an app is permanent and removes all associated data such as configuration, code, builds and releases with it.
Next Steps
Understanding Heroku’s app lifecycle helps developers make the most of the platform’s features for efficient deployment, scaling, and management. By leveraging Heroku’s streamlined workflow, teams can focus on building and improving their apps without worrying about complex infrastructure management. Dive deeper into any of these topics to learn more: