PageSpeed: Parallelize downloads across hostnames (deprecated)
Overview
Serving resources from four or five different hostnames increases parallelization of downloads.
How does your site score on this recommendation?
Details
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. The waterfall diagram below shows a page which loads 45 resources from the same host. Notice how long the resources are blocked (the brown segments), before they are downloaded (the purple segments) as they wait for a free connection.
One way to improve the situation is to create multiple sub-domains (eg. static1.gtmetrix.com, static2.gtmetrix.com) so that the number of resources downloaded in parallel is increased. This is referred to as "domain sharding." Because browsers limit connections on a per host basis, creating a sub-domain adds a new pool of connections that the browser can make, allowing more resources to be downloaded at the same time. Taking the same page as above and splitting the resource requests between two domains, you can see that a lot less time is spent blocking and the page loads about 33% faster:
Domain sharding can have a negative effect on performance - it adds DNS request time as well as connection time to each new concurrent connection to the shard (as seen by the green segments in the waterfall); but if utilized correctly, can drastically improve resource load time. Before implementing it, you should read more about the common problems with domain sharding.
Our Recommendations
Your first step towards reducing blocking time should be the reducing the number of resources needed to be downloaded (eg. combine external CSS/JS and use sprites). However, in situations where these optimizations don't help as much (eg. a shopping or image gallery where you can't sprite the images),domain sharding can often help alleviate the problem.
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.
More GTmetrix Resources
For more details on domain sharding, take a look at our extended resources:
<%--Details from Google
The HTTP 1.1 specification (section 8.1.4) states that browsers should allow at most two concurrent connections per hostname (although newer browsers allow more than that: see Browserscope for a list). If an HTML document contains references to more resources (e.g. CSS, JavaScript, images, etc.) than the maximum allowed on one host, the browser issues requests for that number of resources, and queues the rest. As soon as some of the requests finish, the browser issues requests for the next number of resources in the queue. It repeats the process until it has downloaded all the resources. In other words, if a page references more than X external resources from a single host, where X is the maximum connections allowed per host, the browser must download them sequentially, X at a time, incurring 1 RTT for every X resources. The total round-trip time is N/X, where N is the number of resources to fetch from a host. For example, if a browser allows 4 concurrent connections per hostname, and a page references 100 resources on the same domain, it will incur 1 RTT for every 4 resources, and a total download time of 25 RTTs.
You can get around this restriction by serving resources from multiple hostnames. This "tricks" the browser into parallelizing additional downloads, which leads to faster page load times. However, using multiple concurrent connections can cause increased CPU usage on the client, and introduces additional round-trip time for each new TCP connection setup, as well as DNS lookup latency for clients with empty caches. Therefore, beyond a certain number of connections, this technique can actually degrade performance. The optimal number of hosts is generally believed to be between 2 and 5, depending on various factors such as the size of the files, bandwidth and so on. If your pages serve large numbers of static resources, such as images, from a single hostname, consider splitting them across multiple hostnames using DNS aliases. We recommend this technique for any page that serves more than 10 resources from a single host. (For pages that serve fewer resources than this, it's overkill.)
To set up additional hostnames, you can configure subdomains in your DNS database as CNAME records that point to a single A record, and then configure your web server to serve resources from the multiple hosts. For even better performance, if all or some of the resources don't make use of cookie data (which they usually don't), consider making all or some of the hosts subdomains of a cookieless domain. Be sure to evenly allocate all the resources to among the different hostnames, and in the pages that reference the resources, use the CNAMEd hostnames in the URLs.
If you host your static files using a CDN, your CDN may support serving these resources from more than one hostname. Contact your CDN to find out.
--%>