At some point in 2023, we were discussing costs and pagespeed. I quickly pointed out that the slow performance and spike in bandwidth costs were caused by the usage of .gif images. At first, the team was reluctant, but a few days later, I came up with a report provided by the Amazon S3 service, where you can save an access log of the hosted files and later process it using Amazon Athena.

S3 Access logs documentation

The report was curiously enlightening. I was able to find access to .gif files with a size over 100MB. Usually, the .gif images were the cover of the posts, and on our main listing page, there were several of them loading even though users were not accessing the post. Without a doubt, the .gifs were a problem we needed to address.

After discussing this with the team the following day, we tried to figure out the best way to address the issue. For sure, the first proposal was to stop using .gif images, but another team claimed that using .gifs was important for the posts, as they sell more when they have .gifs. We also proposed using YouTube videos, as we already supported that, but it seemed like it was going to make their work more complex.

At some point, we mentioned using a CDN, and as we were hosting on AWS, the expected thought was using an AWS Cloudfront distribution. At first, I tried to turn down this proposal, as CF provides 1TB of outgoing bandwidth for free, but after that, we would still pay $0.1 per GB, which, based on our monthly expenses (over 15TB), was only going to reduce the cost by a bit over $100.

After our daily meeting, I started to investigate how we could address this situation. A few hours later, I evaluated several CDNs, and the final option was Cloudflare, as they offered a free plan that was enough for our needs. Also, it was super easy to implement. We just got another domain for the CDN, and in a few days, everything was set up and working.

This is how much Cloudflare was able to serve during the first month after the implementation:

15TB of Bandwidth usage throught cloudflare

Usually, Cloudflare is caching around 80% of the traffic, sometimes more, as the next graphic shows.

Cached content

This is how AWS bills the bandwidth:

  • First 10 TB: $0.09 per GB
  • Next 40 TB: $0.085 per GB
  • Next 100 TB: $0.07 per GB
  • More than 150 TB: $0.05 per GB

Based on that, the 15.28 TB we were paying $1,381.17 in bandwidth, meaning that our yearly expenses for this reason would be near $16,574.04. If we consider that Cloudflare is caching 80% of the traffic, the total savings looks like this:

Total cost without CDN Total Cost with CDN Savings Yearly
$16,574.04 $3,314.81 $13,259.23

It was definitely really cool that we avoided paying all that, but using a CDN comes with other benefits that directly impact page speed. In another post, we will discuss the benefits of image transformations and also using next-generation formats as an option to speed up your website.