Hacker News new | ask | show | jobs
by vijayaggarwal 4382 days ago
There are so may factors at play in determining the amount of gain from using such a service, e.g.,

1. How widespread the usage is. The more widespread it is, the better the chance of finding the resource in the browser cache itself, instead of having to make external request.

2. Geo distribution of resource by the CDN. The closer the nearest CDN server to the end user, the quicker the delivery.

3. Popularity of CDN domain used to serve the resource. Since a DNS request is potentially involved in fetching the resource, the domain name should be widely used to keep the DNS cachces warmed up.

I am especially skeptical towards adding DNS calls to my page. One for HTML and one-two for static resources is what I have seen works best in practice, especially with modern browsers that do not have the two parallel downloads per domain limit.

1 comments

Another thing to consider is parallel downloads. Last I checked, all browsers limited simultaneous HTTP calls to a single domain. Spreading downloads across domains will increase multithreaded downloading, which on most connections will increase speeds.
Parallelism is complicated: the per-server connection limit has been increased in modern browsers and will change dramatically as SPDY deployment rises[1] and multiple connections per domain becomes a complete de-optimization.

In contrast, the speed of a DNS query is relatively fixed – that initial lookup can take a long time on a cold cache (possibly seconds, particularly internationally) and nothing will transfer until it's completed, so you really need to calculate the time to last byte with that in mind. If you're talking about small, cached files, domain sharding is often a significant step back if the entire transfer can complete over an existing connection in the time it takes to perform DNS + connection for a new hostname. This is particularly interesting when you remember that modern browsers can do DNS prefetching really early so e.g. DNS for your primary domain was completed before someone even clicked on the link and multiple connections were opened as soon as they clicked.

Steve Souders looked at this last year:

http://www.stevesouders.com/blog/2013/09/05/domain-sharding-...

> A middle ground is to alter domain sharding depending on the client: 1 domain for browsers that support SPDY, 2 domains for non-SPDY modern browsers, 3-4 domains for IE 6-7. This makes domain sharding harder to deploy. It also lowers the cache hit rate on intermediate proxies.

1. interestingly, CDNJS has supported SPDY for 2 years: https://twitter.com/cdnjs/status/231227466335797249