I currently run a popular classifieds website which runs on 2 servers. There are currently 2 servers, one webserver and one database server. They are running Linux and the website is coded in place and MySQL.

I am in the process of upgrading the servers as the site is outgrowing the existing server setup. I have bought another server to act as another webserver which is conneced to the existing 2 servers in a private network. So I would have 2 we servers and one database server.

The website has a large number of images continously uploaded and removed from the website by the users. The original idea was to have the 2 web servers sync files including images. But I think due to the large number of images to sync, there maybe issues with the images not being synced straight away.

I am just trying to find out the best and most robust solution to this, as I am sure it's a common issue a lot of growing websites must face.

The ideas I had so far are:

1) sync both webservers. Could be slow and times when images are not yet available on both servers. 2) mount images directory so that both webservers upload to same directory. Would this slow uploading of images? 3) change upload photo php script to upload to Amazon s3 bucket and serve images using anmazon cloud front. Although I think this maybe expensive due to the large number of images the website serves each month.

Any ideas or links to further reading would be great.

  • #3 is the most desirable solution, #1 the least. You can address your concerns about cost with the estimator tool. I agree with EJB that Cloudfront is nice, but not necessarily required. – Sammitch Mar 11 '16 at 23:18

By far the easiest, best and definitely most robust solution is going to be to use the S3 option - with or without cloudfront.


Images are typically static content so they cache really well. If your solution design can leverage that it doesn't really matter if the actual permanent storage is somewhat slow or costly.

Either your webservers each operate their own cache, or leverage an external cache i.e. that of a Content Delivery Network.

For many applications a (highly available) file share is still a very suitable and commonly deployed solution to share content between servers.

Alternatively don't store files on a file-system at all but use the database and store them as BLOB's instead. A very common approach. Since you already need a database anyway and this makes application servers almost stateless, solves a lot of locking, replication, HA, consistency and access problems by shifting them to the database layer, where a lot of those problems are old news, well understood and solved.

  • Good lord, do not store images in a database, and certainly not mysql. If we were talking about a handful of icon-sized images, perhaps, but a large number of mid-to-large images? Absolutely S3. This is why S3 exists. – Sammitch Mar 11 '16 at 23:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.