Nowadays we often hear people talk about CDNs. But there is another, less known term—domain sharding—which is confused with CDN very often, even though the two technologies are completely different.
What is Domain Sharding ?
Too often we read tutorials about setting up a CDN where in fact domain sharding is described.
Traditionally, browsers limit the number of simultaneous requests to a single domain. That restriction has been defined in the specifications of the HTTP/1.1 protocol: the goal was to not overload the query servers.
Domain sharding has been set up to circumvent the allocation of static files (images, CSS, JS) on multiple subdomains. That way it is possible to multiply the number of simultaneous requests by the number of subdomains.
Using domain sharding gives us the possibility to load content on cookie-free subdomains.
However, this solution is not flawless. In fact, each subdomain adds additional DNS resolution which usually is significant in terms of performance. A DNS resolution is the correlation between the URL and the IP address associated with it. This request takes between 120 and 200 ms before being resolved.Each DNS request takes between 120 and 200 ms before being resolved. Click To Tweet
Just a few years ago, the practice of domain sharding was highly recommended. Today things have changed for many reasons.
Internet browsers have evolved enormously. These days they perform 6 simultaneous requests per domain (when IE only allowed 2) on average. With a small number of HTTP requests, the establishment of domain sharding can be contra-productive.
On mobile connections, DNS resolutions are much longer than with a conventional connection. An excessive use of domain sharding could be very expensive in terms of performance.
Should We Still Use Domain Sharding?
There is no universal answer to this. Everything depends on your website and on the number of HTTP requests it realises. Generally, it is recommended to not use more than two subdomains.
You should also note that the HTTP/2.0 protocol will make this practice outdated. This is already the case for SPDY, the experimental protocol created by Google.
If you’d like to investigate the subject, we recommend these articles for reading:
What Is a CDN?
The term CDN stands for Content Delivery Network. It is often confused with domain sharding, although it is something totally different.
A CDN works by increasing the number of servers in multiple worldwide locations: it can deliver your content to visitors who are geographically closer to it. Every HTTP request made by the user is well served by the server nearest to his/her position.
A CDN is usually used with subdomains profiting from the cumulative effect of domain sharding.
When Should a CDN Be Used?
The setting of a CDN service is recommended for every site having an international audience. In the case of a French website hosted in France and with a French audience, the use of a CDN is questionable. Especially considering that the prices of these services are not negligible.
Now you have all the necessary information for not confusing these two different techniques, CDNs and domain sharding. The gist of it:
- Domain sharding is a distribution of resources between different domains, with the aim of overcoming the limitations imposed by browsers.
- A CDN is the hosting of website resources on different servers spread around the world.
The choice between a CDN and/or domain sharding has to be made according to the characteristics of your project and to your budget.