Poll: Which is a better storage method?

So I am in the process of coding up a new site with MySQL/PHP … The site will be storing a large number of photos. I am wondering which method would be the best to store the data with. Currently the images are getting uploaded in a raw format, but are going to be resized and store a total of 3 version + a thumbnail. I am trying to plan ahead on the site and assume that it will draw a large bit of traffic and could eventually need to be balanced between a few machines (Yes I know I am thinking big here). But for performance purposes would storing the images as flat files or in a database be a better idea? Let me know what you think, and why. Thanks
[poll id=”5″]

4 thoughts on “Poll: Which is a better storage method?”

  1. Hey Todd,

    Thanks for the info on this. I was thinking that when the time comes that splitting the server into two machines, 1 being web the other being the backend mysql storage server. As long as the tables were setup correctly I figured the overhead wouldn’t be that bad … hmm well maybe I will go back to the flat file storage again. Thanks for the insight

  2. I voted flat file for 2 reasons
    1) Having the web server pull from disk and throwing an image back is going to be faster than pulling from the DB and doing the same not to mention having blobs in your database throws off paging boundaries and can hurt your fetch performance by a fair amount in big selects
    2) Having the images served from disk means that you scale linearly as you add web servers. Otherwise your DB becomes the bottleneck which is a much more expensive prospect to have to upgrade.


    b) By putting all your images on the filesystem you have to work out some sort of syncing methodology (like periodic rsyncs in both directions which is the easiest way or setting up DRBD which is cooler but more complicated). I think you can also use nginx as a load balancer as well where it would look on server A for an image and if it failed it would find it on server B (which would cover the in between times while the rsync was happening for example)

Comments are closed.