Infrastructure Comparisons
Side-by-side trade-offs where neither column wins. The workload, the team and the operational budget decide — and each comparison ends with the verdict that follows from that, not from a preference.
VM vs Container vs ServerlessManaged vs self-hosted databaseObject vs block vs file storageRolling vs blue/green vs canaryActive-passive vs active-activeDeclarative vs imperative infrastructure
Declarative vs imperative infrastructure
Desired state against a sequence of operations. Declarative wins for managing a fleet over time; it is not universally better.
| Dimension | Declarative | Imperative |
|---|---|---|
| You write | What should exist | What to do |
| Repeat runs | Converge — safe to re-run | Re-execute — often not idempotent |
| Drift | Detectable by comparing to state | Invisible |
| Review | A plan you can read before it happens | You read the script and hope |
| Ordering control | Inferred from dependencies | Exactly what you wrote |
| One-off operational task | Awkward | Natural |
| Learning cost | A tool, a language and a state model | A shell you already know |
Use Declarative when
- Infrastructure that lives for years and changes repeatedly.
- Several people change it and changes must be reviewed.
- You need environments to be reproducible.
Use Imperative when
- A one-off migration or investigation.
- An operational runbook step.
- Bootstrapping before any state exists.
Verdict
Declarative for anything that persists, imperative for anything that happens once. The mistake is a shell script that provisions the fleet — and the opposite mistake is a module that wraps one resource in twenty variables.