Three Use Cases Where You Should Use Amazon CloudFront

Amazon CloudFront is likely not the most common and known service in the AWS family. Nevertheless, it proves to be a very interesting alternative to S3 or other products alike when you aim not to the storage in itself, rather to delivering content for your appliance. Indeed, CloudFront is a content delivery web service with “low latency, high data transfer speeds, and no commitments”. Despite that, I see that CloudFront is often poorly used or unused at all. So, to make clear what it is thought for and how to take advantage of it, let’s see 3 typical use cases where you should use Amazon CloudFront.

Three use cases where you should use Amazon CloudFront

Replace S3 with CloudFront when your userbase is geographically distributed

S3 is typically used to store and deliver data for your appliance. Unfortunately, this is a poor choice when the userbase is geographically distributed and you can’t focus your storage on a particular area of the world to achieve the lowest possible latency. On the other hand, CloudFront has a global network of so-called “edge locations”, which are data centers spread around the world, all replicating the content you would like to deliver to your user. Every time a resource is asked for by end users, the request is automatically routed to the nearest edge location, in order to achieve high-performance delivery of the content. In addition to that, you can even set different domain aliases for your CloudFront distribution, that is, having cdn1.mydomain.com, cdn2.mydomain.com, and so on, all pointing to the same CloudFront distribution. This allows parallel downloads and improves, even more, the performance of your appliance.

Harness the Origin Servers feature to cache dynamically generated content

When Cloud Front was launched, it was a feeder of content stored on S3 only. You put your objects on Amazon S3, CloudFront takes and caches them on the edge locations, then delivers them from there. This was quite a strong limitation for certain applications, but later on, Amazon introduced a feature called “Origin Servers” that quite changed the game.

Adding a Custom Origin Server allows CloudFront to feed content from anywhere, even from your on-premises web server, or a machine from another cloud provider. The great thing behind that is that you can deliver even automatically generated content via CloudFront, and use CloudFront to replace a custom caching solution. CloudFront allows you to tune quite finely its behavior, especially thanks to HTTP headers like Cache-Control, who control how long CloudFront should cache a given resource. Another nice feature is that CloudFront supports Etag headers.

Do you know what Etag is? They are a sort of a hash, or a digest, of the given resource. Modern browser uses them to save bandwidth. When a browser requests something that is available in browser’s cache, it will send a special If-Match header with the ETag of the resource from the cache. CloudFront will compare this ETag with ETag from his cache and will respond with HTTP 304 Not Modified without sending the resource again. Just add Etag’s to your content on CloudFront and this behavior will be automatically triggered.

CloudFront caching on steroids: Whole-Site Delivery

If we can deliver even dynamically generated content, why not taking full advantage of it and move to a Whole-Site Delivery approach? In the typical usage pattern, CloudFront act as a CDN for static content only, typically hosted either on S3 or on your Custom Origin server. Nevertheless, we have just seen how you can use it to cache dynamic content from your origin server. So, what blocks from using CloudFront as a CDN for your whole website? The key idea here is to use CloudFront as a proxy for both S3 (where your static assets are stored) and your EC2 instance, or your on-premises Custom Origin server (where dynamic content is generated).

If this seems a bite off more than you can chew, fear not: a lot of websites already use an approach like this, with a significant improvement of their performance. The idea that user-personalized pages can’t be delivered via CDNs is simply a myth. Truth is that network and path optimizations allow CloudFront to speed up dynamic content without losing a bit in customization. Setting up this architecture isn’t difficult at all, you will probably need some time to perfectly tune it, but your profits in term of performance, better scalability, improved availability, and reduced costs will go way beyond that.

Avatar

Written by

Andrea Colangelo

Software Engineer with a solid focus on QA and an extensive experience in ICT. Above all, Andrea has a very strong interest in Free and Open Source Software, and he is a Debian and Ubuntu Developer since years. Non-tech interests include: Rugby, Jazz music and Cooking.


Related Posts

Nisar Ahmad
Nisar Ahmad
— November 12, 2019

Kubernetes Services: AWS vs. Azure vs. Google Cloud

Kubernetes is a popular open-source container orchestration platform that allows us to deploy and manage multi-container applications at scale. Businesses are rapidly adopting this revolutionary technology to modernize their applications. Cloud service providers — such as Amazon Web Ser...

Read more
  • AWS
  • Azure
  • Google Cloud
  • Kubernetes
Avatar
Stuart Scott
— October 31, 2019

AWS Internet of Things (IoT): The 3 Services You Need to Know

