Table of Contents

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.

History

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.

A website with many HTTP requests (images, CSS files, JavaScript, etc.) thus was penalised by that limit.

Definition

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.

Just a few years ago, the practice of domain sharding was highly recommended. Today things have changed for many reasons.

Browser Evolution

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

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.

Definition

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. Otherwise, a CDN has many benefits you may want to take advantage of.

In Conclusion

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.


Comments (11)

If using a CDN it seems it's best to limit yourself to a single subdomain instead of using multiple shards as suggested by sites such as Pingdom, is this correct?

I was using http://cdn.domain.com for CSS, http://cdn2.domain.com for JS and http://cdn3.domain.com for images; however, it seems with HTTP2 and SPDY this is actually going to hinder the performance.

How about with HTTP1 support only though?

When adding the CDNs to WP-Rocket does it matter which order they are loaded in? For example: Should images be added before CSS & JS for the CDN subdomains?

Hi Jonathan,

Great explanation. How about SSL and non SSL performances? If I read somemore correctly, HTTP2 requires SSL (and provided the browser supports it).

Thanks & regards

Hi Jonathan,

Is that a reason why wp-rocket.me is not using SSL?

My site does call an external javascript, hence HTTP2 would be great, but just worried that after enabling free Cloudfare SSL it would affect the speed and the seo.

What is your suggestion? To go with SSL or non SSL? It seems in future all websites will be SSL, just look at free wordpress.com site, all with ssl now.

I imagine the best case scenario is a CDN combined with domain sharding. To be honest I've never even heard of domain sharding so this is interesting.

This is a pretty lax article honestly.

First... who should use a CDN? Honestly, almost everyone - even if you only have a local presence. Why and Which CDN to use... now, that's another story. Why do I say everyone should - especially small, local businesses. Because there are services out there, like Cloudflare, which puts your "origin" server behind the front facing Cloud that clients see. This is a fantastic security benefit for a small, local business --- one that many small, local businesses cannot afford normally.

Next - Domain Sharding. If you're using a CDN that utilizes HTTP2, then there isn't really a need for sharding normally... unless you have, for example a VPS or Dedicated server, but can only afford the base model with very limited disk space. So, you shard off the static files (images, CSS, js, etc) that don't need the speed benefits (like from compiling server side scripts/php) of the VPS/Dedicated into a plan that offers much higher disk space (like the Unlimited plans with GoDaddy or Namecheap)... and then you also put those behind the CDN that offers HTTP2 to help further protect the origins.

The other posts are correct, but another reason would be that you can optimise a server which only serves "static" files for doing that specific task. Other servers which run scripts or database connectivity need to do a certain amount of "thinking" before they send back content, whereas a server which sends back only files can be lean and mean.

Related Articles of Page speed and caching
Subscribe to Our Newsletter

Stay in the loop with the latest WordPress and web performance updates.
Straight to your inbox every two weeks.

Get a Faster Website
in a Few Clicks

Setup Takes 3 Minutes Flat
Get WP Rocket Now