Content Delivery Network or Content Distribution Network, CDN – geographically distributed network infrastructure which allows optimizing delivery and distribution of content to the end network users (source).
Who needs to use CDN and why?
CDN is used in website development. Firstly, it reduces the load on their own servers – static files will give away CDN servers. Secondly, it will increase download time of your application for a user – data will be downloaded from the nearest CDN-server, i.e. through the shortest network route.
1) Amazon: every 100 ms download slowdown of a page will decrease the number of sale by 1 % (Source: Greg Linden, Amazon)
2) Google: 500 ms data results slowdown cause 20% loss of search requests.
3) Yahoo!: 400 ms of additional time for page loading, cause for 5 to 9% increase of number of users that pushed “back” button before the end of loading. (Source: NicoleSullivan, Yahoo!)
Therefore, page loading speed is important! :)
CDN & Drupal
To integrate CDN infrastructure into Drupal sites, we use the CDN module.
For module installation and setting, we need to:
1) apply patch to the core if you use Drupal 6 (Pressflow version and Drupal 7 already have this patch in core)
2) connect to one (or more) CDN networks (the most popular are VoxelCAST, Akamai, Amazon…)
3) fill in the field CDN MAPPING on page /admin/settings/cdn/details.
For all the files to be downloaded from one CDN server, just write a route to it, e.g. «cdn.example.com».
4) turn on CDN usage (route - /admin/settings/cdn, radiobutton status)
Example of advanced setting of field CDN MAPPING
http://cdn.example.com|.css .ico .svg .otf .ttf .swf .zip .rar .gz .7z http://img1.example.com|.jpg .jpeg .png .gif http://img2.example.com|.jpg .jpeg .png .gif http://img3.example.com|.jpg .jpeg .png .gif http://img4.example.com|.jpg .jpeg .png .gif http://media.example.com|.flv .avi .mp3
Why are there 4 hostnames separately for pictures? Downloads in parallel.
As www.browserscope.org asserts that modern browsers by default don’t allow doing more than 6 connection with one hostname. It means that if XXX objects (e.g. pictures) are being downloaded on your site then browser will download simultaneously no more than six.
If we have 4 hostnames, the number of synchronous downloads increases four times. And this accelerates page loading speed a lot.
But one should take into consideration that browsers allow no more than 30-35 connections per 1 page. It means that creation of five and more hostnames will not increase website performance, but vice versa will decrease it because of DNS lookups.