The Internet of Things (IoT) embeds technology into any physical thing to enable never-before-seen levels of connectivity. IoT is revolutionizing industries and creating many new market opportunities. Cloud services play an important role in enabling deployment of IoT solutions that min...

Read more
  • AWS
  • AWS IoT Events
  • AWS IoT SiteWise
  • AWS IoT Things Graph
  • IoT
Avatar
Cloud Academy Team
— October 23, 2019

Which Certifications Should I Get?

As we mentioned in an earlier post, the old AWS slogan, “Cloud is the new normal” is indeed a reality today. Really, cloud has been the new normal for a while now and getting credentials has become an increasingly effective way to quickly showcase your abilities to recruiters and compan...

Read more
  • AWS
  • Azure
  • Certifications
  • Cloud Computing
  • Google Cloud Platform
Valery Calderón Briz
Valery Calderón Briz
— October 22, 2019

How to Go Serverless Like a Pro

So, no servers? Yeah, I checked and there are definitely no servers. Well...the cloud service providers do need servers to host and run the code, but we don’t have to worry about it. Which operating system to use, how and when to run the instances, the scalability, and all the arch...

Read more
  • AWS
  • Lambda
  • Serverless
Avatar
Stuart Scott
— October 16, 2019

AWS Security: Bastion Hosts, NAT instances and VPC Peering

Effective security requires close control over your data and resources. Bastion hosts, NAT instances, and VPC peering can help you secure your AWS infrastructure. Welcome to part four of my AWS Security overview. In part three, we looked at network security at the subnet level. This ti...

Read more
  • AWS
Avatar
Sudhi Seshachala
— October 9, 2019

Top 13 Amazon Virtual Private Cloud (VPC) Best Practices

Amazon Virtual Private Cloud (VPC) brings a host of advantages to the table, including static private IP addresses, Elastic Network Interfaces, secure bastion host setup, DHCP options, Advanced Network Access Control, predictable internal IP ranges, VPN connectivity, movement of interna...

Read more
  • AWS
  • best practices
  • VPC
Avatar
Stuart Scott
— October 2, 2019

Big Changes to the AWS Certification Exams

With AWS re:Invent 2019 just around the corner, we can expect some early announcements to trickle through with upcoming features and services. However, AWS has just announced some big changes to their certification exams. So what’s changing and what’s new? There is a brand NEW ...

Read more
  • AWS
  • Certifications
Alisha Reyes
Alisha Reyes
— October 1, 2019

New on Cloud Academy: ITIL® 4, Microsoft 365 Tenant, Jenkins, TOGAF® 9.1, and more

At Cloud Academy, we're always striving to make improvements to our training platform. Based on your feedback, we released some new features to help make it easier for you to continue studying. These new features allow you to: Remove content from “Continue Studying” section Disc...

Read more
  • AWS
  • Azure
  • Google Cloud Platform
  • ITIL® 4
  • Jenkins
  • Microsoft 365 Tenant
  • New content
  • Product Feature
  • Python programming
  • TOGAF® 9.1
Avatar
Stuart Scott
— September 27, 2019

AWS Security Groups: Instance Level Security

Instance security requires that you fully understand AWS security groups, along with patching responsibility, key pairs, and various tenancy options. As a precursor to this post, you should have a thorough understanding of the AWS Shared Responsibility Model before moving onto discussi...

Read more
  • AWS
  • instance security
  • Security
  • security groups
Avatar
Jeremy Cook
— September 17, 2019

Cloud Migration Risks & Benefits

If you’re like most businesses, you already have at least one workload running in the cloud. However, that doesn’t mean that cloud migration is right for everyone. While cloud environments are generally scalable, reliable, and highly available, those won’t be the only considerations dri...

Read more
  • AWS
  • Azure
  • Cloud Migration
Joe Nemer
Joe Nemer
— September 12, 2019

Real-Time Application Monitoring with Amazon Kinesis

Amazon Kinesis is a real-time data streaming service that makes it easy to collect, process, and analyze data so you can get quick insights and react as fast as possible to new information.  With Amazon Kinesis you can ingest real-time data such as application logs, website clickstre...

Read more
  • amazon kinesis
  • AWS
  • Stream Analytics
  • Streaming data
Joe Nemer
Joe Nemer
— September 6, 2019

Google Cloud Functions vs. AWS Lambda: The Fight for Serverless Cloud Domination

Serverless computing: What is it and why is it important? A quick background The general concept of serverless computing was introduced to the market by Amazon Web Services (AWS) around 2014 with the release of AWS Lambda. As we know, cloud computing has made it possible for users to ...

Read more
  • AWS
  • Azure
  • Google Cloud Platform