How to share assets between multiple web servers?

There are multiple ways to do this based on your needs.

  • Use a central file server mounted with fx NFS on the webservers
  • Same as above, but redundant, so if one goes down the other takes over
  • Use some sort of synchronization tool (rsync for example) and host the files locally on the webservers. Then setup a cronjob to sync the files between the servers at a specific interval.
  • Use a CDN such as Amazon S3, Akamai etc.

The first two are best if you have a lot of new files coming. The third would be the ideal solution if you don’t add or change files that often since the users will get 404’s on static content not yet synced..

The last option might be ideal in many ways, but might also turn out to be the most expensive of the 4. You would also need to rewrite your websites to support this.

Leave a Comment