Heroku Architecture Credential By Example

John Tucker
7 min readSep 26, 2019

In preparing for the Heroku Architecture Credential, I found myself needing a concrete example to solidify my learnings; thought to share the making of this example through a series of videos.

Addendum 11/6/19: So, it took me two tries to pass the exam and thought to share some observations. The materials that I created here are more focused on the delivery of a single Heroku application, where-as the exam is focused more focused on architecting the Heroku infrastructure to support a complex mix of applications across multiple locations / technologies. The trick for my passing was to put a lot more time in understanding the Heroku Enterprise material; especially Private Spaces. Also, make sure you have a theoretical understanding of Apache Kafka and it usage.

Addendum 11/12/19: I have sprinkled some representative questions and direction on answers below; look for the large Q characters.

Part 1: Local “Hello World” Application

Setting up a local “Hello World” web application.

Agenda:

Addendum:

Part 2: Getting Started

Setting up a Heroku “Hello World” web application.

Agenda:

The final solution for this part is available in the started branch of the larkintuckerllc/hello-cert repository.

Question: During development, we want to be able to run our applications locally. What Heroku feature(s) can be used used to support this scenario?

Answer: Running Apps Locally

Part 3: Core Concepts

Dissecting the “Hello World” application to introduce Heroku core concepts.

Agenda:

  • Regions
  • Buildpacks
  • Slugs
  • Releases
  • Stacks
  • Dynos
  • Dyno Managers

Question: We have a Ruby application that requires a Grunt (JavaScript) build step. What Heroku feature(s) can be used used to support this scenario?

Answer: Using Multiple Buildpacks for an App

Part 4: More Core Concepts

Pretty much what the title is, more Heroku core concepts.

The final solution for this part is available in the more-core branch of the larkintuckerllc/hello-cert repository.

Agenda:

  • Environment
  • Logging
  • Resources
  • Releases Revisited
  • Metrics
  • Alerting

Addendum:

  • In the video, I mentioned that the Heroku router generated the 304 (Not Modified) response code. It turns out that it was Express itself determining that the API result was unmodified (using an Etag header) and returning this response code

Question: We have an application that requires credentials to access a third-party API. What is the recommended practice for storing such credentials?

Answer: Development and Configuration Principles: Configuration

Part 5: Networking

Exploring a number of networking related topics.

The final solution for this part is available in the networking branch of the larkintuckerllc/hello-cert repository.

Agenda:

  • Cache Control
  • Compression
  • X-Request-ID
  • Custom DNS
  • Heroku Router

Question: We have a web application with multiple dynos. Does the Heroku Router, by default, ensure that a user is directed to the same dyno each time? What Heroku feature enables this?

Answer: Session Affinity

Part 6: Pipelines

Exploring a basic workflow using pipelines.

Agenda:

  • Pipelines
  • Basic Workflow
  • GitHub Integration

Question: We have a web application that includes a front end that is built during deployment. The front end build depends on environment variables that vary across the staging and production environments. What, if any, problems will we encounter when promoting applications from staging to production?

Answer: Pipelines: Design Considerations

Part 7: Review Apps and Continuous Integration

Using Heroku Review Apps and Heroku Continuous Integration to power a GIT Feature Branch workflow.

The final solution for this part is available in the review-apps branch of the larkintuckerllc/hello-cert repository.

Agenda:

  • Review Apps
  • GitHub Branch Protection: Reviews
  • Heroku Continuous Integration
  • GitHub Branch Protection: Require Status Checks

Addendum:

  • In the video, I referred to a GIT workflow; should have referred to it more specifically as a GIT Feature Branch workflow

Question: Describe the automated workflow that Review Apps support. Given Review Apps automated workflow, what feature(s) support setting up application environment variables?

Answer: Review Apps (New): Configuration

Part 8: Heroku Postgres Basics

We add a database query to our application; both local and Heroku.

The final solution for this part is available in the postgres-basics branch of the larkintuckerllc/hello-cert repository.

Agenda:

  • Prerequisites:
    Docker
    PostgreSQL client
  • Local PostgreSQL
  • Manual Database Migration and Seeding (Local)
  • DATABASE_URL
  • Hello Database (Local)
  • Heroku Postgres
  • Manual Database Migration and Seeding (Staging)
  • Hello Database (Staging)

Question: Which Heroku feature enable you to create SQL queries for your Heroku Postgres databases and share the results with colleagues? What file formats are supported?

Answer: Sharing Query Results with Dataclips

Question: We have an application where we have horizontally scaled our app by adding additional dynos to meet capacity. What Heroku Postgres feature would we use to similarly horizontally scale your Heroku Postgres database?

Answer: Heroku Postgres Follower Databases

Part 9: Release Phase

We improve on the database example, to support migrations, and learn about the Heroku Release Phase along the way.

