Top reasons not to use Google CDN


Note: This is a post written on August 13, 2010 in my personal website, Bibakis.com.
It has moved here, mostly for archival.

Content Delivery Networks are one of the latest trends on the web. The idea is simple. Instead of having a single server in a central location, place lots of servers of smaller capacity in a variety of locations. This allows you to avoid bottleneck and reduce delivery times.

tortoise-and-rabbit

Some major web companies (most notably Google and Microsoft) have started offering public CDN services to open source projects. A lot of developers advise to use public CDNs in your websites to serve javascript libraries like jQuery and Prototype. Before you make haste to take advantage of this new trend keep the following in mind.

Your websites will be depending on the CDN
Although CDN providers have an advanced infrastructure and are generally considered very reliable, they cannot guarantee 100% availability. In fact even commercial CDNs cannot do that. Given the fact that we are talking about free services here there will be times when the CDN will be offline. If the CDN goes offline so do you.

You are as slow as your slowest part
If a CDN is performing at high speeds then everything will be ok. However consider the following example. If a page from your application takes 4 seconds to load and a javascript library takes 6 seconds to load from the CDN then the loading time for the user is 6 seconds. So while a CDN is often used to offload a site and increase loading speed it may result in the opposite if it’s not in the peak of it’s performance.

The client will have to open a connection to a second domain instead of using the already existing connection to your one. Also the client will be forced to make a second DNS lookup to determine the CDNs IP.

Unsuitable for intranet applications
If you are developing a web-based intranet application then using a CDN will reduce performance. Instead of loading the files from a central location within your Ethernet based network you will be loading them from a much slower internet connection. Also your application will become dependent on your internet connection, therefore disabling the biggest advantage an intranet applications.

Offline development becomes painful
There may be times when you’ll have to develop your application offline for a variety of reasons. Whenever you go offline you must change you code to temporary use local files. This can be a real pain depending on the structure of your application.

JavaScript is cached anyway
JavaScript files are cached by the client’s browser. The only real benefit of using a CDN is for first time users. Are you willing to take the CDN risk just for the chance of increased speed on the single first pageview? I guess that depends a lot on your bounce rate but you get the point.

Conclusion
Before making the decision of using or not a public CDN take some time and make some performance tests of your own. Get YSlow and test loading speeds yourself. This is the only way to see if it makes sense to use a CDN.