Linux – How to Share Assets Between Multiple Web Servers

file-sharinglinuxweb-server

I have multiple Linux web servers attached to a load balancer, and I like to share assets (such as pictures, videos, and other stuff) between these servers. What is the best way to do this?

Currently, I have mounted on a file server to all the web servers, but I am worried about it going down under a heavy traffic. How can I avoid this from happening?

Thanks in advance.

Best Answer

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.

Related Topic