Domain Sharding. The hell is it?

Domain Sharding. The hell is it?

Everyone nowadays accesses the web via their respective “Web Browsers”. Web browsers limit the number of active connections for each domain. When the number of resources to download exceeds that limit, users experience slow page load times as downloads are queued.

Developers may split content across multiple subdomains. Since browsers reset the connection limit for each domain, each additional domain allows an additional number of active connections. This lets the user retrieve files from the same source with greater throughput.

domainsharding.jpg

What is it anyway?

Upon connecting to a webpage, the user's browser will go through the HTML page and download all required page resources. Typically, these resources are supplied by a single domain. With domain sharding, the user’s browser connects to two or more different domains to simultaneously download the resources needed to render the web page.

The Magic Number?

Today’s web browsers are capable of supporting 6 concurrent downloads per domain. This number is divided across the total number of resources to give the total number of requests. For example, a website with 30 resources has to do 6 sequential requests for a single user. The “MAGIC NUMBER” would be 4 domains.

Real World Example?

YouTube splits images and script resources across two domains: i.ytimg.com and s.ytimg.com. i.ytimg.com contains icons, logos, thumbnails, avatars, and other visual elements while s.ytimg.com contains JavaScript, CSS, favicons, sprite sheets, and objects related to website optimization and analytics. Users visiting youtube.com will simultaneously download the scripts and media needed to render the page. Because browsers distinguish domains by name rather than by IP address, domain sharding can be performed by a single web server. As long as the server has the bandwidth to support multiple concurrent connections, it can take advantage of domain sharding to quickly distribute content to visitors.