Platform Engineering · Lesson 164

Cloud Migrations: Discovery, the 7 Rs, Waves, and Cutover

Moving hundreds of applications to the cloud is a programme, not a lift. It starts with discovery (what runs, what it talks to, who owns it), chooses a strategy per application from the 7 Rs (retire, retain, rehost, relocate, replatform, repurchase, refactor), groups dependent applications into waves, moves data with replication so cutover is minutes, not days, and keeps a rollback plan until the new home has proved itself. This lesson follows one application group through a wave, and shows the two classic failures: an undiscovered dependency that broke on cutover night, and a "lift and shift" that cost more in the cloud than it did on premises.

Difficulty: Advanced · Know this first: Lesson 163, Lesson 157

What you will learn

By the end of this lesson you can work at four levels:

This page teaches it with a plain-language analogy, an animated diagram with normal and failure scenarios, a simulator, a quiz, basic, intermediate, advanced, and master checks, the expert detail ("Go deeper"), a production incident, a hands-on lab with commands and their output, and a production design exercise.

Run it as:

When it breaks, I check

One thing to remember

Where the time goes

This bar adds up hours of team effort for one migration wave. It is a worked example, not a measurement. The dependency mapping and optimisation hops are where migrations go over time or over budget.

Try it: plan the wave

Pick how dependencies are found, the strategy for the wave, and whether optimisation is part of it.

10weeks for the wave
0.82×monthly cost vs business case
lowcutover risk

Check yourself

Three questions. No score is saved anywhere — this is just you against the material.

Basic to master

Migrations grow in four levels: reading an inventory, planning an application, running a wave, and running the programme.

Basic — Read the inventory

At the basic level you can describe what an application is made of and who owns it.

  • Servers, databases, storage, utilisation, licences, owners, criticality.
  • Dependencies: inbound and outbound connections.
  • The 7 Rs and what each means.

Where it breaks: sizing from allocated CPUs instead of used CPUs.

Try it: Basic

A server has 32 vCPUs allocated and averages 6% CPU with peaks of 20%. How do you size it in the cloud?

Now do it: Compare allocation and peak use for one of your servers.

Intermediate — Plan an application

At the intermediate level you plan one application's migration end to end.

  • Strategy and reason; target architecture in the landing zone.
  • Data replication method and validation; test plan per dependency.
  • Cutover runbook with go/no-go points; rollback plan and window.

Try it: Intermediate

What should a go/no-go point check before switching DNS?

Now do it: Write the go/no-go list for one cutover.

Advanced — Run a wave

At the advanced level you move a group of dependent applications together.

  • Waves built from the dependency graph and business calendar.
  • Hybrid connectivity sized for replication and remaining dependencies.
  • Rehearsals, cutover, rollback window, and optimisation with owners and dates.

Try it: Advanced

Two applications talk thousands of times a second. How do you schedule them?

Now do it: Find the chattiest pair in your estate.

Master — Run the programme

At the master level the migration is a programme with a factory.

  • A migration factory: repeatable tooling, runbooks, and teams per strategy.
  • Business case tracked per wave: cost, data-centre exit dates, risk.
  • Modernisation after migration planned, not hoped for.

Trade-off: rehosting meets exit dates and defers modernisation; refactoring gets the most from the cloud and takes the longest; most programmes rehost the long tail and replatform or refactor the few that matter most.

Try it: Master

The data-centre lease ends in 14 months and there are 400 applications. What is a realistic approach?

Now do it: Sort your applications into the 7 Rs.

Go deeper

Tools for each stage, by provider (check current names and capabilities):

A cutover runbook skeleton:

T-7 days   lower DNS TTLs to 60 s; freeze changes to the wave's apps; confirm rollback owner
T-1 day    rehearsal sign-off; replication lag under 10 s; checksums match; on-call confirmed
T-0 00:00  announce start; stop writes at source (maintenance page)
T-0 00:05  wait for replication lag 0; final row counts and checksums           GO / NO-GO 1
T-0 00:15  promote target database; switch application config; start services
T-0 00:25  switch DNS / load balancer; smoke tests; business transaction test    GO / NO-GO 2
T-0 00:40  open traffic; watch error rate, latency, business metrics for 2 h
T+1..14 d  reverse replication on; rollback possible until T+14 d; then decommission

A quick way to see what a server talks to before you move it (run on the server; read-only):

ss -tnp state established | awk 'NR>1 {print $4, $5}' | sort | uniq -c | sort -rn | head -20
sudo crontab -l; ls /etc/cron.d/         # scheduled jobs: the usual hidden dependencies

