interviewpath
  • 0day streak
  • 10total XP
  • Level 1
0/6

Unit 5 · Distributed & cloud · Lesson 10 of 14

Platform engineering, infrastructure as code and safe migrations

Platform engineering turns infrastructure, delivery and operations into self-service products for other engineers. Declarative infrastructure as code, CI/CD with progressive rollout, default observability and safe migration patterns (expand and contract, backfills, avoiding unsafe dual writes) make change routine instead of risky.
About 4 hFocus mode

Step 1: Learn the ideas

  • Platforms as internal products and golden paths
  • Declarative infrastructure as code: desired state, state, plan and apply
  • Drift detection and remediation
  • Immutable infrastructure and pull-based reconciliation
  • CI/CD stages, artifact promotion and environment parity
  • Progressive delivery: canaries, feature flags, automated rollback
  • Observability defaults: metrics, logs, traces
  • Expand and contract (parallel change)
  • Dual writes, backfills and verification
  • Rollback safety and two-phase deployment of format changes

Why it matters

As systems grow, the bottleneck moves from writing code to changing production safely: provisioning, deploying, migrating data and seeing what happened. Platform teams build the paved road that makes the safe way the easy way. Infrastructure roles probe this directly, and senior candidates in any backend or distributed role are expected to explain how a risky change (a schema change, a storage migration) reaches production without downtime.

Core ideas

Platforms as products. A platform offers self-service capabilities (compute, databases, queues, pipelines, observability) behind stable interfaces, with sensible defaults and guardrails. Success means product teams adopt it and ship faster with fewer incidents, not that it bundles many tools.

Declarative infrastructure as code. You describe the desired end state and a tool computes and applies the difference. With a plan step, the tool compares your configuration with its recorded state, refreshed against the real infrastructure, and shows the intended changes. Review plans before applying: a renamed resource can appear as destroy-and-recreate.

Drift is any difference between declared and real state, usually from manual changes or other tools. Detect it with scheduled plans or continuous reconciliation, then either re-apply the declaration or update the code to capture a deliberate change. Pull-based (GitOps-style) systems run a controller that keeps reconciling the environment toward a version-controlled declaration, the same loop Kubernetes controllers run.

Delivery pipelines. Build once, test, and promote the same artifact through environments. Release progressively: send a canary slice of traffic to the new version, compare its errors and latency with a baseline, widen in steps, and roll back automatically when the comparison fails. Feature flags separate deploying code from releasing behavior, so behavior can be turned off without a redeploy.

Observability by default. Every service on the platform should get request metrics (rate, errors, latency distributions), structured logs carrying request IDs, distributed traces and SLO dashboards without extra work. Adding them during an incident is too late.

Safe migrations: expand and contract. Split a backward-incompatible change into compatible steps:

  1. Expand: add the new column, table or field; remove nothing.
  2. Write both old and new (dual write), still reading the old.
  3. Backfill historical data in small, throttled, idempotent, resumable batches.
  4. Verify by comparing old and new (shadow reads, checksums), then switch reads.
  5. Stop writing the old path, then contract: remove it. Every step must work with both the previous and the next code version, so you can roll back at any point.

Dual writes are a risk to manage. Writing two stores from application code is not atomic: a crash between the writes leaves them inconsistent, and concurrent updates can land in different orders. Prefer one source of truth plus change data capture or an outbox, and in every case run a verification job with a repair path. Data-format changes need two-phase deployment too: first ship code that can read the new format everywhere, then enable writing it, so a rollback never meets data it cannot parse.

Common misconceptions

  • "Infrastructure as code means scripts in version control." The value lies in declarative desired state, reviewable plans and reconciliation, not in storing imperative scripts.
  • "Drift is harmless if things work." Undeclared changes vanish or conflict on the next apply and make incidents harder to reason about.
  • "A migration is one deploy plus a script." Zero-downtime changes take several deploys, each compatible with its neighbors, plus a verified backfill.
  • "Dual writes keep two stores in sync." Without atomicity or reconciliation they drift apart; build detection and repair.
  • "A clean canary proves the release is safe." It shows the slice was fine for that traffic and duration; compare against a baseline and watch for delayed effects such as data-format problems.

