The Importance of a CDN: How to Speed Up Apps with AWS CloudFront
Rupert Maspero
For web and mobile apps speed and reliability are crucial. We recently helped Stornaway optimise their AWS CloudFront implementation, a powerful Content Delivery Network (CDN), to enhance their app’s performance.
What is a CDN? 🤔
A CDN helps deliver website content faster by storing copies at various locations worldwide, called edge locations. When someone accesses your website or app, the CDN sends the content from the location closest to them, speeding up delivery.
If the content isn’t already stored there, the CDN retrieves it from the main server (known as the origin server, such as an Amazon S3 bucket) and saves a copy for future use.
A CDN like Amazon’s AWS CloudFront is essential for businesses aiming to globally deliver content quickly. For platforms like Stornaway, it’s a game-changer that ensures a seamless user experience.
Key Benefits of a CDN
- Faster Load Times: Content is served from the closest edge location, ensuring quick delivery.
- Reduced Server Load: The CDN handles the bulk of traffic, allowing origin servers to scale more efficiently.
- Flexibility: Easily switch between test and production environments with minimal configuration.
Do I Need a CDN? 🤷♂️
If your app includes many videos, images, or JavaScript files and serves users globally, using a CDN is highly recommended.
For Stornaway, ensuring their video player loaded quickly was a top priority. Implementing a CDN helped maintain fast, consistent performance for users worldwide, regardless of their location.
Our Approach For Stornaway ⏰
We integrated AWS’s CloudFront CDN with Active Storage in Stornaway’s Rails application. AWS’s CloudFront CDN was chosen because the application's assets were already stored in an AWS S3 bucket.
This meant doing a few key steps:
- Configuring Amazon S3 as the origin for static and video files.
- Setting up CloudFront distributions for global caching.
- Enabling proxy mode in Active Storage for secure, dynamic URLs.
- Optimising caching policies for improved performance.
- Updating all references to call the CDN where possible, while leaving a fallback for any old URLs.
Curious to find out more about the platform? Check out this intro to Stornaway 👀
Results 🏆
The results were significant: faster load times, smoother video playback, reduced server strain, and improved resilience during traffic surges.
With tens of thousands of customer projects in the wild already using ActiveRecord to serve millions of images, we wanted to trust it to mmtm to make this change thoughtfully and sustainably. They've done so much great work for us in partnership with our in-house team!
Ru Howe, Inventor of Stornaway and Chief Design & Technology Officer
Martin Dick
Co-Founder, mmtm
Need help improving app performance?
We've spent the last 10+ years building, improving and supporting bespoke web applications, including Rails products that rely on fast, reliable content delivery.
If your app's struggling with slow load times, heavy media, traffic spikes or server load, I'd be happy to talk through your best options!
Schedule a callFrequently Asked Questions
What is a CDN used for in a web application?
A CDN is used to deliver website or app content faster by caching files closer to the people using it. For apps with images, videos, JavaScript or global users, a CDN can reduce load times, reduce pressure on the origin server and make the experience more consistent during busy periods.
When does an app need a CDN?
An app may need a CDN if it serves large files, has users in multiple locations, experiences traffic spikes or depends on fast media delivery. It's especially useful for platforms with video, image-heavy pages, downloads or frontend assets that should load quickly without making the main application server do all the work.
Does AWS CloudFront work with Ruby on Rails?
Yes! AWS CloudFront can work well with Ruby on Rails applications, including apps that use Active Storage and Amazon S3 for file storage. The setup usually involves configuring S3 as the origin, setting sensible caching rules and making sure the Rails app serves the right CDN URLs safely.
How can I improve web application performance?
A good first step is to identify what is actually slowing the app down. That might be large media files, slow database queries, frontend assets, server load, hosting setup or old application code. For a professional recommendation, we suggest our Codebase Audit service!
Not Sure What To Read Next? Here's What We Recommend...
- CDN
- Digital Solutions
- Software Consultancy
- AWS CloudFront
- App Development