Reputation: 1571
While interviewing for a job recently, I was asked what storage system I would use for storing video data if I were building a video streaming service.
I proposed a solution where I stored the actual video on a distributed file system (such as HDFS/S3), and store the metadata about the the video (path of HDFS, sharing permissions etc) in a relation database table. This made sense to me and seemed like a clean solution. However, the interviewer kept grilling me about why we couldnt use a relational database to store the actual video itself (as blob data). I gave him some reasons that I thought were appropriate - videos are files and file systems are optimized to store files better, file system caching, read/write performance etc. But his counter to everything was - "you can do that with a database as well...".
Is there a clear reason why videos would be better stored on disk as files as opposed to a mysql database?
Upvotes: 3
Views: 2248
Reputation: 69
To achieve better scalabitlity its better to store video files on different storage so as to better utilise the connections to your DB. Serving video files may hold the connection for a long. With the approach you can have separate service to serve the actual video. More advantages are like when your service have to serve the video in new format, when you convert all the existing videos to new format updating DB would take less time as you just have to add the links to file of new format. Also while sharding a DB you will never come to know which shard will be having more load, its better to add storage to a single pool than adding a storage to differ pool at the back of different shards.
Keeping the videos in the same DB would be catastrophic for maintainability of the system.
Upvotes: 3