How I Reduced Our AWS Cloudfront Data Transfer Cost from $1000+ to Under $400

Sagar Chauhan
4 min readOct 23, 2023

--

Photo by Alexander Grey on Unsplash

When running an e-commerce platform, especially one hosting a vast amount of images for multiple websites, the costs associated with data transfer can quickly add up.

As a Senior Technical Product Manager (hands-on with day-to-day coding and contribute to features as an IC), working on a large scale distributed microservice architecture for an ecommerce platform, I was faced with the challenge of reducing our AWS cloudfront data transfer bill which was exceeding $1000+ per month.

This was the challenge my team and I faced, but after some rigorous optimization and strategic changes, we managed to cut our AWS Cloudfront data transfer costs by over 60%. Here’s how we did it.

The Challenge

Our e-commerce platform served images that were dynamic in nature. Instead of storing multiple versions of each image for different sizes, our application logic would compress and modify each image on the fly. This meant we could maintain just a single file on AWS S3. It seemed like an efficient system, but it came with its own set of challenges.

The next step was to cache these modified images. Our choice? AWS Cloudfront. By doing this, we ensured faster delivery to end-users, and we believed it was an efficient system.

However, there was a catch. Each time an image was requested, we incurred a data transfer charge.

With the increasing demand and growth of our platform, these charges skyrocketed.

It was soon clear that this model wasn’t sustainable in the long run.

The Revelation

As we were brainstorming solutions, we stumbled upon an interesting fact. Cloudflare, another popular CDN provider, had a very different philosophy when it came to data transfer charges. In fact, they were staunchly against it.

After diving deep into the nuances of Cloudflare pricing structure, we discovered they didn’t charge for data transfer out to the internet. This was a game-changer!

The Transition

We decided to make a pivotal move. This wasn’t a decision made lightly, given the potential implications on our infrastructure and the required changes in our workflows.

Instead of caching our images on Cloudfront, we would now cache them on Cloudflare.

However, the transition was surprisingly smooth. We ensured that our application logic was compatible, tweaked a few settings here and there, and before we knew it, our images were being cached on Cloudflare.

The Result

The results were nothing short of spectacular. In the very first month of the switch, we witnessed a drastic reduction in our costs. Our AWS Cloudfront data transfer costs, which had been $1000+, plummeted to under $400.

Conclusion

In the world of cloud services, it’s essential to keep an open mind and be willing to pivot when required. By being agile and adapting to new solutions, we managed to significantly reduce our operational costs while maintaining the efficiency and speed of our e-commerce platform. For those in similar situations, it’s always worth weighing the pros and cons of different services and finding the one that aligns best with your operational and financial goals.

Shameless Plug 🤪:

Hey everyone!

I’m excited to announce the launch of my first book, “Building Serverless Applications on AWS: A Step-by-Step Guide !”

Building Serverless Applications on AWS: A Step-by-Step Guide

You can get my book in multiple formats, including Kindle, paperback (both in India and internationally), and Gumroad.

So, whether you prefer a physical book or a digital copy, you can choose the format that works best for you.

If you wish to buy it, please use the link below:

About the book : https://bit.ly/about-my-book
Kindle : https://bit.ly/buy-kindle-version
Paperback India : https://bit.ly/buy-paperback-version-india
Gumroad : https://bit.ly/buy-on-gumroad
Paperback International : https://bit.ly/buy-paperback-version-international

I’m excited to hear what you think!

Until next time……

Feel free to follow me up on :

Twitter | LinkedIn | Github | Website

--

--

Sagar Chauhan
Sagar Chauhan

Written by Sagar Chauhan

Hustler | Geek | Bootstrapper | PolyMath

Responses (1)