Web Performance Optimization

 Home / What is a CDN and how does it work?


What is a CDN and how does it work?

Content Delivery Networks (CDN) are global shared infrastructures used for high performance content delivery over the Internet. A CDN significantly improve the speed at which a website or mobile application can deliver web content, provide high availability and enhance scalability on demand to content providers while offloads traffic from their infrastructure reducing bandwidth, hardware and operational costs.

Architecture

Content distribution over the Internet combines development of high-end computing technologies with high-performance networking infrastructure and distributed data mechanisms. For a content provider, replicating the same content or services over several mirrored web servers strategically located at various locations is a challenging task. This is where CDNs offer a fast and reliable service for distributing content to cache servers (a.k.a. edge servers) located close to users and provide services that boost network performance by maximising bandwidth, improving scalability and maintaining availability through content replication.

A Content Delivery Network (CDN), also know as a Content Distribution Network, is a collection of servers globally distributed across diverse data centers around the Internet to deliver web objects from Content Service Providers (CSP) to their end-users. CDNs provide network services based on application layer protocols like HTTP. A CDN is particularly aimed to customers who want to guarantee quality-of-service to their end-users while consuming their web content and services, such as media and news companies, e-commerce and web service providers.

Locations where servers are deployed are called nodes or points-of-presence (PoP), which generally sits near to main Internet Exchange Points (IXP) in different geographical regions over the world and also in strategic locations close to customers' end-users. Choosing the best regions for each node is closely associated to the content delivery mechanism to reduce user perceived latency for accessing content and to reduce network bandwidth utilization.

Each PoP is conformed of multiple edge servers providing large capacity on demand to CSP to handle sudden spike in web content requests bringing higher throughput and performance to CSP's origin servers, which typically are traditional web servers hosted in a centrally data center with limited resources. A unexpected peak in traffic to a centrally located website could make it temporarily unavailable. Hybrid infrastructures of bare-metal and virtual servers are also used for flexibility and performance depending on geographical location load requirements.

Operation

A CDN performs as a global Application Delivery Controller (ADC) including network traffic routing, layer 7 load balancing, caching, compression, TCP optimizations and brings security in layers 3/4 and layer 7. Internal application specific servers and network appliances deliver these global services to CDN customers on demand.

Communication between client end-users and origin servers is broke down by CDN edge servers located in the middle of a standard client-server data flow. Instead, two communication flows are used: One between clients and edge servers, and another between edge servers and origin servers.

Content delivery to end-users could be whole-site, where the entire web site is outsourced to a CDN to deliver all its content, or partial-site, where only embedded objects like media and static scripts are delivered by cache servers.

Request Routing

CDN's request-routing network infrastructure is responsible to address client request to appropriate edge servers instead to origin servers generally using the Domain Name System (DNS) employing CDN's own network of globally dispersed name servers. This request redirection outsource the distribution of cached content to the edge servers on behalf of origin servers.

The request routing system in a CDN specifies how to select an edge server in response to a client request, using metrics such as proximity, latency and load. Distribution of client requests are directed considering current network conditions, geographic location, server load and bandwidth available. Main network routing mechanism are DNS-based, Anycast and Global Server Load Balancing (GSLB). DNS-based routing uses customized name servers to address domain names to multiple IP addresses based on client DNS resolver. Anycast routing utilize the same IP address assigned to multiple hosts, holding paths to hosts in the routing table of different IP routers. GSLB routing employs distributed web switches and web caches located around the world to coordinate a global application content delivery service.

Network Optimization

In standard hosting in a central data center, HTTP messages have to travel all the way from user location up to the content origin back and forth. Since a CDN have points-of-presence strategically located around the globe, rount-trip-time (RTT) is decreased, resulting in lower latency and faster content delivery to end-users, reducing web page load times and improving end-user experience.

CDNs accelerate web content delivery employing caching and various network optimization techniques in an end-to-end fashion, focused mainly in the middle-mile, but also reach the first-mile and last-mile.

Caching employs reverse-proxy servers as a network service to store HTTP responses to reduce load times and bandwidth utilization for subsequent requests for the same web object issued by different users.

One type of network optimization technique used is HTTP Multiplexing between the CDN and origin to handle multiple requests and responses from different users over already established connections at origin servers, avoiding unnecesary TCP handshakes overhead. Pipelining of multiple HTTP requests on single TCP connections is also employed to reduce web page loading times.

Delivery of Static and Dynamic Content

Origin's content sits behind any CDN node, which fetch objects from origin as requested from end-users. When the CDN receives a client HTTP request, it is handled from the node that’s geographically closest or in the fastest route to the user.

Distribution of distinct content types is managed using application specific servers and network devices like web switches and reverse-proxy cache servers that handle client requests for either static or dynamic content. Web objects would remain cached in edge servers until they are expired (or purged) causing the CDN to retrieve them again from origin as requested.

When a user requests static content to a website using a CDN it first revise its cache. If the requested object is already in cache, it is delivered directly to the user from the CDN. If the object isn't in cache, the CDN forwards the request to the origin server to fetch the response from it and deliver the object to the end-user, storing it in cache for subsequent users requests.

Requests for dynamic content are generally transparently forwarded to the origin. Some types of dynamic content can be cached using techniques like micro caching, full-page caching, Edge Side Includes (ESI) for web content assembly and by implementing application logic at CDN's edge servers which can generate responses directly back to the end-user.

Secure Content Delivery

CDNs are known to provide better network security to customers in terms of protection against unauthorized access and content modification. Through external caching, a CDN offload traffic from origin and give protection from excessive load and some sort of DoS attacks. Since CDNs already protect themselves from DDoS attacks, customers can benefit from it transparently and reduce potential risks of malicious activity that could interrupt their business. Also SSL offloading is used, maintaining encryption processing at edge servers, reducing load at origin servers.

CDNs also act as a global cloud-based Web Application Firewall (WAF) to protect origin servers from layer 7 attacks like SQL Injection, Cross Site Scripting (XSS) and remote file inclusions.

Cost Savings

CDNs increases reliability and scalability while eliminates the need to invest in expensive infrastructures and dedicated resources to protect web content. This reduce customers internal costs, such as data center capacity, space, and electricity consumption, and lower delivery costs as popular content is cached and delivered through the CDN rather than through the customers own servers.

Also operational costs are reduced without the need to operate a large infrastructure and pay for big Internet pipes that generally remains idle much of the time waiting for peaks of traffic. Instead, customers would spend for infrastructure and bandwidth on demand only in high traffic events as required.

March 29, 2016 by Fernando Garza