In this article you will learn:
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.
Amazon CloudFront pricing
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.
Amazon CloudFront pricing options:
Free-tier: If you are unsure if CloudFront is right for you, you can always start with the free-tier eligible account for the first year. As the name suggests you get to use Amazon CloudFront for free with the AWS Free Usage Tier. Once you sign-up as a new AWS customer you receive 50 GB of Data Transfer Out and 2,000,000 HTTP/HTTPS requests each month for a year. Even if your usage is higher, you will only be billed for the usage above this allowance.
On-demand: Your costs are determined by pay-as-you-go pricing and the actual usage of CloudFront services. You pay for what you use.
AWS discounted pricing: You can get discounts on Data Transfer Out of AWS if you reserve capacity and commit to using more than 10 TB per month.
What determines the Amazon CloudFront cost?
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 a simple table where you can find more details about Amazon CloudFront CDN pricing. The usage types are in order of how much they impact the cost.
Origin server to Amazon 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. If you are using an AWS origin, data transferred from origin to edge locations will be free. This applies to data transfer from all AWS regions to all global CloudFront edge locations. If you are using your on-premises servers or a service from a provider other than Amazon, you will be charged separately based on the pricing of your data transfer out.
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 Requests
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.
Real-time log requests
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.02 for every 10,000 requests that CloudFront encrypts.
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.
Amazon pricing and CloudFront cost reduction best practices by StormIT
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.
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.
Obviously, every project/case is unique, and it is not always possible to achieve such results, but we are confident that by using Amazon CloudFront in a smart way it is possible to achieve overall lower costs and improved performance.
You can learn more about our offers here:
How to reduce Amazon CloudFront costs?
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. If you already know that you don’t want to make these changes or don’t have the necessary knowledge, read more about our offer in the last section of this article or click on the button below.
Common ways of reducing CloudFront costs:
1. Using the right CloudFront price class for your needs:
Using 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.
2. Reserving capacity for CloudFront
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.
3. With Cache-control:
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:
For a Cache-Control field, type: max-age=number of seconds that you want objects to stay in a CloudFront edge cache.
For an Expires field, type a date and time in HTML format.
Make sure your expiration time isn't too short (it should be days or weeks at least, and months, ideally).
8. After you add these metadata to your files, you will have to invalidate them in CloudFront distribution settings.
Possible cost reduction for those who use services from providers other than Amazon Web Services
Consider using Amazon Web Services instead of other services with CloudFront CDN:
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.
Consider using CloudFront CDN instead of a CDN service from other providers:
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.
Ready to start saving on your CDN costs?
We are designated as AWS Service Delivery Partner for Amazon CloudFront and our team of AWS certified professionals is ready to help accelerate and secure your applications with the right CDN solution for your needs.