Drongo_III Posted February 9, 2013 Share Posted February 9, 2013 (edited) 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 February 9, 2013 by Drongo_III Quote Link to comment https://forums.phpfreaks.com/topic/274247-image-upload-on-load-balanced-servers/ Share on other sites More sharing options...
kicken Posted February 9, 2013 Share Posted February 9, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/274247-image-upload-on-load-balanced-servers/#findComment-1411321 Share on other sites More sharing options...
Drongo_III Posted February 26, 2013 Author Share Posted February 26, 2013 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? Quote Link to comment https://forums.phpfreaks.com/topic/274247-image-upload-on-load-balanced-servers/#findComment-1415093 Share on other sites More sharing options...
kicken Posted February 26, 2013 Share Posted February 26, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/274247-image-upload-on-load-balanced-servers/#findComment-1415155 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.