Websites that load faster are more engaging and more likely to make conversions, here’s how I do it.
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.
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.
Browser Concurrent Connections
|Browser||CC per hostname (HTTP/1.1)||Maximum Conns|
|IE 6, 7||2||35|
|IE 8, 9||6||35|
|Firefox 3, 4||6||30|
|Safari 4, 5||6||30|
|Chrome 1, 2||6||60|
|Chrome 5, 6, 7||6||30|
|Chrome 8, 9, 10||6||35|