开发者

How to store audio files in server (during hosting)

开发者 https://www.devze.com 2023-02-14 09:14 出处:网络
I was thinking of building an app to serve audio content. The first question I get is how to store it. Two obvious solutions that occur are:

I was thinking of building an app to serve audio content. The first question I get is how to store it. Two obvious solutions that occur are:

  1. Dump in database as BLOB
  2. Dump in filesystem, and store path in DB

There was a similar question here and the answer urged to store in file-system. I can think of at least one disadvantage of storing in files, i.e. I loose all backup, recovery and other awesome features of databases.

Also I wanted to know how both solu开发者_JAVA百科tions would fare in terms of scalability.

Does anyone know how flickr or youtube does it?

Or does anyone has even more creative(scalable :)) ideas?


Your file system should have backup and recovery procedures setup if this data is important. (The rest of the application is backed up right?). So you shouldn't use a database just for the backup and restore capability.

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


I would definitely go for Filesystem. storing and deliviring (large) files is exactly what it was made for.


Storing files in a file system would allow for using Content Delivery Networks. Outsource the storage may bring several benefits.


This is a classic question. And a classic argument, with good points for both solutions. Scalability can be achieved with both solutions. Distributed databases are usually easier to handle than distributed filesystems if you grow to the size where all you media dont fit on a single server (but even that is open to debate). Think MongoDB or other NoSQL scalable databases.

It boils down to what features you need. It is very hard to implement transactionality on a filesystem, so if it is a concern to you, you should use a database.


Backup and recovery of filesystem is much easier to implement than proper and consistent backup of the database. Also if you lose a file on the disk, it's just a file. If you lose a part of the huge table, it's a loss of all files contained or referenced in that table (as the table becomes unreadable).

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


I think that both ways are viable. But the backup issue i definately there. Both solutions are scalable given the right design. But big files are probably better of in the file system.

Regards, Morten

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号