To database or not to database

For the past week or so I’ve been thinking about the storage of video files, and how to implement a storage system that is fast, effecient, secure, and reliable. My big question here is to use a database or not to use a database. I’m likely using MySQL for everything else, but video files are a bit larger than you VARCHAR(255) or even larger than a photo gallery image I’d store in a database. I’m concerned that throwing video files, ranging from 100MB to 5GB in a database might start to slow things down… which I really don’t want to happen. On the other hand, I can’t afford to have video files laying around in violation of a database foreign constraint, which might happen if a user deletes a video and the file delete fails (maybe its in use).

I’ve done some work storing large datasets in MySQL, but no work storing >25MB in a single field. Of course there would have to be a seperate media table, to prevent a stray ‘SELECT * FROM videos’ fr0m crashing the whole thing. but that still doesn’t convince me it will be as fast as it needs to be.

Another nice plus on the filesystem side is the mod_flv and mod_h264 streaming plugins for Apache. I know you can write a version of the flv streaming module in PHP, but I don’t see it having the speed of an Apache plugin.

I think ideally I’d like to store videos in the database or using something besides the regular flat file approach. Using Ruby on Rails might make this a moot point from a programming perspective, attachment_fu easily handles both file and database datastores.

If you have any experience storing large files in a database, I’d love to hear about it.

Leave a Reply

Your email address will not be published. Required fields are marked *