You might know—vaguely, roughly, innately—that deploying an application to Heroku's Platform-as-a-Service would be a good choice to make. It'll save you from the struggles of setting up networks, managing infrastructure, and configuring services, freeing up time to focus on building features for your application, to deliver value to your customers. But maybe you aren't really sure how Heroku does those things. Or maybe (gulp) you don't think Heroku can help you out much.
Heroku takes care of so many DevOps-y chores for you that its simplicity tends to obfuscate the number of concerns involved in deploying and maintaining a production-grade app. So in this post, we're going to take a look at just eight ways in which Heroku makes your development life just a little bit easier.
Your application is more than just the code you've written. It also relies on the packages you've explicitly imported, the programming language you're writing in, and the operating system your code runs on. You know what that all adds up to? Maintenance. You've got to be on the lookout to make sure that your operating system is patched from security flaws and your programming language is updated for performance improvements, constantly.
Instead of sorting through package security updates, or figuring out how to take your site down and update to the latest Ubuntu, Heroku will take care of all of the security overhead for you. Here’s a recent blog post demonstrating what the process for the end user is to receive critical security updates (hint: it’s nothing).
The problem of machine maintenance scales linearly as you add more servers to your workflow, typically by way of needing more environments. If you need to introduce a staging environment into your setup, you may already have some automation scripts to set up that infrastructure, but now you need to pay close attention to their system dependencies as well.
Deploying the entire stack of a Heroku application is as simple as a
git push to a new Heroku app. Rather than spending time re-provisioning the minutiae of your servers' needs onto staging servers, you can just link your different environments and push your code out to a new environment instantaneously.
But maybe you have many environments, and you don’t want to keep entering commands to deploy the app to all of them. That’s fine; you can set up a pipeline instead. A pipeline allows you to promote your app through various environments: development, review, staging, production.
When it comes to environment variables, you can get and set these through the command line, too:
# set for production (by default) $ heroku config:set APP_SECRET=XXX # set for staging $ heroku config:set APP_SECRET=YYY --remote staging
Databases are at the heart of every application, from the very simple to the very complex. Applications rely on the presence of a database from which to store and retrieve essential information. If connections to this service stop flowing, it can completely kill your application. Tweaking the database engine itself can also eke out some performance gains, which can be critical for high-traffic sites.
Let Heroku's database administrators ensure that the installations are well-tuned, so that your engineers can work on other issues. They'll upgrade the database, automatically apply security patches, migrate you off of bad instances, and more. While your team is iterating on improvements, Heroku's DBAs will optimize your database for gains you didn't even know you needed.
Frequent maintenance of your backend isn’t just lip-service: it’s a core value Heroku prides itself on.
Logs: they're not just for lumberjacks anymore! You're likely tracking various actions across the lifecycle of requests, whether that's to your web app, its worker queues, system components, or any backing services. Configuring all of those sources of information can be a challenge, and aggregating into something that can be consumed could be even harder.
Heroku's Logplex will not only slurp up information from any source you tell it to, it'll also spit it back out in a format that you expect, whether that's for long-term storage, a terminal somewhere, or any API endpoint. You can build your own pipeline, or tap into the existing add-on ecosystem for log routing.
As you might expect from its extensive and flexible logging setup, Heroku's also got a phenomenally beautiful monitoring system. Although you can choose to integrate with third-parties on this, in many cases, you won't need to. Heroku's dashboard will show you much of what you need to know, from memory health (via GC times and overall usage), to HTTP request/response times, and even the overall health of your server's interaction with its resources. There are also plenty of external integrations to choose from if you’d prefer to hook into an external system like New Relic or Graphite.
For Professional dynos, you can also set up alerts directly from the Heroku Dashboard. As you're configuring your thresholds, Heroku will tell you how many times it would've triggered notifications to your time, and advise you to adjust the metrics if they're too sensitive. There's also a native integration with PagerDuty.
Have you got a backup strategy for your application and its infrastructure? And are you sure it works? With dependencies that your system might need—Redis, Postgres, Kafka—you have to set up data backup and recovery strategies, configure the granularity of its retention, and make sure that you've always got enough disk space on hand to keep the backups you need.
Since Heroku's on your side, and probably more nervous about data loss than you are, they've already thought through a thousand different disaster scenarios, and are able to store and restore your data in the safest manner possible. For example, a single command through your terminal can rollback your database to a previous state; if a Kafka node fails, Heroku's automated systems will work to restore it to its normal operation.
It's not uncommon for applications to require the need of a process manager, in order to restart stalled—or completely crashed—applications. But as with backups, ensuring that this daemon is doing the right thing can be tough, especially considering that it "works" only when everything else doesn't.
In the event of the unexpected, Heroku will restart your servers for you, whether that's due to resource exhaustion, a segfault, or just a plain logic bug. While attempting to recover, the runtime also has a cool-off period of several minutes to gracefully resume normal operations.
If your application is highly available, it needs to be in more places than one, which means more of everything--including databases. In the average HA setup, all data writes go to a primary database, and several region-specific secondaries are distributed across the world. Ensuring the proper throughout from the primary to the secondary is a bundle of networking and latency issues, chief among them being to ensure that your application does not read data that has become stale.
For Postgres (The One True Database™️), Heroku provides the ability to fork your primary database more easily than you might believe possible. By creating a database through the command-line, and providing the
--follow flag, you can create a read-only follower of your primary database. Changes from the primary are streamed in real-time, allowing for seamless migrations, data redundancy, and a hot standby.
When you spend less time setting up and executing on your production needs, you’ll have more time for your users’ needs. Heroku runs eight million apps at 25 billion requests per day, and the developers building those apps benefit from a DevOps workflow that's managed for them.