Parallel Downloads Across Domains
Parallel downloads are simply multiple downloads that take place concurrently across multiple domains hosted by one host. The main benefit of parallel downloads is reducing download time when downloading many resources.
It is important to note that web browsers aren't designed to allow parallel downloads. Typically, web browsers limit the number of concurrent connections made to a host. Commonly they are limited to 6 concurrent transfers.
This results in a backlog of resources when there are many assets waiting to be downloaded. Browsers establish as many simultaneous connections as possible but queue the resources to ensure they are downloaded one at a time. This automatically increases the time it takes to download resources from the same host. Parallel downloads, also known as domain sharding, reduce the time it takes for a connection to be complete which results in faster page loading and download speeds.
Pros
- Faster download speeds: By creating multiple subdomains, the number of resources being downloaded concurrently increases. Since browsers limit connections based on host basis, creating sub domains adds new connection pools that browsers can make allowing more concurrent downloads.
- Faster page loading: Parallel downloads allow splitting of resource requests between many domains. As a result, little time is spent blocking pages. This ultimately increases the time it takes to load pages by approximately 33%.
Cons
Although parallel downloads can help reduce the time it takes to download resources/load resources on pages, there are a number of cons you must consider before using parallel downloads across domains on your site. Below are the main cons to consider.
- Parallel downloads result in more DNS lookups and increase the time it takes to create initial connections when there are too many downloads taking place which may in turn has a negative impact on performance. It is therefore important to ensure the connection time and extra DNS lookups are worth it.
- Your assets stands to lose caching benefits if you don't make sure resources are consistently served from similar subdomains. It is important to use a single Zone with Zone Aliases to achieve the positive effect.
- You stand to incur additional costs i.e. the cost of buying an SSL certificate for subdomains or buying an entire wildcard SSL certificate if your site needs HTTPS. You don't have to buy any SSL certificates for subdomains if your site isn't HTTPS because you can pass resources via your primary domain.
- Many browsers have a same-origin policy that prevents cross domain violations. Parallel downloads can expose your website to potential security threats when moving static content to separate domains or subdomains. Consider enabling CORS.
- SPDY, receptively HTTP/2 in 2016 (as it will replace SPDY), make domain sharding obsolete but not yet every browser supports SPDY.
Conclusion
One of the best ways of reducing download/page loading time is to reduce the number of resources that need to be downloaded via sprites or combine and minified external CSS/JS. However, in situations where such optimizations don't make a significant difference, parallel downloads come in handy. If your website takes a lot of time blocking or most of your website users use older browsers i.e. IE6/7, implementing parallel downloads across domains will offer significant performance gains. It is however important to be aware of the challenges you stand to face and how to overcome them.