Heroku
02 / 02

Add-ons, Pipelines & Production Tips

Heroku: Add-ons, Pipelines & Production Tips

Add-ons

Add-ons are third-party services provisioned and billed through Heroku. They automatically set config vars in your app.

# Common add-ons
heroku addons:create heroku-postgresql:essential-0   # PostgreSQL
heroku addons:create heroku-redis:mini               # Redis
heroku addons:create papertrail:choklad              # Log management
heroku addons:create sendgrid:starter                # Email
heroku addons:create scheduler:standard              # Cron jobs
heroku addons:create newrelic:wayne                  # APM monitoring

# List installed add-ons
heroku addons

# Open add-on dashboard
heroku addons:open heroku-postgresql

Heroku Scheduler

  • Add-on for running jobs on a schedule (like cron) — free tier available

  • Intervals: every 10 minutes, every hour, every day at a specific UTC time

  • Configure via: heroku addons:open scheduler

  • Each job runs in a one-off dyno — charged for dyno time

  • Not reliable for precise timing — may run ±1 minute from scheduled time

  • For precise cron, use a worker dyno with node-cron or APScheduler (Python)

Review Apps & Pipelines

Heroku Pipelines provide staging environments and automated review apps for pull requests.

# Pipeline stages: development → staging → production
heroku pipelines:create my-pipeline --app my-app-staging --stage staging

# Promote from staging to production (no rebuild — same slug)
heroku pipelines:promote --app my-app-staging

# Review Apps: auto-created per PR (configure in Dashboard → Review Apps)
# - Spun up when PR opens, destroyed when PR closes
# - Shares config from staging (with overrides in app.json)

# app.json — configures review apps
cat app.json
{
  "name": "My App",
  "description": "Review app config",
  "env": {
    "NODE_ENV": { "value": "staging" },
    "FEATURE_FLAGS": { "value": "all" }
  },
  "formation": {
    "web": { "quantity": 1, "size": "standard-1x" }
  },
  "scripts": {
    "postdeploy": "npx prisma migrate deploy && node scripts/seed.js"
  },
  "addons": ["heroku-postgresql:essential-0"]
}

Production Best Practices

  • Use release phase for migrations: release: npx prisma migrate deploy — ensures migration runs before traffic shifts

  • Health check endpoint: Heroku checks / by default; return 200 quickly or configure in Dashboard

  • Preboot: enable in Settings → enable preboot — starts new dynos before killing old ones (zero-downtime deploy)

  • Log drains: stream logs to Datadog, Papertrail, Loggly — heroku logs only keeps 1500 lines

  • SSL: automatically provisioned for *.herokuapp.com and custom domains (ACM)

  • Metrics: Dashboard → Metrics shows response time, throughput, memory, errors per dyno

  • Memory limits: if dyno exceeds RAM limit, it's "swapped" → R14 error → R15 = killed. Monitor with heroku ps

Alternatives Worth Knowing

  • Railway: closest Heroku replacement, Postgres included, generous free tier, similar DX

  • Render: free tier with auto-sleep, good for hobby projects, native Docker support

  • Fly.io: more control, runs Docker containers globally, good for latency-sensitive apps

  • Vercel / Netlify: better for Next.js/frontend — serverless functions, not persistent servers

  • AWS Elastic Beanstalk: Heroku-like PaaS on AWS infrastructure, more configuration needed

Keep your own version of these notes — editable, searchable, and organised by your stack.

Start free