I run a site which has a couple of million photos and gets over 1000 photos uploaded each day. Up to now, we haven't kept the original file that was uploaded to conserve on space. However, we are getting to a point that we are starting to see a need to have high-res original versions. I was wondering if its better to store these in the filesystem as an actual file or if its better to store them in a database (ie: mysql). The highres images would be rarely referenced but may be used when someone decides to download it or we decide to use it for rare processes like making a new set of thumbnails sizes/etc.
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
Yep, as everyone has noted, store the large images in a filesystem (and possibly thumbnails as well). You can hash or UUID them or something to get a reasonable location/unique name, then you can store this (as well as the matching thumbnail or other resolutions if required) location in the database. Then the DB does the search/match/join work for you, and the filesystem does what it's good at: storing files.
Without knowing it the question you are asking is very closely related to content management. Part of the domain of content management is managing attributes of that content - that is your problem here.
Store the images wherever you like that serves your purposes. What you need to do is develop a model for defining an authority for meta-data and variants of the images you produce.
Let's say I have product images. I have a data-development staff, a sales staff, a customer service staff, and an IT staff.
The KEY to this problem is that there must be a database that contains information about all of the images in your organization and the standards you create to affect those images must be reflected in the database that describes all of your images.
When the time comes that you have too many images, (terabytes) and you want to archive images older than 6 years your database will let you know which images, and all variants of those images that need to be archived. You can update the database to indicate those images that are archived (and where) so the image can be restored again if it's truly necessarily.