Question

Is it a good idea to store video files in a database as BLOB objects or store them on a physical disk.

This is for a site similar to youtube where users can upload their video and view them

Database would be Mysql

Which option is better and why

Thanks

Was it helpful?

Solution

Pro MySQL: - The BLOB may be subject to foreign keys and thus keeping the database redundant as opposed to saving to the filesystem. In this case you have to program the deleting of the file. - Finegrained user permissions.

Con: - MySQL doesn't run for free, it comes with overhead as opposed to the serving from the filesystem. - Webservers can't directly serve BLOBs from the database. This means PHP will have to mediate the process. When the BLOB gets loaded from MySQL into PHP, the memory usage will be atleast as large as the BLOB. So in your case where files could be running into the hundreds of MB's this would put enormous strain on the webserver.

In all reality MySQL isn't ment to be used to save files. BLOBs are mostly used to save lare ammounts of serialized data such as caches.

OTHER TIPS

I'm using NFS to store media content from about 5 years with no issues on storage perspective. Manipulating, encoding and saving are managed via ffmpeg, php scripts and cron jobs. Video metadata are stored in a MySql database and web delivery is provided via Nginx (via a read only NFS mount). Video files size up to 2GB in this environment. Probably I can go faster on another db engine but, the real time waste is due to the encoding process and not for saving files.

When I'm saving thousands of little images (like avatars) I ever use MySql just to store files metadata (image path and other properties) and not to save file in a BLOB field who can slow down the db too much on heavy queries.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top