One time it broke

This is a composite of a failure pattern that keeps repeating; the details are illustrative. The transfer nobody listed.

Timeline

  • Saturday 00:00The order management wave cuts over in 45 minutes. Smoke tests and business checks pass.
  • Sunday 02:00A mainframe job tries to push the day's pricing file by SFTP to the old file server's IP. The server is shut down; the job logs an error nobody watches.
  • Monday 09:00Invoices are not generated: the order app is waiting for pricing data. Finance escalates.
  • Monday 21:00The wave is rolled back using reverse replication, with no data lost. Flow logs are collected for a month and the wave rescheduled.

What changed after

Every wave's dependencies come from at least 30 days of observed traffic (covering month-end), scheduled jobs on every server are listed, the file transfer moved to a managed SFTP endpoint, and cutover runbooks include a "first night" checklist of batch jobs.

Try it yourself, from scratch

Everything here runs on any Linux machine: your own laptop, WSL on Windows (run wsl --install in PowerShell once), or a small cloud VM. The Python needs only Python 3 and its standard library; check that you have it with python3 --version.

Before you start: Any Linux server you are allowed to inspect (or your own machine) for the discovery steps, and Python 3. Everything here is read-only.

1. Linux commands

Type each one, read what it prints, and compare it with the note above it.

  1. List established connections by remote address and port: the raw material of a dependency map.

    ss -tn state established | awk 'NR>1 {split($4,r,":"); print r[1]":"r[2]}' | sort | uniq -c | sort -rn | head -15

    Options: -t TCP, -n numbers; $4 is the peer address in this state-filtered output.

    Expect: Counts per remote address and port: databases, APIs, file servers this machine talks to right now. Repeat over weeks to catch nightly and monthly jobs. Read-only.

  2. List scheduled jobs, the usual hidden dependencies.

    crontab -l 2>/dev/null; ls /etc/cron.d/ 2>/dev/null; systemctl list-timers --all --no-pager | head -15

    Expect: User crontabs, system cron files, and systemd timers: each one may push or pull data somewhere. Read-only.

  3. Measure real utilisation for sizing: CPU and memory over a minute.

    vmstat 5 12 | awk 'NR>2 {cpu+=100-$15; n++} END {printf "average CPU busy %.0f%%\n", cpu/n}'
    free -m | awk '/Mem:/ {printf "memory used %d of %d MiB\n", $3, $2}'

    Options: vmstat 5 12 samples every 5 seconds, 12 times; column 15 is idle CPU.

    Expect: A CPU percentage and memory use; collect them for weeks and size from the peaks, not from the allocation. Read-only.

2. Python: waves.py

This program plans migration waves. It builds a dependency graph from observed connections, groups applications that must move together, picks a strategy per application, and sizes rehosted servers from measured peak use instead of their allocation. It also flags a dependency that is in the observed traffic but not in the CMDB. Save it as waves.py, then run it.

# waves.py
import math

OBSERVED = [("orders", "pricing-db"), ("orders", "invoicing"), ("invoicing", "pricing-db"),
            ("mainframe", "orders-fileshare"), ("orders", "orders-fileshare"),
            ("hr-portal", "hr-db"), ("reports", "orders"), ("wiki", "wiki-db")]
CMDB = {("orders", "pricing-db"), ("orders", "invoicing"), ("invoicing", "pricing-db"),
        ("orders", "orders-fileshare"), ("hr-portal", "hr-db"), ("reports", "orders"), ("wiki", "wiki-db")}
STAYS = {"mainframe"}                         # not migrating: its links must keep working over the hybrid link
STRATEGY = {"orders": "replatform", "invoicing": "rehost", "pricing-db": "replatform (managed PostgreSQL)",
            "orders-fileshare": "replatform (managed SFTP + object storage)", "reports": "repurchase (SaaS BI)",
            "hr-portal": "rehost", "hr-db": "rehost", "wiki": "retire", "wiki-db": "retire"}

for a, b in OBSERVED:
    if (a, b) not in CMDB:
        print(f"not in the CMDB: {a} -> {b}" + ("  (stays on premises: keep this link working)" if a in STAYS or b in STAYS else ""))

parent = {}
def find(x):
    parent.setdefault(x, x)
    while parent[x] != x:
        x = parent[x]
    return x
for a, b in OBSERVED:
    if a not in STAYS and b not in STAYS:
        parent[find(a)] = find(b)
groups = {}
for app in STRATEGY:
    groups.setdefault(find(app), []).append(app)
