Coppermine is a PHP photo gallery platform. Some photo galleries can grow to gargantuan proportions. One gallery in particular has over 1,000 galleries with nearly 100,000 images – we’re talking well over 30GB of images and has severely heavy traffic.
Needless to say, we wanted to offload a good chunk of that bandwidth to a CDN, and one of the most affordable and scalable CDN’s out there is Amazon Cloud Front. Amazon Cloud Front has a mirror option, but there’s also an option to store the files in an S3 bucket to relieve the space on the origin server.
My solution was to run a script triggered by a cron job that scans images in the images folder on the web server, checks if they’re in the s3 bucket. If an image is in the bucket, then it deletes the image on the server. If it’s not there, then it uploads the image, verifies the image was uploaded, and then deletes it off the web server. It also has a built-in timeout so it doesn’t bog the server down too much.