The final solution for this part is available in the release-phase branch of the larkintuckerllc/hello-cert repository.

Agenda:

  • Motivation
  • Object Relational Mapping
  • TypeORM
  • Local Development
  • Staging Deployment (Release Phase)
  • Production Deployment (Release Phase)

Question: Which Heroku feature enables us to run database migrations during deployment?

Answer: Release Phase

Part 10: Postdeploy in Review Apps

Using database seeding as a use-case, we explore the postdeploy feature in Review Apps.

The final solution for this part is available in the postdeploy branch of the larkintuckerllc/hello-cert repository.

Addendum: In preparing for the next video, realized that I missed handling the situation where finding todos could fail. Fixed it in this branch after the fact.

Agenda:

  • Sidebar: Rotating Credentials
  • Seeding the Database
  • Postdeploy
  • One-Off Dynos

Question: We have an application where we have a database seeding script that we only want to run once the first time we deploy our production application. What Heroku feature enables us to run this database seeding script?

Answer: One-Off Dynos

Part 11: Heroku Redis Basics

We add an in-memory cache (write and read) to our application; both local and Heroku.

The final solution for this part is available in the redis branch of the larkintuckerllc/hello-cert repository.

Agenda:

  • What and Why In-Memory Cache
  • Redis
  • Local Redis
  • Heroku Redis
  • Simple Example

Question: Our application uses an expensive Heroku Postgres query where its underlying data is updated nightly. What technology can we deploy to improve the performance of our application?

Answer: Heroku Redis

Part 12: Heroku Kafka Basics

We add a distributed streaming solution to our application; both local and Heroku.

The final solution for this part is available in the kafka branch of the larkintuckerllc/hello-cert repository.

Agenda:

  • What is Kafka?
  • Local Kafka
  • Heroku Kafka
  • Simple Example, also Worker Dyno

Question: Which Apache Kafka feature can be used to support additional producers and consumers working on a particular topic?

Answer: Apache Kafka on Heroku

Part 13: Salesforce Integration: REST APIs

We use Salesforce REST APIs to regularly synchronize Salesforce contacts to our Heroku application.

The final solution for this part is available in the sfdc-rest branch of the larkintuckerllc/hello-cert repository.

Agenda:

  • Rest APIs Limits
  • OAuth2 Theory
  • Connected Apps
  • Local HTTPS
  • Misc. Code Changes
  • OAuth2 Implementation
  • Using REST API to Synchronize Data
  • Running Code in Heroku
  • Heroku Scheduler

Due to technical difficulties, the there are two videos for this part.

Question: We have a Heroku application we need to integrate with a Salesforce organization where we need to control access to Salesforce data using the user’s Salesforce credentials. What technologies can we use for a solution?

Answer: Integrating Heroku and the Salesforce Platform: Calling the Salesforce REST API

Part 14: Salesforce Integration: Heroku Connect

We use Heroku Connect to regularly synchronize Salesforce contacts to our Heroku application.

The final solution for this part is available in the heroku-connect branch of the larkintuckerllc/hello-cert repository.

Question: We have an Oracle application that we want read-only access to a data in a Salesforce organization. We are looking for a configuration only (no code) solution. What combination of Heroku and Salesforce technologies can we use to enable this?

Answer: Heroku Connect and Heroku External Objects and Salesforce Connect

Part 15: Salesforce Integration: Heroku Connect (Writing)

We use Heroku Connect to bidirectionally update Salesforce contacts and our Heroku application.

The final solution for this part is available in the heroku-connect-writing branch of the larkintuckerllc/hello-cert repository.

Agenda:

  • Theory of External Ids
  • External Ids in Practice
  • Trigger Log
  • External Ids and Relationships
  • Accelerated Polling
  • Flip Flop Issue

Question: Describe what it means for Heroku Connect to be an eventually consistent system with Salesforce.

Answer: Writing Data to Salesforce with Heroku Connect: Techniques to Mitigate Sync Issues

Part 16: The Twelve-Factor App

We draw examples from our example to explore the factors in a Twelve-Factor App.

Agenda:

  • Codebase
  • Dependencies
  • Config
  • Backing services
  • Build, release, run
  • Processes
  • Port binding
  • Concurrency
  • Disposability
  • Dev/prod parity
  • Logs
  • Admin processes

Question: Which of the methodologies from the Twelve-Factor App relates to the Heroku One-Off Dyno feature?

Answer: Twelve-Factor App: Admin Processes

Part 17: Security and Compliance

The materials on security and compliance does not translate well into our concrete example; never-the-less information is important to understand:

Part 18: Collaboration and Enterprise

The materials on collaboration and enterprise does not translate well into our concrete example; never-the-less information is important to understand:

Wrap Up

Ok, believe I touched upon all the key concepts required for the Heroku Architecture Credential.

--

--

John Tucker

Broad infrastructure, development, and soft-skill background