05.2.3 · Skill in Release engineering

Environments

Development, staging and production environments that behave alike.

Environments let changes be tested before they reach users. Differences between them cause surprises in production. Configuration as code and preview environments per change reduce that drift.

Your status · Environments

Saved in this browser. Sign in to keep it on every device.It colours this skill's tile on your map.

Why it matters for a product engineer

Environments let a change be tested before it reaches users. Each difference between them is a place where something works in testing and fails in production. A product engineer who keeps environments alike, and keeps them apart, finds problems earlier and protects real users and real data.

How to do it

  1. Keep development, staging and production as similar as possible: the same database engine, the same queue, the same versions.
  2. Put configuration in the environment, not in the code, and define the environments themselves as code.
  3. Build once, and deploy the same artifact everywhere. Only the configuration changes.
  4. Give each change its own preview environment when you can, so reviewers can try it.
  5. Keep production data and production services out of test environments: separate keys, separate analytics, separate email.
  6. Make the current environment obvious, in the interface and in the terminal.

Common mistakes

  • SQLite in development and PostgreSQL in production.
  • A staging environment that nobody keeps up to date.
  • Test traffic in production analytics, or test emails sent to real users.
  • Copying production data, with personal details, into development.

Example

This site runs in three places: a developer’s machine, a local preview of the built site, and production. The same build runs in all three. Analytics send only from a production build on productengineer.pro, so local, preview and agent runs never reach the real collector. Locally, the API offers a development sign-in, turned on with DEV_LOGIN=1, so nobody needs a real GitHub or Google account to test it.

Side by side

Three gaps between development and production

Traditional appTwelve-factor app
Time between deploysWeeksHours
Who writes and who deploysDifferent peopleThe same people
Dev and production environmentsDivergentAs similar as possible

Environments drift apart through time, people and tools. Frequent deploys by the people who wrote the code keep all three gaps small.

ReportedAdam Wiggins, The twelve-factor app

Sources: Dev/prod parity (The twelve-factor app) ↗

Resources

1
  • articleStart here
    The twelve-factor app ↗
    Adam Wiggins (Heroku) · 30 min

    Twelve short rules for building services that deploy and scale cleanly, still the common baseline.

Tools

1
Tools for Release engineering