preloader

Content Delivery Network

images/cdn.png
By J. Toman / on 31 Jul, 2019

Content Delivery Network

A Content Delivery Network (CDN) is a collection of connected data centers around the world that sit between your web visitor and your server, which we’ll call your origin server. When someone visits your web page the CDN first checks the data center closest to your visitor to see if a cached version of the page or any other resources they requested are available there. If they’re not found in the cache, the data center will relay the request to the origin server which supplies the missing resources to the data center. The data center caches them for future use and sends them on to the web visitor. If the visitor is in luck and the data center has a copy of the page or resource, then it delivers that local copy. That’s usually much faster than asking your origin server to rebuild and serve those resources every time a request is sent. Often the data center has a configurable time to live (TTL) after which it considers the content of its cache stale . Stale content is always refreshed from the origin server when there is a request for it, and the time to live on the content is reset. This allows a balance for resources that are only changed infrequently to remain up to date.

Security

A CDN also provides a extra bit of security if configured correctly. The visitor to your website only sees the IP address of the CDN and its data centers but does not see your origin server. Similarly, you can configure the origin server to only accept requests from the CDN, making it more difficult for a would be hacker to poke around the edges of your origin server. Both of these make it harder for a hacker to bypass the CDN and go directly to your origin server.

Edge Computing

Edge computing. Image originally by NoMore201 [CC BY-SA 4.0]

Because the topology of the CDN is designed to make the data center that serves your data local to your visitor, there’s an opportunity there for the CDN to modify the requested resources as they are being returned to the visitor, or even process the requests locally without involving any origin server in a remote data center. This decentralized processing allows the application to be scaled out over smaller, local servers. It reduces the demands that would be placed on the network and allows the request to be serviced faster than it would be if it had to go all the way to the origin server and back again.

A simple example of edge computing is that arrow in the lower left side of this page. That’s created by a little Javascript app to scroll back to the top of this page, but if you looked through the code for this website you wouldn’t be able to find it. The code for that app is inserted at an data center as a Cloudflare App, a service provided by the CDN that Lillibolero uses. That’s a pretty handy way to add functionality to a website without having to clutter the code for it. Much more sophisticated applications of edge computing are possible, including whole applications that run mainly on the edge and store their data in the browser.

Streaming

Another example of the value of a CDN, and an application of the edge computing we just talked about, is the rise of video streaming services on the edge like Cloudflare Stream. Video data is large and costly to move around the Internet, but like all data it’s cheap to store. Using their Stream service, which stores local copies of the video material, you can stream video content to a user relatively inexpensively. This opens up a world of possibilities for video publishing by small organizations that don’t have significant resources to invest in video marketing or training.

Conclusion

For all these reasons, having a CDN as part of your content delivery system is a very good idea, even for small sites that don’t expect a lot of visits. Perhaps especially for small sites as they usually are hosted on modest servers that can easily be overwhelmed by even a small spike in traffic. A CDN like Cloudflare usually offers a free plan with unlimited outgoing bandwidth for personal sites and small companies.