Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

If I understand this correctly, I have two options for static files:

  1. Use a CDN and throw all my static files on it.
  2. Use a separate domain just to store the static files so users can download it simultaneously.

So I assume it is either one to choose or do i need a separate domain then use a CDN to get files from that domain? Because I assume even if I have a CDN I still need to have a local copy of the static content somewhere either on my main site or a static content site like static.domain.com?

share|improve this question

2 Answers 2

Depending on the way you have your CDN setup, it is likely you will need a separate domain to store the static files as the origin that the CDN caches off of. Whether or not to use a CDN depends on the performance requirements of your applications, rather than the network architecture.

If you are serving a very large amount of content that will require you to purchase a significant amount of additional bandwidth, or if you have stringent response time requirements and want to locate the files near to the end user, the investment in a CDN is probably a wise choice. Essentially, a CDN is simply a caching layer in front of your own files a la Varnish, but geographically distributed.

The most frequent arrangement that you see it used is to setup a domain (origin.example.com) that serves your static files. However, when you source the files, instead of pointing at the origin you point at the domain that you've setup to point the CDN at (static.example.com). The CDN will automatically keep cached versions of your files in a certain number of teirs and reduce the load on your server, called the "origin server". Many CDNs only use a single layer of caching, called the edge layer, but some also include a second teir called the midteir. In that case, you might have n edge servers spread across the globe which query regional master servers called the midteir servers. Those then will refresh against the origin, to further reduce the number of hits that the origin server gets.

share|improve this answer

You don't need a CDN or separate domain to serve up static files effectively. A caching (reverse) proxy will be very effective. Just make sure you have your headers set accordingly. I would suggest looking at Varnish and Nginx.

If you're concerned about scaling and performance, I would also recommend the writings of John Allspaw and Theo Schlossnagle.

share|improve this answer

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.