Forum Moderators: coopster

Message Too Old, No Replies

Uploading File to Two Servers

         

ladams02

3:07 pm on Aug 24, 2006 (gmt 0)

10+ Year Member



I'm running a blog script that allows user to upload avatars and such files. We have two servers that we run and want the user to upload the file, and have this file upload to both servers. I know you can just have the script open a connection, upload the file, close the connection, and then do this again for the other server. But is there a way to go about synchronizing the directories to take care of this? I guess I'm just looking for the most efficient and standard way to go about this. Thanks!

Frank_Rizzo

3:34 pm on Aug 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do you have full access to both servers?

You can use something like rsync to synchronise between servers but I prefer to use a custom procedure and SCP between servers.

jatar_k

3:37 pm on Aug 24, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



usually you will need to decide which is the master in this situation and which is the slave.

Always changing on one server and having the other sync'ed from it. You need to know which will always be up to date and which will be dependant.

you can run a cron to keep them sync'ed
you could upload to both, always doing the master first

rsync, custom scripts, scp, ftp, cron

who knows, there are a ton of ways you could do it. It is really hard to say which would be the best without understanding the complete scenario. There are more than likely multiple methods that would work all with their own pros and cons.

ladams02

3:44 pm on Aug 24, 2006 (gmt 0)

10+ Year Member



Yes we have full access to both servers. Is using rsync or a custom scp more efficient than having PHP do this as described above? Can you provide any additional information/links on how a custom SCP would work? Thanks.

[Update] I guess I was kind of looking for the standard way this is handled.

jatar_k

4:03 pm on Aug 24, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



trouble is there isn't really a standard, well I guess it would be different for each person you ask.

we used various methods for sync'ing

php scripts
shell scripts (using scp)
rsync

they all worked well, each solution was chosen for the system based on a pro/con analysis, in each case it was the best solution

ladams02

4:52 pm on Aug 24, 2006 (gmt 0)

10+ Year Member



I'm gonna go ahead and do some research on the different methods you guys have brought up to me. But from your standpoint, what would you recommend to be the most efficient path to take. We have a PHP blog script that different users log in and out of. We want the users to be able to upload avatars and various images to a certain directory. The images uploaded in this directory then needs to be immediately transfered over to the directory that is on the second server. The two servers are basically a mirror of each other.

Again thanks for your help and I'll start some research on my own.

jatar_k

5:02 pm on Aug 24, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



writing a shell script or php script that is triggered once the upload is successful to push it to the other server would be the first thing I would look at.