Lk
Lab notes

Case study

The Graviton Migration That Was Supposed to Take Two Weeks

A client wanted to cut their AWS bill by switching to ARM. The first service took a day. The other fourteen took three months. Some dependencies just don't care about your cost projections.

The pitch was clean. Graviton instances cost roughly 20% less than their x86 equivalents for most workloads, and AWS keeps widening the gap. My client — a logistics SaaS company running about fifteen services on ECS — saw the numbers and wanted in. Their CTO estimated two weeks. "It's just a different processor," he said. "Docker abstracts all of that."

He was right about Docker abstracting a lot. He was wrong about the timeline by a factor of six.

The first service went fine

We started with the notification service. It was a small Node.js app: Express, a Postgres connection via pg, some SQS polling. No native dependencies, no binary packages. We changed the ECS task definition to use Graviton, rebuilt the Docker image on an ARM runner, deployed it to staging, and watched it hum along for two days without a single issue.

The team was thrilled. Someone put together a spreadsheet projecting $4,200/month in savings once all fifteen services were migrated. The CTO forwarded it to the CFO. Timelines were promised.

That spreadsheet haunted us for the next three months.

The second service was a different story

The order processing service used Sharp for image manipulation — generating shipping labels with barcodes. Sharp ships prebuilt binaries for most platforms, and it had ARM support. But the Dockerfile was doing something creative:

FROM node:18-alpine
RUN apk add --no-cache vips-dev build-base
COPY package*.json ./
RUN npm ci

That vips-dev package pulled in the Alpine x86 build of libvips, and the prebuilt Sharp binary expected specific shared library versions that didn't match what Alpine's ARM repositories offered at the time. The build failed with a linker error that looked like a corrupted binary.

The fix wasn't hard once we understood the problem — we switched to node:18-slim (Debian-based) where the ARM ecosystem is more mature, and let Sharp use its own bundled libvips. But it took a full day of debugging a misleading error message to get there.

Then the pattern emerged

Every service had its own surprise. The PDF generation service used Puppeteer with a Chromium binary that only shipped for x86. The geocoding service depended on a C++ addon that needed to be compiled from source on ARM, which meant installing build tools in the Docker image, which added 400MB to the image size and tripled the build time.

One service used an npm package that vendored a pre-compiled SQLite binary. Another had a Python sidecar with numpy pinned to a version that predated ARM wheels.

Warning

If your Dockerfile has apk add build-base or apt-get install gcc and you don't know exactly why, that's a service that will not migrate to ARM quietly.

The frustrating part was that none of these were exotic dependencies. Sharp, Puppeteer, SQLite, numpy — these are some of the most popular packages in their ecosystems. But "popular" and "builds cleanly on ARM Alpine Linux" aren't the same thing.

Multi-arch builds sounded like the answer

Someone suggested multi-arch Docker builds using docker buildx. Build once, produce images for both amd64 and arm64. That way we could migrate services at our own pace without maintaining two separate build paths.

It worked, technically. But it doubled our CI build times. Each image now took 8–12 minutes instead of 4–6, because the cross-compilation step for the non-native architecture was significantly slower, even with QEMU emulation. For the services with native dependencies, it was worse — numpy compiled from source under QEMU emulation took 22 minutes.

We tried setting up native ARM runners in our CI pipeline. That helped, but it meant maintaining a second fleet of build agents. The infra team now had twice as many runners to patch and monitor.

The savings math changed

By week five, we had migrated seven of the fifteen services. The monthly savings on those seven came to about $1,800. But we'd also spent:

  • ~160 hours of engineering time across three developers
  • $600/month on additional CI runner costs (ARM build agents)
  • Two days of a senior engineer's time debugging a production issue where an ARM image got deployed to an x86 task definition that hadn't been updated

That production issue was my favorite. The container started, the health check passed, and the service answered HTTP requests. But it ran under QEMU emulation on the x86 host, which meant it was using 3x the CPU and responding 400ms slower than normal. Nobody noticed for six hours because the latency dashboards only showed p50, and the p50 was fine. The p99 told a different story.

What we actually learned

We finished the migration eventually. It took twelve weeks, not two. The final savings landed at about $3,400/month — real money, but a fraction of the engineering cost to get there. It'll pay for itself within a year. Probably.

The real lessons were more mundane than I expected:

Audit native dependencies before you estimate. Run npm ls or pip list and flag anything that ships platform-specific binaries. If you have more than two or three, add a month to your timeline per service.

Don't start with the hardest service, but don't start with the easiest either. We started with notification service, which gave us false confidence. The second service we tried should have been something with moderate complexity — enough to surface the patterns without demoralizing the team.

Pin your base images to digests, not tags. node:18-slim resolves to a different image on ARM than on x86. If you're building multi-arch and something works on one platform but not the other, you want to know the exact image you're building from, not just the tag.

Your CI pipeline is part of the migration. We treated CI as an afterthought and paid for it with weeks of slow builds and flaky cross-platform compilation. The build infrastructure should have been the first thing we migrated.

The CTO still talks about the migration as a success, and honestly, it was. The services run well on Graviton. The cost savings are real. But I think about the gap between "change the instance type" and "actually make everything work on a different architecture," and I keep coming back to the same thought: the Docker abstraction is good enough to make you think this will be easy, and not quite good enough to make it actually easy.

That's the most dangerous kind of abstraction — the one that works until it doesn't, and gives you no warning about which side of that line you're on.