3 Reasons Why You Should Use a CDN
One of the fundamentals of web performance optimization is the use of a Content Delivery Network (CDN). CDN's distribute your application's assets around the globe. They are the logistics of your application's resources. This makes then physically closer to your end user. When files do not need to travel as far they get to the requester faster. When I first read I need to use a CDN in Steve Souders' book I thought he was nuts. The rise of cloud services has made CDNs a low cost commodity that anyone can afford. There are three core reasons you should use a CDN today.
Light travels at 299,792,458 meters / second, which sounds really fast. Remember sunlight takes 8 minutes and 20 seconds to reach Earth. On the Internet you add friction forces, routers and other hops across the Internet and a packet's speed is not near the speed of light.
When content is hosted physically near the end user it does not need to travel near as far, which of course if faster. CDNs help make this possible. You just need to upload the file to a central server and it is automatically distributed to the other servers around the world. The CDN provider manages routing the requests to the closest physical server.
Fiddler, the popular network sniffing tool, provides estimated information on how long a request to various parts of the world might take using an estimation formula. The formula produces estimated results and they are available in the statistics panel.
While this is not an real world measured value, it should serve as a guideline of end user discomfort caused by your distant assets crossing the globe.
When static assets are served from a CDN they are not on your web server. When a file is served it must come from the disk. Anytime you hit the disk you are creating a server-side performance hit because disk I/O is very expensive. You have also used your web server's (IIS, Apache, etc) threads that could otherwise be allocated to serving dynamic content.
While some markup is static, often an application uses some sort of rendering. Even for a properly built SPA the markup has some server-side rendering involved. So these web servers are tuned for dynamic content, run through services like ASP.NET, node, ruby, etc.
Today you can host your content in Azure or AWS for next to nothing. I moved my images to Amazon's S3 many years ago and have layered CloudFront on top of the bucket. My monthly cost is usually less than 15 cents US. Granted this Blog and other other applications I host generate a small traffic volume, it is very cheap.
In the past there were not many CDN options and all were very expensive. Today there are many. Shop around to find the one that best suites your needs. CDNs tend to customize in a specific areas. Some are faster, others more distributed and so on. If you are just starting out both Azure and AWS have easy to setup, low cost solutions.
A CDN is something every web owner should utilize. They will help your application perform better, allow your web server to scale and do not cost an arm and a leg. Please invest some time and start using a CDN today.