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
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.
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.
Pick how dependencies are found, the strategy for the wave, and whether optimisation is part of it.
Three questions. No score is saved anywhere — this is just you against the material.
Migrations grow in four levels: reading an inventory, planning an application, running a wave, and running the programme.
At the basic level you can describe what an application is made of and who owns it.
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.
At the intermediate level you plan one application's migration end to end.
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.
At the advanced level you move a group of dependent applications together.
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.
At the master level the migration is a programme with a factory.
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.
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
This is a composite of a failure pattern that keeps repeating; the details are illustrative. The transfer nobody listed.
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.
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.
Type each one, read what it prints, and compare it with the note above it.
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 -15List 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
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}'waves.pyThis 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
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
New to a feature used above? These W3Schools pages explain each one from zero, with examples you can run in the browser.
awk, sort, uniq, head, free, ls, Pipes, Redirection.A company must leave its data centre in 18 months, with 320 applications on 1,400 servers. Design the migration programme.
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?
Say 320 applications, 1,400 servers, 60 databases, 800 TB of files, a 10 Gbit/s link, and a team of 25.
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.
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.
Each row is one way this system went wrong in the diagram's scenarios. The hop number is where to look first.
| Scenario | Where | Effect | What goes wrong |
|---|---|---|---|
| Missed dependency | Hop 2: Dependency mapping | Breaks | Dependencies 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 nothing | Hop 9: Optimisation | Breaks | Every 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. |
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.
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.