Php – Keep Uploaded Files in Sync Across Multiple Servers – PHP Linux

filePHPsynchronization

I have a website right now that is currently utilizing 2 servers, a application server and a database server, however the load on the application server is increasing so we are going to add a second application server.

The problem I have is that the website has users upload files to the server. How do I get the uploaded files on both of the servers?

I do not want to store images directly in a database as our application is database intensive already.

Is there a way to sync the servers across each other or is there something else I can do?

Any help would be appreciated.

Thanks

EDIT: I am adding the following links for people that helped me understand this question more:

Synchronize Files on Multiple Servers
and
Keep Uploaded Files in Sync Across Multiple Servers – LAMP

For all Reading this post NFS seems to be the better of the 2.

NFS will keep files in sync but you could also use ftp to upload the files across all servers as well but NFS looks like the way to go.

Best Answer

This is a question for serverfault.
Anyway I think you should definitely consider getting in the "cloud". Syncing uploads from one server to another is simply unreliable - you have no idea what kind of errors you can get and why you can get them. Also the syncing process will load both servers. For me the proper solution is going in the cloud.

Should you chose the syncing method you have a couple of solutions:

  1. Use rsync to sync the files you need between the servers.
  2. Use crontab to sync the files every X minutes/hours/days.
  3. Copy the files upon some event (user login etc)