Parallelize downloads across hostnames

I recently hosted my new website and I checked Google's Page speed performance analysis. After analyzing my new website I got the below message:

"This page makes 'n' parallelizable requests to www.example.com. Increase download parallelization by distributing these requests across multiple hostnames:"

The explanation takes me to Google's help site at http://code.google.com/speed/page-speed/docs/rtt.html#ParallelizeDownloads but still after reading it I am not entirely clear about what I need to do. After I spending few hours in Internet I got few ideas about - Parallelize downloads across hostnames.

Web browsers put a limit on the number of concurrent connections they will make to a host. When there are many resources that need to be downloaded, a backlog of resources waiting to be downloaded will form. The browser will make up as many simultaneous connections to the server as the browser allows in order to download these resources, but then will queue the rest and wait for the requests to finish. The time spent waiting for a connection to finish is referred to as blocking and reducing this blocking time can result in a faster loading page.

Basically every single call to the server is a request. It means if you have n objects on the page including IMAGES, CSS files and JavaScript files then you will get "n" server request.

The more modules you add to website the more CSS and JavaScript files there will be there. Just go to site config -> performance and enable the optimize CSS + JS option. Try this and see what page speed says.

If it is a bunch of images then try using CSS sprites for repeated images (icons/logo etc) so it only makes one request.

Also if you were to alias your hosts (all to the same IP), you could achieve better parallelization. For example, suppose your site downloads these files:

	
        www.example.com/css/styles.css
	www.example.com/css/common.css
	www.example.com/css/default.css
	www.example.com/css/jquery-ui.css
	www.example.com/js/common.js
	www.example.com/js/widjets.js
	www.example.com/js/jquery.js
	www.example.com/js/jquery-ui.js
	
 

Older browsers (pre IE8/FF3/Safari 3) will download no more than two connections per host. So that means those 8 objects would get downloaded in 4X time. Modern browsers do 8 or more concurrent downloads per host (FF3.5 upped it all the way to 16!) so the report is bringing up something that is less of an issue these days.

However, you could in theory speed up the site for all browsers by making www1, www2, www3, and www4 aliases to the same site and then downloading these files:

	
    	www1.example.com/css/styles.css
        www2.example.com/css/common.css
        www3.example.com/css/default.css
        www4.example.com/css/jquery-ui.css
        www1.example.com/js/common.js
        www2.example.com/js/widjets.js
        www3.example.com/js/jquery.js
        www4.example.com/js/jquery-ui.js
  	      
 

If your site spends a significant time blocking, or a majority of your users use a older browser like IE6/7, then implementing domain sharding should result in significant performance gains. However, depending on how URLs are generated and where resources are being loaded from, implementing domain sharding can be a difficult and time consuming task. If you’ve already reduced the number resources your site loads but still aren’t happy with performance, domain sharding is worth a try.

Of course, the effort to do that is pretty large, so my recommendation would be: if the site is fast for you, don't worry about it. Of course, if you can compress and join the CSS and JS code to a single file, that would be the best thing to do.

Start Parallelizing Files Step By Step:-

  • Create a CDN(Content Delivery Network) ready for your site.
  • Once you have that setup with your website, create new subdomains for this domain. You may choose cdn1.yourdomain.com and cdn2.yourdomain.com or something like that.
  • Go to your cpanel for your website and login. Then, find your “DNS zone editor” in your cpanel under “Domains” and click on it. Then, choose the domain you want to parallelize files for.
  • Go to “Add a CNAME Record” and create two new subdomains for your CDN. In the “Name” box, enter what you want to call it. Example: cdn1.yourdomain.com or something similar. In the “CNAME” box, put your cdn URL name. Then, do the same thing again for one more and call it cdn2.yourdomain.com or something similar to that.
  • Add your two new CNAME records to your CDN zone settings.
  • After another 24 hours, your website will now be parallelizing downloads across multiple hostnames with your CDN.