Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I understand how splitting components across domains can maximize parallel downloads, and enable you to have cookie-free static content domains, but since there's a time cost for each domain lookup what is the optimum number of domains to use?

share|improve this question
add comment

2 Answers

up vote 8 down vote accepted

My recommendation is that for relatively simple sites, one "static content" domain should be sufficient. DNS lookups should be cached, so only affect the first contact with that server, but it should still be kept to a minimum.

You can place all of your Javascript, CSS and static images on there to reduce the overhead of cookie processing and to provide the option of offloading that work on to a different physical server. If you are running multiple popular, related sites (e.g. Stack Overflow, Server Fault etc.), then you can share a static site between them all (e.g. sstatic.net).

Of course, there may be situations where more domains are appropriate (e.g. a photo hosting site may offload the photo serving to another separate domain).

share|improve this answer
    
+1 - good general guidance –  JasonBirch Jul 13 '10 at 18:49
    
If you use any JavaScript frameworks, you can also get Google to host these for you (code.google.com/apis/ajaxlibs). This has the added benefit that if the user has already visited another site which grabs JS from Google, they may already have it in cache. –  Michael Mior Jul 15 '10 at 19:19
add comment

I can think of one edge case where the benefits of multi-host requests outweighs the DNS setup costs.

When serving map tiles from a Google Maps-style slippy map, you can see benefits from distributing your tile locations virtually across a much larger number of hosts, even if they are all pointing at the same underlying resources (images). In these cases, you'll want to ensure that the resources have an "affinity" set to one host based on their properties (such as some combination of the MOD of row and column numbers) so that browser caching works optimally and requests are balanced across all hosts for any given view extent.

This situation is very specialized, but it basically just emphasizes that if you have a non-standard use case make sure that you test everything, and don't forget to include both raw numbers and UX / perceived performance of all of the scenarios.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.