Jump to content

Recommended Posts

Hello

 

Wonder if someone can give some advice.

 

I am working on quite a high volume website (800k+ hits per month) which operates on two load balanced servers.

 

I'm creating an image upload page that will enable users to send images and some other details to backoffice staff. The upload facility will typically allow around 4-5 image uploads at once totalling between 2-10mb of images (need to be quite high res).

 

The intention is to allow backoffice staff to access these images for their own business purposes. But the problem i foresee is that because the servers are load balanced the images will be uploaded to one or other of the servers. So if had the system simply generate a link to a zipped folder of images and email the link to backoffice staff they would end up not being able to access the images if the load balancer directs them to a server other than the one where the images were uploaded - phew!

 

So I'm looking for some advice on the best approach in this scenario:

 

a) setup some kind of sync between the servers - what would you suggest?

b ) store the images in a database - guessing blob data ? The servers both share a mysql service so this seems reasonable.

c) some other ingenious solution proposed by the all knowing people of php freaks :)

 

Any advice is very welcome!

 

Drongo

Edited by Drongo_III
Link to comment
https://forums.phpfreaks.com/topic/274247-image-upload-on-load-balanced-servers/
Share on other sites

  • 3 weeks later...

Setup a network drive and mount it on both servers.  You can either do this through a third server just to store the images or use one of the existing ones as the base.

 

Hi Kick

 

Sorry it has taken a while to respond to this.

 

Lets assume that this isn't possible to setup - because I have very limited control over the hardware in this instance.

 

As a way of doing it via php would perhaps ftping the files via php's ftp functions be a possible solution? Any reasons you would advise not using this?

If you can't do the shared directory, some other options would be

 

- A cron based rsync between the two servers on the images directory.

- A cron based PHP script that will sync the two servers via FTP or something

- Modify your upload script to ftp the file over.

 

 

The cron solutions would not require you to modify any of the upload scripts/procedures but there'd be a delay of however long the cron task is. You'd also need to script the cron in a way that prevents it running several times concurrently.

 

Modifying the upload script would let you only do the transfers when needed and may provide more immediate results, but requires changes to the code, which if you ever were able to move to a shared directory setup would have to be un-done. You'll also probably want to take steps to make sure the transfer to the other server happens in the background so the end-user isn't stuck waiting for the file to both upload then transfer.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.