print()
for i, members in enumerate(sorted(groups.values(), key=len, reverse=True), 1):
    print(f"wave {i}: " + ", ".join(f"{m} [{STRATEGY[m]}]" for m in sorted(members)))

print()
SERVERS = {"invoicing-app1": (16, 0.18), "hr-portal-web": (8, 0.35), "hr-db": (32, 0.22)}   # vCPUs, peak use
for name, (vcpus, peak) in SERVERS.items():
    needed = vcpus * peak / 0.6                                  # aim for 60% at peak
    size = 2 ** math.ceil(math.log2(max(2, needed)))
    print(f"{name:<15} allocated {vcpus:>2} vCPUs, peak {peak:.0%}: rehost on {size:>2} vCPUs")

Run it, and you should see this output:

$ python3 waves.py
not in the CMDB: mainframe -> orders-fileshare  (stays on premises: keep this link working)

wave 1: invoicing [rehost], orders [replatform], orders-fileshare [replatform (managed SFTP + object storage)], pricing-db [replatform (managed PostgreSQL)], reports [repurchase (SaaS BI)]
wave 2: hr-db [rehost], hr-portal [rehost]
wave 3: wiki [retire], wiki-db [retire]

invoicing-app1  allocated 16 vCPUs, peak 18%: rehost on  8 vCPUs
hr-portal-web   allocated  8 vCPUs, peak 35%: rehost on  8 vCPUs
hr-db           allocated 32 vCPUs, peak 22%: rehost on 16 vCPUs

3. What to notice

4. Advanced: every step as one Bash script

The same Linux steps, made into a real script you can keep and run again. It uses the Bash features a production script needs: functions (one per step), an array of step names, arguments to choose steps, a case for options, exit codes recorded for each step, and a trap that prints a summary even when you stop it with Ctrl+C. Make a folder for this lesson (mkdir -p ~/labs/cloud-migrations && cd ~/labs/cloud-migrations) and save this as lab.sh.

#!/usr/bin/env bash
# The Linux steps of "Cloud Migrations: Discovery, the 7 Rs, Waves, and Cutover", as one script (save it as lab.sh).
#
#   ./lab.sh          run every step, in order
#   ./lab.sh 2 4      run only steps 2 and 4
#   ./lab.sh --list   list the steps
#
# The steps share one shell, so a later step can use what an earlier one set up (a folder,
# a variable, a container): run them all in order the first time. Your own scripts should
# start with "set -euo pipefail"; this one runs teaching commands, and some of them fail on
# purpose, so it records each step's exit code instead of stopping at the first failure.

STEPS=(
  'List established connections by remote address and port: the raw material of a dependency map.'
  'List scheduled jobs, the usual hidden dependencies.'
  'Measure real utilisation for sizing: CPU and memory over a minute.'
)

step_1() {
ss -tn state established | awk 'NR>1 {split($4,r,":"); print r[1]":"r[2]}' | sort | uniq -c | sort -rn | head -15
}

step_2() {
crontab -l 2>/dev/null; ls /etc/cron.d/ 2>/dev/null; systemctl list-timers --all --no-pager | head -15
}

step_3() {
vmstat 5 12 | awk 'NR>2 {cpu+=100-$15; n++} END {printf "average CPU busy %.0f%%\n", cpu/n}'
free -m | awk '/Mem:/ {printf "memory used %d of %d MiB\n", $3, $2}'
}

# print a step that has to be run by hand, instead of running it
by_hand() {
  echo "  (run this one yourself: $1)"
  sed 's/^/    /'
}

RESULTS=()
run_step() {
  local n=$1 start=$SECONDS code
  printf '\n== step %d of %d: %s\n' "$n" "${#STEPS[@]}" "${STEPS[n-1]}"
  "step_$n"
  code=$?
  RESULTS+=("step $n: exit code $code, $((SECONDS - start)) s")
}

summary() {
  echo
  echo "== summary"
  local r
  for r in "${RESULTS[@]}"; do echo "  $r"; done
}

case "${1:-}" in
  -h|--help) sed -n '2,6p' "$0"; exit 0 ;;
  --list) for i in "${!STEPS[@]}"; do echo "$((i + 1)). ${STEPS[i]}"; done; exit 0 ;;
esac

