How to store audio files on the server (during hosting)

I was thinking of creating an application for serving audio content . The first question I get is how to save it. There are two obvious solutions:

  • Dump in the database as a BLOB
  • Dump in the file system and save path in DB

Here was a similar question, and the answer was requested for storage on the file system. I can come up with at least one drawback of file storage, that is, lose all backups, restores, and other amazing database features.

I also wanted to know how both solutions would deal with scalability.

Does anyone know how flickr or youtube does it?

Or does anyone have more creative (scalable :)) ideas?

+4
source share
6 answers

Your file system must have backup and recovery settings if this data is important. (Is the rest of the application copied correctly?). Therefore, you should not use the database for backup and recovery purposes only.

Saving files outside the database allows you to separate your databases and file servers, which will be a plus on the scalability side.

+6
source

I would definitely go for the file system. storing and sending (large) files is exactly what it was done for.

+2
source

Saving files to the file system will allow the use of content delivery networks. Outsourcing storage can bring several benefits .

+2
source

Backing up and restoring a file system is much easier than properly and sequentially backing up a database. Also, if you lose a file on disk, it is just a file. If you lose part of a huge table, this is the loss of all the files contained or mentioned in this table (as the table becomes unreadable).

Of course, for small databases where you can disable the DBMS and quickly copy all the DB files, all of the above is not applicable, but this scenario is almost the same as the data files on the disk.

+1
source

This is a classic question. And a classic argument, with good points for both decisions. Scalability can be achieved with both solutions. Distributed databases are generally easier to handle than distributed file systems if you grow to a size where all your media do not fit on the same server (but even this is open to discussion). Think MongoDB or other scalable NoSQL databases.

It comes down to what features you need. It is very difficult to implement a transaction in the file system, so if this bothers you, you should use a database.

+1
source

I think both ways are viable. But the backup problem I am definitely there. Both solutions are scalable with the right design. But large files are probably better on the file system.

Regards, Morten

0
source

Source: https://habr.com/ru/post/1341649/


All Articles