Configure
Build your server

CDN: Explained in Simple Terms

CDN: Explained in Simple Terms 26 October 2023

Contents of Articles:

  1. Introduction
  2. CDN. Definition
  3. How CDN Works
    1. Content Distribution
    2. Caching
    3. Shielding in CDN
  4. When to Connect to CDN
  5. Advantages of Using CDN
  6. Drawbacks and Alternatives to CDN
  7. Conclusion

Introduction

The weight of websites has been steadily increasing over the years. To put it in perspective, in 2018, the average size of web pages was 1.8 MB, but by the first half of 2023, it had reached 2.3 MB. However, users are not willing to compromise on website loading speed and tend to abandon a site if its content doesn't appear within 3 seconds. According to Google's research, this behavior is observed in 53% of users. As user engagement metrics drop, so does a site's ranking on search engines. If a heavy website is located far from its target audience, the waiting time for content can become even more critical. The bounce rate continues to rise with each additional second it takes to load a page. For online businesses with a global customer base, this poses the risk of zero conversions and revenue loss. The solution to the problem of slow website performance is a content delivery network (CDN). In this article, we'll explain what a CDN is, when to use this technology, and what alternatives are available.

CDN (Content Delivery Network): Definition

A CDN, or Content Delivery Network, is a network of servers located in various geographic locations. CDNs help websites deliver content to users quickly and reduce the load on the main server (which stores the original data). CDN servers act as additional storage and data transmission nodes. Their cache contains static content. When a user's request to load a website comes from a location far from the main server's data processing center, a part of this request is handled by the CDN. The CDN server closest to the visitor's location delivers the unchanged website content to the user's browser, relieving the main server of this task. This reduces traffic latency, increases the connection speed between devices, and decreases the risk of server overload.

How CDN Works

CDN: Explained in Simple Terms

A website is hosted on a server, often referred to as the content source or origin server. Typically, a browser's request is directly processed by the origin server, which means it independently serves all files. If users of the website are scattered across various parts of the U.S., Europe, Asia, and other regions worldwide, the server's response must traverse thousands of kilometers of optical fiber cables, receiving instructions from various relays along the way. If the origin server is located in a data center in Washington, for instance, users in that region will experience nearly instant data retrieval. However, the distance from Washington to Los Angeles is 2,670 km, and some connection points may be even farther. Retrieving information can take several minutes, which only a few highly motivated users will tolerate. To reduce the time it takes for clients to receive content, the "heavy" parts of the website (binary files, texts, images, streams, scripts) are cached on distributed CDN servers. Not every company can afford its own CDN server network, so website owners turn to CDN service providers.

Content Distribution

A server within the CDN is a "Point of Presence" (PoP) for the project in a specific location. The service provider is chosen based on the availability of equipment in the required areas. Regional PoPs are also referred to as edge servers. They connect to the origin and cache data when they receive the first user request. For that user, loading the site might take a while. For subsequent requests, the edge server quickly delivers files to browsers because they are already in its memory. To eliminate inconvenience for the initial clients of each PoP, the project owner may pre-warm the CDN network.

For content distribution among users in different regions, CDN networks use two popular technologies: GeoDNS and AnyCast.

GeoDNS: When a web browser queries the site's DNS server, it identifies the user's public IP address and selects the closest PoP based on these coordinates. GeoIP, which translates IP addresses into geographical coordinates, forms the basis of this technology.

AnyCast: This technology utilizes the BGP protocol, which provides information about neighboring networks and their distances. CDN establishes connections with several routers, which, after some time, communicate which of them can provide the shortest path to the required IP address and route traffic accordingly.

The ability to identify user IP addresses enables setting geographical restrictions on access to a website from specific geographic zones on CDN servers.

Caching

Over time, even static content can become outdated. To ensure that users see the website in its most current form, caching rules are established, defining the Time to Live (TTL), which determines how long information is stored in the cache before the edge server reverts to the origin server for new content. Before new caching, the CDN server undergoes purging, a process that clears and prepares it for the download of up-to-date information.

By employing a CDN, websites can provide users with faster loading times, reduced latency, and improved overall performance. This not only enhances the user experience but also positively impacts search engine rankings.

Shielding in CDN

During updates at Points of Presence (PoPs), there can be increased load on the main server. The high intensity of incoming requests can lead to server overload. To safeguard the project's stability within a wide CDN network, shielding is employed. An additional server is placed between the origin and PoP, and it caches and distributes the results to CDN servers. This intermediate server functions as a shield.

When to Connect to CDN

CDN: Explained in Simple Terms

CDN can help solve various project challenges, from maintaining reputation to saving on VPS/VDS rentals. Let's look at situations where projects can't do without CDN:

Wide Geographic User Base. Common for online stores, streaming platforms, gaming servers, major news portals, and online banks where users are scattered across different regions.

Rapid Project Growth and Scaling. When your project is expanding quickly and needs to handle increased traffic.

Stable Website Performance. For the need to ensure that your web project performs without overloads.

High Risk of DDoS Attacks. When there is a significant risk of DDoS attacks, which can be costly to defend against.

Handling "Slow Requests". If your site includes resource-intensive programs and interactive media content.

Improving User Experience and Search Engine Indexing. When you want to provide a faster response from the server to enhance user experience and search engine rankings.

High Hosting Costs. CDN can allow you to choose a less powerful VDS, saving hosting expenses.

In summary, connecting to a CDN positively impacts a project's online presence.

Advantages of Using CDN

Without CDN, some projects may struggle to compete. The more alternative options your users can find on other websites, the less motivated they will be to stay on a slow-loading site. Let's examine the key advantages of CDN:

Improved SEO. Users receive content within seconds, which is factored into search engine rankings.

No Need for Expensive IT Infrastructure. There's no need to purchase additional servers and associated hardware or set up data centers.

Increased Uptime. Lower risk of DDoS attacks, absence of overloads beyond server capabilities, and multiple data backups.

Wide Audience Reach. Users are attracted to fast server response times.

High Availability with CDN Source Server. CDN ensures high availability for your users.

Drawbacks and Alternatives to CDN

In some cases, setting up a CDN network may be futile and costly. Before turning to a content delivery network provider, ensure that the technology is suitable for your website. If your website primarily contains dynamic content, edge servers may not be able to handle it. Additionally, updating data on CDN servers can take up to 24 hours, which could be critical for some projects that require real-time updates. CDN may not be suitable for small businesses with a local customer base, where renting additional servers doesn't provide benefits or a return on investment.

In such cases, website optimization can be achieved through more traditional SEO methods and tools:

  • Compressing images, videos, and illustrations on the website using CMS plugins, graphic editors, online services, etc.
  • Organizing the inclusion of JS scripts and CSS styles.
  • Choosing a more powerful server configuration for faster HTML page generation.
  • Reviewing the settings of database management systems and web applications.

Conclusion

A CDN network is a valuable tool that can reduce downtime and improve a website's performance, which is crucial for user interaction. However, it is not suitable for all projects, and sometimes it's better to optimize website loading speed using traditional SEO tools.