2

One of the purpose of a CDN is to distribute your static assets in an area closest to your user. So say my server is at location X and most of my users will be at Y. However the closest CDN server to Y will be at X. What is the advantage of using a CDN if the server will be at the same region as the server? What's the difference than just hosting the image on the server itself and not putting it into a server.

1 Answer 1

4

CDN's have a couple of benefits other than geographic distribution:

  1. Cookie-less domains: if your static content is on a CDN, then your users are not sending your site's cookies with the request for the static file, which will translate to faster requests and response times for CSS, JS, and images.
  2. Parallelized downloads. Browsers usually only download two items at a time on each host. By pushing your content onto CDNs, the browser will open more concurrent downloads for each hostname that you now have.
  3. Speed. CDNs are optimized to send static content quickly, and this can often be better than trying to send it over your generalist webserver that is also trying to generate dynamic content.
  4. Distributed load. It is a bit wasteful to fork an entire Apache process to serve favicon.ico.

For the first two, you should note that it is pretty easy to set up your main server to send static content on an arbitrary number of cookie-less sub-domains. You should also note that having your static content spread across too many domains can kill the performance gain that you get from parallelized downloads due to the round trip needed for a DNS lookup. For the third and forth point, they will really only help if your main server is under a lot of load.

For my money, if you are not experiencing a specific performance issue, a CDN under this situation represents a micro-optimization that should not be bothered with. I would just set up the main server to serve static content from a couple of sub domains and call it a day.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .