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

Browsers only allow you to download a limited number of concurrent files from the same domain.

Would a subdomain for images (basically as a content delivery network) on the same web hosting server increase the number of files that can be downloaded simultaneously?

(And thus improve page loading time?)


Consider this example:

www.example.com
img.example.com

The img subdomain is hosted on the same web server (same IP & location) as the www domain.

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

Yes or no. Your assumption is correct and that more resources can be loaded in parallel by the browser if they are served from multiple domains. There are two cases to consider though:

  1. Your server is not presently serving at maximum capacity: In this case more requests being served simultaneously is better. Visitors who's download bandwidth is not already maxed out will see reduced page-load time.

  2. Your server is serving at maximum capacity: There will be little change, it may even slow down due to the overhead of getting and handling more requests. The way to speed up in this case is either to upgrade the server or use an actual CDN network.

You should look at your server performance logs to see which is the case. CPU usage is a good indicator when images are expected to be cached for the general case (you serve mostly the same images over-and-over). Disk usage is a better indicator when your image set is so large that it wont be cached so often (you serve different images to different users as for most personal gallery sites).

share|improve this answer
    
Great, thanks! What about on a shared server, is this log information easily available/compile-able? –  Baumr Mar 20 '13 at 20:34
1  
If they allow ssh do a 'top' or some shared hosting has this information in the control panel. Still believe that if you want good speed then ditch the shared hosting, go for VPS + CDN. Trying to pimp up shared hosting is like trying to pimp a wheelbarrow rather than pimping a BMW. –  bybe Mar 20 '13 at 21:28
1  
@Baumr - That depends how they do it. If you are allocated a slice of CPU, you will see a graph of your usage. In a load-balanced system, you have a cap and your process is throttled-down when it exceeds a certain limit. They gather statistics about how much this occurs per certain period of time. –  Itai Mar 21 '13 at 0:26
add comment

Short answer yes using a sub domain will enable parallel downloading that can will improve the amount of fetches sent and received at any one time, also you can setup the sub domain to be cookieless with good expires which will further emulate the use of a CDN.

But bear in mind the following:

  • CDN mirrors your files all over the globe and speeds up the site for people all over the globe.
  • CDNs are extremely cheap.
  • Good CDNs do not slow down and scale with demand.
  • CDNs do not eat up your server resources up while server providing all the client requests can.
  • Using a CDN adds an additional layer of security if the main site gets hacked, Assuming you don't bare your API key.
  • CDN provide also API based features that allows you do to lots of funky stuff.
  • Data loss doesn't really happen on CDNs since 1, your files are mirrored all over the globe and 2 they use fail proof raid setups while your own server may not.
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.