BunnyCDN Blog

Performance tips, updates, tricks and insights into our Content Delivery Network.

Why HTTP/2 Domain Sharding Might Actually Be Hurting Your Performance

Introduction

Performance Tips & Tricks

Why HTTP/2 Domain Sharding Might Actually Be Hurting Your Performance

Posted by Dejan Grofelnik Pelzel on .
Featured

Why HTTP/2 Domain Sharding Might Actually Be Hurting Your Performance

Posted on .

In the past, browsers had a limit of downloading a single request per connection. On top of that, browsers would limit the number of connections per hostname to prevent excessive load on the computers and server. This meant that for each request, the browser would need to send a request, wait for the server to reply and repeat this for every file, potentially hundreds of times.

Domain Sharding

To work around this, various optimization tools such as Pingdom or GTmetrix often suggest splitting your content over multiple hostnames also known as domain sharding. This usually meant splitting different resource types over different subdomains, such as js.mywebsite.com, css.mywebsite.com, images.mywebsite.com to achieve better parallelism. This, however, wasn't perfect as it introduced a different problem. Websites would now need additional DNS lookups and SSL handshakes for each of the connections, causing CPU usage and delays on both the client and the server. While this improved non-sharded configurations, it definitely wasn't an ideal solution.

The Solution: HTTP/2 Multiplexing

Fast forward a couple of years and HTTP/2 is here, bringing a set of new security and performance standards for the modern web. One of them being the new multiplexing feature. Multiplexing addresses the problem described above by allowing the client to request multiple requests that are then transferred at the same time over a single connection. This dramatically reduces the amount of time spent waiting for subsequential requests, reduces the number of DNS requests and only requires a single SSL handshake. This can drastically improve the performance and also minimizes the network congestion, buffering and network retransmits.
As a result, with modern browsers splitting your static content over multiple hostnames might actually be hurting performance by adding unnecessary extra steps for the client and server to spend time on. Most guides and tools have not yet been updated to reflect this and knowing this can shed some extra milliseconds off your load time. BunnyCDN already takes full use of the HTTP/2 protocol so have this in mind when optimizing your website.

Do note, however, that while all modern browsers support HTTP/2, it currently only works over HTTPS connections. If your website is still not taking advantage of the many benefits of SSL we would strongly suggest into upgrading or to stick instead to the older guides that suggest domain sharding to get the best performance.

Dejan Grofelnik Pelzel

Dejan Grofelnik Pelzel

https://bunnycdn.com

The founder of BunnyCDN. An expert in networking, servers and development. Makes sure things are always running fast and smooth.

View Comments...

Categories