StormiTIP
Effective CloudFront implementation
Properly implementing CloudFront CDN reduces backend traffic. This can lower your overall infrastructure costs.
In this article you will learn:
In this article, we delve into the essentials of Amazon CloudFront pricing and explore how you can optimize your CDN costs. Discover the key factors influencing CloudFront expenses, from data transfer rates to additional features, and learn actionable strategies to minimize your spending. We’ll cover everything from understanding the free-tier and on-demand pricing to leveraging StormIT’s cost-saving techniques.
If you don’t know what a CDN (Content Delivery Network) or Amazon CloudFront are and how they can potentially be useful for your business, consider reading this article first or watch our video about CloudFront.
With CloudFront CDN it is very easy to distribute your content all over the world and to locations where you wouldn’t usually be able to deliver particularly fast. Before we get into the details on how to save money with Amazon CloudFront and answer your question, how to reduce my CloudFront usage costs, you need to learn how the pricing for the service works.
Or you can watch our video about Amazon CloudFront pricing:
The cost is determined based on your actual usage of Amazon CloudFront. The biggest share of the cost is for data transfer out to the public Internet.
Below is the first table where you can find more details about Amazon CloudFront CDN pricing. These first three usage types are the most common ones and if you start using CloudFront, you’ll probably see them on your AWS bill. The usage types are in order of how much they usually impact the final cost.
The second table below describes pricing for special features of CloudFront.
With Amazon CloudFront, you can use an AWS origin (Amazon S3, Amazon EC2, Elastic Load Balancing, etc.) or your origin servers, which can be from different providers.
CloudFront provides the possibility to remove files from all edge locations prior to the expiration date set on those files. There is no additional charge for the first 1000 paths requested for invalidation each month; after this threshold, you then pay $0.005 per path requested for invalidation.
Field-level encryption further encrypts sensitive data in an HTTPS form using field-specific encryption keys and is charged based on the number of requests that need the additional encryption; you pay $0.02 for every 10,000 requests that CloudFront encrypts using field-level encryption in addition to the standard HTTPS request fee.
With CloudFront real-time logs, you can get information about requests made to distribution in real-time. You can use real-time logs to monitor, analyze, and take action based on content delivery performance. You pay $0.01 for 1,000,000 lines in your log file.
Prices for Data Transfer Out of Amazon CloudFront vary across geographic regions and are based on the edge location. The price can be as low as $0.085 for North America and Europe, and up to $0.170 for South America. You can choose from three types of price classes when you create or update a CloudFront distribution. More info can be found here: Cloudfront cost reduction with price classes.
We help companies to save. No hidden costs or contracts. We invest time, resources, and people into building solutions around Amazon CloudFront, the industry-leading and highly secure CDN. We are ready to share our best practices for cost and technical optimization of AWS infrastructure with you.
At StormIT we have helped many customers to optimize their overall spend on data transfer (egress bandwidth) from different industries with a broad range of use cases from web applications and blogs to media streaming and gaming.
Below we share an example of a customer from the online gaming industry that has hundreds of thousands of active gamers every day and needs to deliver a mix of dynamic (application traffic) and static content (pictures, videos, CSS styles, js files, etc.) to players. By leveraging Amazon CloudFront and implementing the best practices mentioned above we managed to achieve significant cost savings for total data transfer out (DTO) from AWS.
As you can see in the graph below, before they worked with StormIT, the customer’s spending on DTO was slightly above $3000 per month, but after StormIT’s optimization their spending dropped significantly to approximately $1700, which translates to a more than 40% decrease and yearly savings of $18,000. This proves that Amazon CloudFront is a less expensive option and provides a better price per GB of transferred data.
There are several ways to reduce CloudFront costs, but they require changes in your CDN distribution or a commitment to AWS or certain specific functions for cache-control of distributed files, or a combination of these options.
Understanding the full scope of your infrastructure is crucial for effective cost optimization. At StormIT, we offer free Well-Architected reviews to help you assess and improve your entire architecture.
Cost optimization is a key pillar of these reviews, and data transfer costs are frequently discussed. By examining your infrastructure comprehensively, we can identify opportunities to optimize your CloudFront usage and reduce expenses. Discover how our expert reviews can help streamline your setup and enhance cost efficiency.
Book a free reviewUsing the right price class can play a major role in optimizing CloudFront costs. Even if you are distributing your content all over the world, you don’t actually need to use every available PoP (Point of Presence). Data Transfer Out is a significant factor in the overall CloudFront cost and this is one way to save some money on it. AWS charges less where their costs are also lower. Therefore, the prices vary across geographic regions and are based on the edge location from where your content is distributed to your users.
Price classes provide the option to lower the prices you pay to deliver your content out of AWS. By default, CloudFront minimizes end-user latency and maximizes bandwidth speed by delivering content from its entire global network of edge locations. Price classes let you reduce your delivery prices by excluding CloudFront’s more expensive edge locations. You will only be charged fees specific to the edge locations from where the content was delivered within the selected price class. If you select a price class that does not include all edge locations, some of your users may experience higher latency than if your content was being served from all CloudFront locations.
The table below displays which edge locations are used when you choose a specific Amazon CloudFront price class and also the price for GB without any discounts in this region.
You can select the price class in the AWS Management Console when you are creating a new CloudFront distribution or you can change it in an already existing distribution.
AWS offers discounted pricing for customers willing to commit to a minimum of 10 TB of Data Transfer Out per month for a period of 12 months or longer. Discounts vary based on the level of commitment.
This Cloudfront price reduction is usually only suitable for those businesses that have a steady application or website traffic and therefore predictable usage in the long term. Businesses that have seasonality or peaks throughout the year should expect to always pay at least the equivalent of their minimum monthly commitment.
This should help you to use the browser cache of your users more to cut Amazon CloudFront costs, but it can also help with the load on your origin server. For files that should be distributed through CloudFront, you can set how much time they should be saved in edge locations and the user browser. Normally CloudFront serves a file from an edge location until the cache duration that you specified passes. It’s best to make sure your expiration time isn't too short (it should be days or weeks at least, and months, ideally). You should be aware that if you need to make frequent changes to these files, this function will not work for you very well. CloudFront forwards the request to the origin server to verify that the cache contains the latest version of the file only after the file expires and the next time the edge location gets a user request for the file. You can invalidate your files in CloudFront caches any time you need, but you will be charged for this.
In this case, you can minimize Amazon CloudFront costs for data transfer out on files that can be cached inside of your user's browser cache. When these files are saved there, the user browser doesn’t have to fetch them from the cache in the edge location and you don’t have to pay for data transfer out from AWS.
You can use the Cache-Control and Expires headers. If you are using services from different providers, you will probably find information about this in the documentation for your service. After you make changes to the metadata of your files, you will probably need to invalidate those files in CloudFront distribution settings.
There is a very simple way to add metadata to files inside the Amazon S3 bucket by setting meta tags for the files:
1. Sign in to the AWS Management Console and from the Services menu open Amazon S3.
2. Choose the S3 bucket that contains the files on which you need to change the expiration time (TTL).
3. In the Name list, choose the name of the object that you want to add a header to.
4. Scroll down to Metadata options and click on Edit.
5. Choose Add Metadata.
6. And then in the Key menu, choose Cache-Control or Expires.
7. In the Value field, type one of the following:
8. After you add these metadata to your files, you will have to invalidate them in CloudFront distribution settings.
Effective CloudFront implementation
Properly implementing CloudFront CDN reduces backend traffic. This can lower your overall infrastructure costs.
If you are using CloudFront as a CDN distribution for other services from a provider other than AWS, you also pay your provider for data transferred from your origin to CloudFront CDN (Data Transfer Out). You can see a simple schema of data transfer costs below.
You should consider using AWS (Amazon Web Services) instead of services from different providers. If you use Amazon CloudFront, you don’t pay for data transfer out from Amazon services such as S3, EC2 and ELB, you just pay for data transfer from CloudFront to your users and other costs related to it. This is typically more cost-effective than paying for data transfer from regional services. An example of a simple schema can be found below.
If you are already using Amazon services such as EC2, ELB or S3, it’s best to also use CDN from Amazon. There are multiple reasons for this, but the main one is that you will no longer have to pay for data transfers between other CDN services and AWS. This solution is shown below.
You don’t pay for data transfers from AWS origins to a CloudFront edge location which can lead to significant cost savings. A simple solution with CloudFront CDN is below.
Do you want to know more about how to optimize the Data Transfer Out of AWS and lower the cost associated with it? Watch our video about it.
By understanding CloudFront's pricing structure and implementing smart cost-saving techniques, such as choosing the right price classes, leveraging AWS origins, and fine-tuning cache-control settings, you can significantly reduce expenses. Utilizing StormIT’s expertise can further amplify these savings, ensuring you get the best value for your investment. Whether you're just starting with CloudFront or looking to refine your existing setup, these strategies will help you maximize performance while keeping costs in check.