Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

stanjovy's avatar

Tips for parallelizable requests optimization

Hello, guys, So i have a problem with parallelizable requests. Basicly what i need to do is "Increase download parallelization by distributing these requests across multiple hostnames" .... But the info i found on the net is somehow not for my case. So the question is, have any of you dealt with such thing and how do you proceed to fix this?

0 likes
5 replies
MikeHopley's avatar

Hmmm, this sounds like a rule from some website performance checker -- and possibly an outdated rule too, from the days when browsers opened fewer connections per host and HTTP2 didn't exist.

The technique is called domain sharding, and it's considered an anti-pattern nowadays. Are you sure you want to do this?

stanjovy's avatar

To be honest, at first it was wierd for me too... But more look into different sites, that are managing it with some static domain, beside there OG, the more i think people are genuenly into doing it. For some reason.

So maybe, to add to the questions above - is this a good practice overall and should/could it be implemented in Laravel?

MikeHopley's avatar
Level 17

But more look into different sites, that are managing it with some static domain, beside there OG, the more i think people are genuenly into doing it.

Most of that is probably from older websites that implemented domain sharding over five years ago. Times have changed, and domain sharding is increasingly pointless.

Domain sharding can be an effective performance optimisation for HTTP/1 connections. But even then, it's only useful if your website has a lot of HTTP requests.

If the browser is connecting via HTTP/2, then domain sharding actually harms performance slightly due to the extra DNS lookup(s).

Domain sharding is somewhat annoying to implement. You have to decide which resources go on which domain. Technically you don't have to buy a second domain, as you can use CNAME alias to "fake it".

At one point I had a setup that randomly (but consistently) assigned my static files to one of two CNAME aliases, s1.domain.com and s2.domain.com. I think I just took the last modified time of the file, and checked whether the last number was odd or even.

It made very little noticeable difference to performance, and it was complicated; so I stopped using it. It was a good example of excessive/premature optimisation.

I recommend you don't waste your efforts on this outdated approach. But if you really want to shard, use two domains (this was the recommendation from Steve Souders and Yahoo). More than two, and you start to see increasing slow down from the DNS lookups.

A more effective option would be to start using a CDN to host your static files, as this reduces latency by locating the files closer to the client. By doing this you actually end up with some domain sharding anyway, especially if you are using multiple CDNs (e.g. a general CDN for JS & CSS, plus an image-specific one like Sirv).

Using a CDN can potentially provide a dramatic performance boost for users who are located a long way from your server. Look for a CDN with HTTP/2, however.

So maybe, to add to the questions above - is this a good practice overall and should/could it be implemented in Laravel?

My answer would be:

  • No, it's arguably bad practice and almost certainly not worth the hassle
  • It's definitely not something that Laravel should offer as part of the framework, but you could do it yourself
1 like

Please or to participate in this conversation.