What is the best way to organize folders for future scaling? I'm in progress to launch a new website. I expect that in the future I will have to deal with storage capacity of uploaded photos, respectively I will have to distribute them on multiple hard drivers. Currently I use something like this:
/1/1/photo.jpg /1/2/photo.jpg . /10/10/photo.jpg
I use part of a file hash as a file name (and store the hash in the database), then organize them into subdirectories based on the first letter (or letters). For example, file
de9f2c7fd25e1b3afad3e85a.jpg
goes toSince hashes are evenly distributed it's easy to split the store to multiple drives, every directory should have about the same number of images. Currently, I have about 2TB worth of images organized like this, and it works like a charm.
Btw, one neat thing about this is if you somehow mess up your filenames, you won't have gazillion of images unorganized, just hash them and you're back to business.
Unique timestamped URLs would be a good start, f.e. 2009/11/30/photo-widthxheight-{other extracted EXIF information}.jpg