11. GCP Networking Basics: Content Delivery Networks

Mileke KolawoleMileke Kolawole
3 min read

Introduction

The internet is a vast expanse, and the sheer physical distance between users and your website's servers can lead to frustratingly slow load times, especially for those continents away. In a world where a few seconds can make all the difference in engaging (or losing) an audience, those waiting-for-page-load moments are lost opportunity.

Moreover, if your website gains sudden popularity, a deluge of requests for things like images or videos can leave your servers struggling to keep up. It's like being a small bakery and getting reviewed by Keith Lee from TikTok. Suddenly, you're swamped with a line out the door and down the block, desperately trying to fulfill orders all from one kitchen!

Thankfully, Content Delivery Networks (CDNs) offer an elegant solution to combat such problems. Imagine having dozens of 'mini-bakeries,' each a strategic outpost holding stock of your bestsellers. A savvy delivery network routes hungry customers their nearest location, guaranteeing fresh treats without all the lines and long waits.

CDNs operate similarly. They cache copies of your most popular content – images, stylesheets, or even small videos – at "edge locations" strategically distributed around the globe. Users get an optimized experience because the CDN system aims to meet their requests at a site physically closer to them, speeding up delivery and making the wait more endurable. This frees up your main servers to handle the ever-changing parts of your app, where that single point of origin is essential.

Now, CDNs aren't a solve-everything magic box. They shine on those static things that stay the same for everyone, making repeats a breeze! Your frequently accessed logo, your latest 'viral' picture... CDNs make sure no one's staring a wait spinner as those are constantly fetched by new visits. But there are complexities when content goes stale, where updates you make suddenly AREN'T at the edges... something to investigate soon!

The Setup: Matching Content to Caching

In GCP, using the CDN entails these general steps:

  1. Choose What to Cache: Not everything makes sense. Your ever-changing blog article text? Poor fit. The site-wide background image used on every page? Absolutely!

  2. Rules with Priorities: Sometimes multiple rules COULD apply if they aren't precise with file paths, extensions, etc. The system works through these 'most specific wins'

  3. Expiry Settings: "How long is cached data 'fresh'?" This is trickier than it seems. Too short, you lose benefit. Too long, edits don't show for users promptly! Striking a balance takes understanding of how often stuff changes on your site.

The Tradeoff: What Makes Sense to Cache?

Here's where developer insight meets understanding CDNs for maximizing impact:

  • Size: If the item is tiny, is the delay to get it ever a user issue? CDN is there to shave seconds, milliseconds don't always add up

  • Uniqueness: User avatars that are per-profile wouldn't make sense to cache! Things everyone requesting sees the exact same way are gold

  • Update Frequency: Your 'last modified' timestamps get checked by CDNs... if every hour it's new, cache might be wasted effort

Strategic Edge Placement

CDN providers have these global edge sites all over, but YOU might control:

  • Tier Choice: Big ones offer "more points of presence" at a price. Sometimes the budget option cuts out less common geo areas your users ARE in!

  • Specific Rules: "My video only works legally in a few countries, only cache it AT these listed CDN edges". Business/rights management reasons play in

  • Analytics: CDNs can tell you WHERE the traffic came from. Might find a surprise region worth better serving if data proves the need, after launch

Beyond Google-Specific

While Cloud CDN works within GCP, noting that standalones like Cloudflare exist is valid:

  • They boast even larger 'edge network' sometimes... the global footprint is more a CDN provider thing vs the cloud the rest of your app sits on

  • Feature Depth varies: CDNs often tie into security stuff in fancy ways - GCP will have basic things, the pure-play vendors of this space sometimes surprise the less initiated!

0
Subscribe to my newsletter

Read articles from Mileke Kolawole directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Mileke Kolawole
Mileke Kolawole