Dukaan Cuts Monthly Cloud Costs from $80,000 to $5,000 by Migrating to Bare Metal Servers

In a bold move that has captured the attention of the tech community, Dukaan, an Indian e-commerce startup, has successfully transitioned from cloud services to bare metal servers, drastically reducing its monthly operational costs from an astonishing $80,000 to a mere $5,000. This strategic shift not only highlights the potential for significant cost savings in the tech industry but also underscores the importance of adaptability and innovation in the face of financial pressures.

Subhash Choudhary, the co-founder and Chief Technology Officer (CTO) of Dukaan, shared insights into this transformative journey in his recently published book, “The Accidental CTO.” The narrative reveals how the company navigated the complexities of cloud computing and ultimately opted for a more sustainable and cost-effective infrastructure solution.

### The Cloud Conundrum

Dukaan’s initial reliance on Amazon Web Services (AWS) was driven by the need for speed, scalability, and ease of maintenance. In the early stages of the startup, the convenience offered by AWS allowed Dukaan to focus on rapid development and deployment without the burden of managing physical hardware. However, as the company grew, so did its expenses. The monthly bill from AWS ballooned to $80,000, a figure that began to threaten the financial viability of the startup.

Choudhary describes this phenomenon as a “convenience tax,” where the benefits of using cloud services came at a steep price. While AWS provided powerful resources and the ability to scale quickly, the costs associated with these conveniences became unsustainable. “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,” he noted.

### The Decision to Migrate

Faced with mounting costs, Dukaan’s leadership team recognized the urgent need to reassess their infrastructure strategy. The decision to migrate to bare metal servers was not made lightly; it involved careful consideration of the technical, operational, and financial implications. Choudhary emphasized that the potential savings were staggering—bare metal solutions could offer 10 to 20 times more value for the same resources compared to cloud alternatives.

The transition was not merely about cutting costs; it was also about regaining control over their infrastructure. By moving to bare metal, Dukaan aimed to eliminate the ongoing expenses associated with cloud services while also enhancing their operational efficiency. The goal was clear: to create a robust, self-managed infrastructure that would support the company’s growth without the financial strain of cloud dependency.

### The Migration Strategy: Strangler Fig Pattern

To execute this ambitious migration, Dukaan employed a strategy known as the “Strangler Fig Pattern.” This approach involves gradually replacing a legacy system with a new one, allowing for a seamless transition without downtime. Choudhary explained that this method enabled Dukaan to shift traffic from AWS to their self-hosted infrastructure incrementally, minimizing risks and ensuring continuity for their users.

A critical factor in this migration was Dukaan’s ownership of its IP address space. This unique advantage allowed the company to maintain a consistent online presence throughout the transition. “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,” Choudhary stated.

### Building the Infrastructure

Dukaan chose Hetzner, a German-based bare-metal provider, to supply the physical servers needed for their new infrastructure. The decision to partner with Hetzner was strategic; the company rented servers in data centers geographically close to their existing AWS regions, facilitating a smoother transition. For instance, they selected a data center in Helsinki, Finland, to replace their AWS cluster in Frankfurt, Germany.

Over several weeks, Dukaan’s engineering team meticulously built and tested self-hosted Kubernetes clusters using k3s, a lightweight Kubernetes distribution designed for resource-constrained environments. This process involved setting up nine new data centers around the world, each configured to handle specific traffic loads.

Initially, Dukaan shifted just 1% of its European traffic away from AWS to the new bare metal cluster in Helsinki. The remaining 99% continued to be served by the stable AWS infrastructure. This cautious approach allowed the team to monitor performance closely and address any issues that arose during the transition.

### Gradual Rollout and Monitoring

As the migration progressed, Dukaan gradually increased the percentage of traffic directed to their bare metal servers. The team moved from 1% to 10%, then to 25%, and eventually to 100%. Each step was carefully monitored, with the ability to revert all traffic back to AWS instantly if any problems were detected. This meticulous monitoring ensured that users experienced no disruption during the transition.

Choudhary highlighted the importance of this phased approach: “Each step was carefully monitored. If we saw any issues, we could instantly shift all the traffic back to AWS with zero downtime.” This level of diligence not only safeguarded user experience but also instilled confidence within the team as they navigated the complexities of the migration.

### Achieving Zero Downtime

One of the most remarkable aspects of Dukaan’s migration was their achievement of a “zero-downtime migration.” By leveraging their own IP address space and employing the Strangler Fig Pattern, the company successfully transitioned its entire global application to self-hosted, bare-metal infrastructure without any interruptions to service.

Choudhary reflected on the significance of this accomplishment: “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.” This achievement not only demonstrated Dukaan’s technical prowess but also showcased their commitment to providing a seamless experience for their users.

### Lessons Learned and Future Implications

Dukaan’s migration journey serves as a valuable case study for other startups and established companies alike. The decision to move away from cloud dependency in favor of bare metal servers is gaining traction among organizations seeking to optimize costs and regain control over their infrastructure. Companies like OneUptime and Basecamp have reported significant savings after making similar transitions, further validating the potential benefits of this approach.

Choudhary’s insights in “The Accidental CTO” provide a roadmap for others considering a similar path. He emphasizes the importance of understanding the trade-offs between convenience and cost, urging leaders to evaluate their infrastructure strategies regularly. “It’s crucial to assess whether the convenience of cloud services is worth the financial burden it imposes,” he advises.

Moreover, Dukaan’s experience highlights the significance of adaptability in the tech landscape. As businesses evolve, so too must their infrastructure solutions. The ability to pivot and embrace new technologies can be the difference between success and failure in an increasingly competitive market.

### Conclusion

Dukaan’s successful migration from AWS to bare metal servers is a testament to the power of strategic decision-making and innovative thinking. By prioritizing cost savings and operational efficiency, the company has positioned itself for sustainable growth in the future. As more organizations explore the potential of bare metal solutions, Dukaan’s journey will undoubtedly serve as an inspiring example of what is possible when companies are willing to challenge the status quo and embrace change.

In a world where technology continues to evolve at a rapid pace, the lessons learned from Dukaan’s migration are invaluable. They remind us that while convenience is essential, it should never come at the expense of financial sustainability. As startups and enterprises alike navigate the complexities of modern infrastructure, the story of Dukaan stands as a beacon of hope and inspiration for those daring enough to take the leap into the unknown.