Save downloaded files while synchronizing on multiple servers - PHP Linux

I have a website right now that is currently using 2 servers, an 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 is that the site has users uploading files to the server. How to get downloaded files on both servers?

I do not want to store images directly in the database, as our application is already intensively working with the database.

Is there a way to synchronize the servers with 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 who have helped me understand this question more:

Synchronize files on multiple servers and also Save downloaded files when synchronizing on multiple servers - LAMP

For all, reading this NFS post seems like the best of 2.

NFS will keep files in sync, but you can also use ftp to download files on all servers, but NFS looks like a path.

+7
source share
6 answers

I received a response from a server error:

The most appropriate way to deal with this situation is to split the file share into a separate service. Do not duplicate files if you have a network that allows files to be "everywhere (almost) right away." You can do this through NFS / CIFS or through an appropriate storage protocol such as iSCSI. Set as local storage in the appropriate directory. Depending on your network performance and your storage needs, this can add a couple of undetectable milliseconds to the page load time.

So using NFS to share server files will work OR

as pointed out by @kgb, you can specify one single server to store all downloaded files and force other servers from it (just make sure you run cron or something to back up the file).

+4
source

This is a question for serverfault.
In any case, I think that you definitely need to get into the "cloud". Syncing downloads from one server to another is simply unreliable - you have no idea what errors you can get and why you can get them. Also, the synchronization process will load both servers. For me, the right decision is in the cloud.

If you have chosen a synchronization method, you have several solutions:

  • Use rsync to synchronize the files needed between servers.
  • Use crontab to sync files every X minutes / hours / days.
  • Copy files to any event (user login, etc.)
+5
source

Most sites solve this problem using a third-party specified file server, such as Amazon S3, for user download.

+2
source

Another answer might be to use a piece of software called BTSync, it is very easy to install and use, and you can easily synchronize files to as many servers as you need. Only 3 terminal commands are required for installation.

Look at here


and here

+2
source

You can use the db server for storage ... Not in db, I mean, there is also a web server. It will not greatly increase the processor load, but will require a better channel.

+1
source

you could do it with rsync .. people suggested using nfs .. but this way you create one point of failure ... if the nfs server goes down .. both servers are screwed up ... fix me if im wrong

+1
source

All Articles