I’ve always wanted to get a Content Delivery Network (CDN) and I’ve always put it off, saying, ‘I’ll do it when traffic reaches X’ and, ‘I’ll do it next month’.
But, yesterday I finally bit the bullet and made it happen. As I know that I have a diverse, not entirely technical reader base here and I think CDNs are very interesting, I’ll explain them a little.
When you load a webpage, you aren’t loading one file. You are pulling down the actual page itself, CSS files for styling, JavaScript files to make stuff happen and images. In fact, most of the size of the page is made up of such files rather than the page itself.
My server is located in Atlanta, USA. I chose this location because it is just about in the right place that it can easily serve the whole the USA (where most of my customers are) while still being close to Europe. If you ask for a page in Europe, the data has to be sent all the way from Atlanta, and this takes longer than if the server were in London.
This has never been a problem before, but as my server serves more and more pages (we’re talking monthly figures approaching one million now-a-days) people in Europe and Asia will start to notice a delay.
This is where a CDN comes in. A CDN takes your static files (CSS, images, JavaScript) and stores them around the world at different ‘edge’ servers. For example, my CDN has many servers in the USA, many in Europe and many in Asia. Now, when you visit certain pages on my sites, the HTML content (or PHP page), which is the smallest part, will be loaded from the server in Atlanta, while the larger constituents will be downloaded from your nearest location.
This means that if you are in Europe or Asia you will get much faster page loading. People in the USA (and the rest of the American continents) will get slightly faster speeds as there are extra edge locations within the USA. All of the PHP and HTML comes from Atlanta and all of the database work is done there too, but big data files come over the CDN. I think this is very good.
Getting a little more technical, I upload all of the content via FTP as you normally would to something called the ‘origin server’ at content.smilescdn.com. This website is located on the server in Atlanta. The CDN then pulls the content from Atlanta and stores it in the various edge locations around the world. The URL of the CDN is www.smilescdn.com and is an exact replica of whatever I put on content.smilescdn.com, only it loads much faster. Files are checked by the CDN from Atlanta every 24 hours to see if they have changed (and you can force a file update should you need to). If they’ve changed, the new version is sent to the edge locations.
Oh, one other note, I used Amazon’s CDN, CloudFront. I picked it because you only pay for what you use. There are not upfront or minimum costs. If you only accumulate 1 pence of charges in a month, then that’s all you pay for.
I’ll be doing a more detailed, technical post over on the Deverous Blog soon, so look out for that.
UPDATE: If you are wanting the more technical, review post, it’s here on the Deverous blog now.