How to approach it

Read the CNCF platforms paper for vocabulary, then do the Terraform Docker tutorial and create drift on purpose. Read the Stripe online-migrations post, which walks through dual writes, a backfill and a verified read switch, and write the step list for a migration you might face, such as splitting a contacts table into person and company records. Graduates should know CI/CD and why migrations need care. Mid-level candidates should plan an expand-and-contract migration and a canary rollout. Senior candidates should design the platform interface, its guardrails, and the verification and rollback plan for a large migration.

Suggested order

  1. 1Read the CNCF Platforms White Paper for capabilities, platform-as-product thinking and measures of success.
  2. 2Read the Terraform core workflow page and the plan command reference, then do the Docker tutorial and introduce drift by hand.
  3. 3Read SRE book Ch. 8 (Release Engineering) and Workbook Ch. 16 (Canarying Releases) for builds, artifact promotion and canary analysis.
  4. 4Read "Online migrations at scale"; write a five-step expand-and-contract plan for a schema change of your choice with a rollback point per step.
  5. 5Apply two-phase deployment to a serialization-format change: state which release starts reading the new format, which starts writing it, and why rollback stays safe at each point.
  6. 6List the default telemetry your ideal platform gives every service and the alerts it derives from SLOs.

Step 2: Check off what you can do

Tap each one you can genuinely do or explain. Each earns 10 XP.

Step 3: Go deeper

  • CNCF Platforms White PaperStart here

    CNCF TAG App Delivery

    Vocabulary and principles for internal platforms built as products.

    Open(opens in a new tab)Link responded, 5 Oct 2026
  • Terraform documentation: core workflow, plan and driftStart here

    HashiCorp Developer

    Write, plan and apply workflow, state and drift handling in a declarative tool.

    Open(opens in a new tab)Link responded, 5 Oct 2026
  • Site Reliability Engineering (Google SRE book)

    Google (free online edition)

    Section: Ch. 8: Release Engineering

    Hermetic builds, artifact promotion and configuration management in a release pipeline.

    Open(opens in a new tab)Link responded, 5 Oct 2026
  • The Site Reliability Workbook

    Google (free online edition)

    Section: Ch. 16: Canarying Releases

    Designing canaries: traffic slices, baseline comparison, metric selection and automated rollback.

    Open(opens in a new tab)Link responded, 5 Oct 2026
  • Online migrations at scale

    Stripe Engineering Blog

    A worked online migration with dual writes, backfill, verification and cleanup.

    Open(opens in a new tab)Link responded, 5 Oct 2026

Step 4: Practice

Do the Terraform Docker exercise, change the running container by hand, and read the next plan; decide whether to re-apply or update the code. Then write a migration runbook for a realistic change (renaming a heavily used column, or moving a table to a new store): for each step, the code version deployed, the verification query, the rollback action and the metric that tells you to stop. A day later, re-read it looking for a step that cannot be rolled back.

Record attempts on each problem’s page (+15 XP, +10 more when solved on your own).

Step 5: Test yourself

Answer each one out loud or on paper before you finish the lesson.

  1. Question 1What does a plan compare, and what does each kind of difference mean?
  2. Question 2Why must each migration step be compatible with both the previous and the next code version?
  3. Question 3How do you make a backfill safe to stop and restart?
  4. Question 4What is the difference between deploying and releasing?
  5. Question 5What would a platform team measure to know it is succeeding?
  6. Question 6When would you prefer change data capture over application dual writes?

You’re done when you can

  • Explain plan, apply and drift with a concrete example in under two minutes.
  • Write an expand-and-contract plan for an unseen schema change with a rollback point at every step.
  • Explain why application-level dual writes diverge and give two ways to avoid or detect divergence.
  • Describe a canary rollout with the metrics compared and the automatic rollback condition.

Finish the lesson

How confident do you feel?

Lesson complete!

+50 XP

Reviews will come up on the Practice tab so it sticks.

Your notes and study time

Log study time