Chapter 19

Escaping the Golden Cage: From AWS to Bare Metal

Subhash Choudhary · 8 min read

We had done it. We had built our masterpiece on the best foundation we could find: Amazon Web Services. The cloud had given us the power to deploy servers around the world with a few clicks, to build a global database network, and to scale to incredible heights. We were living in a golden age of engineering, powered by the seemingly infinite resources of the cloud.

But we soon discovered that our beautiful home was, in fact, a golden cage. It gave us comfort, power, and speed, but it came at a staggering price and kept us locked into a system where we didn't have ultimate control. This is the story of our daring escape.

Part 1: The $80,000 Phone Call

The call came at the end of the month. It was Suumit. He wasn't angry or panicked. His voice just had a flat tone of pure, unadulterated shock.

"Subhash," he said, "the AWS bill just came in. It's eighty thousand dollars."

I stopped what I was doing. "Eighty thousand? For the month?"

"For one month," he confirmed. "Eighty thousand US dollars."

I pulled up our AWS Cost Explorer dashboard. He was right. The graph of our monthly spending wasn't a gentle slope; it was a rocket launch, mirroring the growth of our user base. Our success was literally costing us a fortune, and our profitability was evaporating into the cloud.

We dug into the line items. The culprits were everywhere. We were paying for:

At every layer of our stack, we were paying a "convenience tax." We were paying AWS for the privilege of not having to manage the underlying hardware. In the early days, this tax was worth it. It allowed us to move incredibly fast. But now, that convenience was threatening to bankrupt us. We were trapped in the golden cage.

Technical Deep Dive: The Economics of Infrastructure

That $80,000 bill forced us to have a long, hard conversation about the fundamental economics of our infrastructure. We had to analyze the trade-offs between the two primary ways of running an internet company: in the Cloud or on Bare Metal.

Concept: The Cloud vs. Bare Metal Trade-off

1. The Public Cloud (AWS, Google Cloud, Azure)

2. Bare Metal (Self-Hosted)

In the beginning, renting the fancy AWS apartment was absolutely the right decision. It gave us the speed we needed to find product-market fit and build our global network. But now our architecture was stable, our workload was predictable, and the rent was simply too high.

We made the bold, terrifying decision to move out. It was time to buy our own land and build our own houses across the globe. It was time to migrate Dukaan to bare metal.

Part 2: The Great Migration

The decision was made. We were leaving the golden cage of AWS. But this presented a terrifying new challenge: how do you move your entire global, live production system, serving millions of users, from one provider to another without a single second of downtime?

You can't just turn off the old system and turn on the new one. That would be a planned outage, and in our business, that's unacceptable. We had to perform the ultimate high-wire act: rebuilding our entire infrastructure on a new foundation and seamlessly shifting the traffic over while the show was still in full progress.

Our Secret Weapon: The Anycast IP

This entire zero-downtime migration was only possible because of one crucial decision we had made months earlier: we owned our own IP address space.

Because our Anycast IP belonged to Dukaan and not to AWS, we had ultimate control over where on the internet it was announced from. We weren't tied to AWS's network. This IP address was our permanent, portable address on the internet. We could move house, but our address would stay the same. This was the key that unlocked our ability to migrate without our users ever knowing.

The Strategy: The Strangler Fig on a Global Scale

We decided to apply the same Strangler Fig Pattern we used to break apart our monolith, but this time on a global, infrastructural scale.

This gradual, controlled migration was the only way to do it safely.

Technical Deep Dive: The Migration Playbook

Step 1: Build the New Foundation

First, we had to build our new houses. We chose a bare-metal provider, Hetzner, known for its powerful servers and affordable pricing. We rented physical servers in data centers that were geographically close to our existing AWS regions (for example, a data center in Helsinki, Finland, to replace our AWS cluster in Frankfurt, Germany).

This is where the "operational overhead" we talked about became very real. We didn't get a nice AWS dashboard. We got a root password to a bare-metal Linux server. We were responsible for everything:

We used tools like k3s, a lightweight but powerful Kubernetes distribution, to make this process easier. But it was still a massive undertaking. We had to become experts not just in our application, but in the low-level infrastructure it ran on. Over several weeks, we painstakingly built and tested our new, self-hosted Kubernetes clusters in nine new data centers around the world.

Step 2: The Gradual Traffic Shift

This was the most critical and delicate phase of the migration. Let's take our European traffic as an example.

The AWS cluster in Frankfurt was now completely idle, receiving no traffic at all. It was an empty, expensive apartment.

Step 3: Decommission and Repeat

With the traffic fully migrated, we could safely log into the AWS console and terminate every single server, database, and load balancer in our Frankfurt region. The first room of the golden cage was dismantled.

We then repeated this incredibly careful and deliberate process, region by region, over the next two months, until our entire global application was running on our own self-hosted, bare-metal infrastructure.