Is this a subdomain for the purposes of a CDN?

Hello guys,

Since most browsers have a connection limit, people use multiple subdomains to serve images. However I had a query on this.

Traditionally people use files.site.com,files2.site.com and so on. Is it possible to instead use

01.files.site.com
02.files.site.com
03.files.site.com
and so on.

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?

Thanks

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.

Steve Souders has good things to say here too…
“Most of the U.S. top ten web sites do domain sharding. YouTube uses i1.ytimg.com, i2.ytimg.com, i3.ytimg.com, and i4.ytimg.com. Live Search uses ts1.images.live.com, ts2.images.live.com, ts3.images.live.com, and ts4.images.live.com. Both of these sites are sharding across four domains. What’s the optimal number? Yahoo! released a study that recommends sharding across at least two, but no more than four, domains. Above four, performance actually degrades.”
http://www.stevesouders.com/blog/2009/05/12/sharding-dominant-domains/

Note however that this article was written in 2009. If anything, the optimal number of sharded domains is lower today than it was then.

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 :slight_smile:

At amazon, they seem to use single level sub-domains and quite a few different domains as well. Any large player that uses in the format

name1.static.domain.com
name2.static.domain.com ?

In steve’s blog live.com seemed to be using as stated above. Others?

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.