CDN, which stands for Content Delivery Network, is a network of servers distributed in different locations whose primary task is to quickly deliver internet content. It could be websites, images, pictures, or other static files that do not change with subsequent HTTP/HTTPS requests. CDN infrastructure is what ensures the high availability for this content. How?
Without CDN, we deal with a single server or a group of servers in one physical location. Let’s call it the “source” for simplicity. Each user searching for information stored on the server must communicate directly with the source. If the recipient is located far away, the transfer will be delayed. And no one has patience for a slow-loading website these days.
Simply put, the CDN infrastructure copies the original content to all available servers within its network. This way users will receive the content they requested quickly, regardless of their location. No wonder CDN is popular among big and small players alike. It is used by global streaming services (Netflix), and e-commerce companies (Shopify), as well as owners and creators of small websites.
Is CDN what I need?
But what if your audience is local, meaning they are close to the server? Do you still need CDN? It may seem unnecessary because the distances we need to deliver content are small.
The important thing is that CDN serves cached files, not files directly from the “source.” It thus relieves the source server, which means you can use a server with lower specifications and still handle the traffic. Even with a narrow, direct network path to the server, CDN allows you to serve more clients than with direct traffic.
It’s yet another story if you store a lot of confidential information on you websites or when dynamic content prevails over static content. Why is that? We will learn this by analysing the mechanics of how CDN works.
How does CDN work?
We will discuss the operation of CDN using the example of Google Cloud CDN, which is one of the most popular Google Cloud services. Every time a user sends a request to a website or application, the request goes to the nearest Google Edge node, of which there are over 120 worldwide. It then passes on to the HTTP(S) Load Balancer and the original backend. Servers in the Cloud CDN network store cached copies of the original content, allowing for fast access to that content.
Most often, graphic files, videos, JavaScript, and CSS are found on the source servers. Cloud CDN automatically creates caches for static content. In Google Cloud CDN, you can even create a cache for content marked as “private,” “no-cache,” or “no-store.” Of course, this is an optional feature and you don’t need to use it.
Cache hit and miss
Upon receiving a request, Cloud CDN searches for the cache using a cache key, usually in the form of a URL. When the response returns from the cache after sending a request, we call it a cache hit, and the information delivery cycle is complete.
However, there may be cases where Cloud CDN does not find the requested file because it is not stored in the cache. This is referred to as a cache miss. This does not mean that the user gets nothing, though.
Cloud CDN communicates with the next server to check if the requested information is available there. If it finds the correct file on one of the subsequent servers, it sends to the cache server nearest to the client. If the file in question is not present on any of the subsequent servers, Cloud CDN forwards the user’s request to the original server.
In case of multiple cache miss, the result is the same as if we were not using Cloud CDN. Still, this is a last resort situation, and along the way, it may turn out that the request gets a response much faster.
How long is my content cached?
An object remains in the cache for a period of time called Time to Live (TTL). TTL can be set for each HTTP response and cache modes. After the specified time period is exceeded, the cache is cleared.
Is Cloud CDN only suitable for static content?
As indicated earlier, CDN is not the best option for large quantities of dynamic content. But does the same apply to Cloud CDN? Although the specialisation of content delivery networks was initially static files, it is increasingly successful in accelerating the delivery of dynamic content to clients.
What is dynamic content? It is content which depends on several variables and appears differently for different users. The simplest example is an e-commerce store that creates a list of recommendations based on the client’s purchase history. It is therefore tailored to each customer’s preferences. Personalisation also depends on geolocation and changes depending on whether the user is using their account or browsing in incognito mode.
Media CDN – a powerful Cloud CDN component
For high-bandwidth outgoing loads such as streaming large files, including videos, Google offers Media CDN. This service distributes content as close to users as possible using the global edge cache infrastructure. Retrieving materials from publicly available HTTP endpoints is easy, and you can combine Media Cloud with any existing source infrastructure. It doesn’t matter if the content is hosted in Cloud Storage or another cloud provider.
API best security practices
Security is key and content providers as well as e-commerce businesses know how big threat a DDoS attack can be to their business. In order to protect your content on Cloud CDN from DDoS attacks, you can use Cloud Armor. This is how it works.
- The client retrieves a token using reCAPTCHA and sends a request to the Load Balancer, providing application credentials in the form of a key, token, or certificate.
- Cloud CDN checks the cache using the key and returns a response.
- If the response is incorrect, Google Cloud Armor is activated. It filters the request, evaluating it according to all configured rules and policies. In case of a rule violation, Cloud Armor returns an error message with a status code.
How do others use Cloud CDN?
U-NEXT is a Japanese company specializing in video streaming. They focus on delivering feature films, documentaries, and anime to their 2.5 million subscribers. U-NEXT was looking for a modern CDN solution that would not require dedicated engineers or weekly technical reports. Deploying Media CDN took just a few hours, achieving a very high cache rate of 98.3%.
How much does Cloud CDN implementation cost?
Implementing Cloud CDN doesn’t have to be difficult, as demonstrated by the U-NEXT example. It can also be relatively quick. The easiest way is to seek assistance from a certified Google Cloud architect. Reach out to FOTC, a Google Cloud partner company. Our experts will guide you through the entire CDN implementation process and help optimize your operating costs in the Google Cloud.