[ $# -eq 0 ] && set -- $(seq 1 "${#STEPS[@]}")
for n in "$@"; do
  if ! [[ $n =~ ^[0-9]+$ ]] || (( n < 1 || n > ${#STEPS[@]} )); then
    echo "there is no step '$n'; try --list" >&2
    exit 2
  fi
done
trap summary EXIT
trap 'echo; echo "stopped with Ctrl+C"; exit 130' INT
for n in "$@"; do run_step "$n"; done

Then make it executable and run it:

chmod +x lab.sh
./lab.sh --list     # the steps
./lab.sh            # every step, then a summary of exit codes and times
./lab.sh 2 3        # only steps 2 and 3

5. Learn the basics behind it

New to a feature used above? These W3Schools pages explain each one from zero, with examples you can run in the browser.

If you remember nothing else

Design exercise

A company must leave its data centre in 18 months, with 320 applications on 1,400 servers. Design the migration programme.

Clarifying questions to ask

How do you discover and assess? How do you choose the strategy for each application? How are waves formed and scheduled? How is data moved and validated? What does every cutover runbook contain? How is cost kept within the business case?

Rough sizing

Say 320 applications, 1,400 servers, 60 databases, 800 TB of files, a 10 Gbit/s link, and a team of 25.

Shape of the answer

Agentless discovery plus flow collection for 60 days; owners for every application; strategy decided with owners (about 15% retire, 50% rehost or relocate, 30% replatform, 5% refactor); waves of related applications scheduled around business calendars; landing zone and hybrid link first; CDC for databases, block replication for rehosts, offline devices for the largest file sets; a migration factory with runbook templates, rehearsals, go/no-go criteria, and a 14-day rollback window; rightsizing and commitments within four weeks of each wave; cost against the business case reported monthly.

Trade-offs to name

Rehosting most of the estate meets the deadline and carries old inefficiencies into the cloud; a factory adds process and makes 320 moves predictable; long rollback windows keep two environments running and paid for.

Failure modes and how to troubleshoot them

Each row is one way this system went wrong in the diagram's scenarios. The hop number is where to look first.

ScenarioWhereEffectWhat goes wrong
Missed dependencyHop 2: Dependency mappingBreaksDependencies come from the CMDB and interviews. A nightly file transfer from an on-premises mainframe to the order application's file share is not in either. After cutover the transfer fails silently; invoices are not generated the next day.
Lift and shift, then nothingHop 9: OptimisationBreaksEvery VM was rehosted at its on-premises allocation: large instances sized for peaks of years ago, Windows and database licences included, running all day, with non-production never switched off. The bill is 2.3 times the business case.

How to troubleshoot

  1. Write down the symptom and when it started: what users see, which number moved, and what changed just before (a deploy, a config change, traffic).
  2. Walk the path in order, from the first hop to the last: Discovery → Dependency mapping → The 7 Rs → Landing zone → Data replication → Testing → Cutover → Rollback → Optimisation. The first hop whose evidence is wrong is where to dig.
  3. At that hop, run the read-only check from the diagram or the lab first; change nothing until the evidence points at a cause.
  4. Fix the smallest thing that restores service, or roll back the last change, and confirm the symptom is gone with the same check.
  5. Write down what you found and the check that would have caught it sooner, so the next person starts there.

Architecture review checklist

Review the design in this lesson, or your own, against these ten areas. Tick an area when you can answer its question with evidence: a number, a test, a document, or an owner. Your ticks stay in this browser.

  1. Business outcomeWhich result for users or the business does this design serve, and which number shows it is working?
  2. SecurityWho and what can reach each part, how is identity proven, and how is data protected in transit and at rest?
  3. ReliabilityWhat is the target (SLO), which single failures does the design survive, and how was that tested?
  4. PerformanceWhat latency and throughput are required at peak, and where is the first bottleneck?
  5. OperationsHow is it deployed, observed, and changed safely, and who is paged when it breaks?
  6. CostWhat does it cost per month and per unit of work (request, tenant, model call), and what grows the bill?
  7. SustainabilityWhich resources sit idle, which region and hardware does it run on, and what can scale to zero?
  8. GovernanceWhich policies, guardrails, and compliance rules apply, and how are they enforced in code?
  9. OwnershipWhich team owns each component, its budget, and its on-call, and where is that written down?
  10. Failure and recovery planWhat is the RTO and RPO, what is the runbook for a region or dependency loss, and when was it last rehearsed?

References and review

The official documentation and standards behind this lesson. Versions and defaults change; when a command or field here differs from them, trust the official page.

Last updated . Next review due by November 2027. Found something out of date? Tell me.

Saved on this device, in this browser.
Next in this series · Lesson 165
Sustainability Engineering: Measuring and Cutting the Carbon of Software

Software uses electricity, and electricity has a carbon cost that depends on how much energy you use, where (each grid has its own carbon intensity), and when (grids are cleaner when the wind blows and the sun shines).

Go to Lesson 165 →

Or browse the full course from the Lessons index.