Will the browsers consider them to be 3 different hosts and therefore allow you those many additional connections, or will they see it as files.site.com and limit the connections?
Should be fine (I’d lose the 0 though). Browsers look at the full host name for their domain connection rules. It’s less important (and useful) these days to shard across a large number of domains though with browsers opening 6 connections per domain.
Yeah, you wouldn’t want to split up the files among too many subdomains. The overhead from all of the additional DNS lookups could potentially offset any advantages you gain from parallelism. So there’s a balance to be made there.
As Patrick said, most browsers today allow 6 (or more) connections per hostname by default. And Firefox allows 8. The last browser to use only 2 connections per host was IE7.
Whenever possible it’s best to combine files to eliminate the need for sharding domains. But perhaps one of the best uses for it is a website with a product database including tons of images, since in that scenario you’re unable to create CSS sprites out of the images. Look at Amazon’s use of subdomains as an example.
We are a community user generated site, so there are tons of avatars/objects per page that need to be fetched just beyond the site assets and that is why we are planning to shard the site assets/user assets efficiently for faster load times.
Thanks for linking steve’s blog. Its a great read. I think we’ll architect the solution to have no more than 4 shards. Yes, its a user generated content site, so it comes with a ton of images - avatars/smilies/actual image uploads and so on - so the use case is right for using shards.
We should use the site assets subdomain to serve all the pages where there is no user generated content. Once the user-gen pages are in, we should use the additional subdomains, might help in not having excess DNS queries as well.
I checked across the web/posted on other forums asking whether the type of subdomains I mentioned will actually be OK with parallel connections and this is the only site with a response and thoughtful responses at that.
My thanks & appreciation to the fantastic community you guys have here
That is mostly to keep cookies off of their static files domain. A lot of large sites will do that.
As far as sharding the user content goes, if you are doing the sharding dynamically, try to make it deterministic so that the same resources will always be served from the same domain (at least for the same visitor) otherwise you could kill the cacheability of the resources.