存储在 mysql DB 中肯定比在 HDD 上存储为二进制文件要慢。如果一台计算机无法处理负载,您可以将文件的副本存储在多台计算机上,并使用现成的负载平衡器来管理它。
Storing in a mysql DB will be slower than storing as binary files on a HDD for sure. You could store copies of the files on multiple machines if one machine can't handle the load, and use an off the shelf load balancer to manage it.
A solution that would require a small upfront time investment on your part but that would save you a lot of hassle in the long run... is using a cloud storage service like:
Videos are too big to be stored efficiently in MySQL. Use the file system. Come up with a reasonable way to sort the video files into separate directories, so that you don't end up with thousands of files in a single directory. For example, all files that start with 'a' go into directory 'a', etc.
If your site gets really big, it might make sense to offload your videos to a CDN, such as Amazon Cloudfront.
So for example you have a file of size 50 GB , you can write it on 50 disks in parallel , 1 GB part on each disk , so it you take just 1 second to write and similarly then it should take 1 second to read from 50 disks. Consider file systems like HDFS.
发布评论
评论(6)
通常,在数据库中存储大文件不被认为是好的做法。请参阅此问题和从中链接的内容以获取更多信息。
您可能希望考虑使用 Rackspace Cloud Files 等服务,而不是简单地存储在磁盘上或 Amazon S3(如果您的预算允许)。
Generally storing large files in a database is not considered good practice. See this question and those linked from it for further info.
Rather than simply storing on disk, you may wish to consider using a service such as Rackspace Cloud Files or Amazon S3 if your budget allows.
使用数据库中的 ID 键将文件排序到文件夹中。
取第一个数字,将其放在第一个目录中,第二个数字放在下一个目录中......依此类推:
例如:
18
/videos/1/8/MyvideoFile
1892
/videos/1/8/9/2/MyVideoFile
或者,您也可以排序通过在数据库中存储服务器编号,将它们存储在各种服务器或 NAS 集群上。
希望有帮助。
Use your ID key in the database to sort files into folder.
Take the first number, put that in first directory, second number in next.. and so on:
ex:
18
/videos/1/8/MyvideoFile
1892
/videos/1/8/9/2/MyVideoFile
Alternatively you can also sort them on various servers or NAS clusters by storing a server number in your DB.
Hope that helps.
存储在 mysql DB 中肯定比在 HDD 上存储为二进制文件要慢。如果一台计算机无法处理负载,您可以将文件的副本存储在多台计算机上,并使用现成的负载平衡器来管理它。
Storing in a mysql DB will be slower than storing as binary files on a HDD for sure. You could store copies of the files on multiple machines if one machine can't handle the load, and use an off the shelf load balancer to manage it.
一个需要您进行少量前期投资但从长远来看会为您省去很多麻烦的解决方案是使用云存储服务,例如:
http://aws.amazon.com/s3/
或者
http://www.rackspacecloud.com/cloud_hosting_products/files
它是可扩展的,您的服务器将能够专注于运行您的网络应用程序。
A solution that would require a small upfront time investment on your part but that would save you a lot of hassle in the long run... is using a cloud storage service like:
http://aws.amazon.com/s3/
or
http://www.rackspacecloud.com/cloud_hosting_products/files
It's scalable and your servers would be able to concentrate on running your web app.
视频太大,无法在 MySQL 中有效存储。使用文件系统。想出一种合理的方法将视频文件分类到单独的目录中,这样您就不会在单个目录中出现数千个文件。例如,所有以“a”开头的文件都会进入目录“a”等。
如果您的网站变得非常大,则将视频卸载到 CDN 可能是有意义的,例如 Amazon Cloudfront。
Videos are too big to be stored efficiently in MySQL. Use the file system. Come up with a reasonable way to sort the video files into separate directories, so that you don't end up with thousands of files in a single directory. For example, all files that start with 'a' go into directory 'a', etc.
If your site gets really big, it might make sense to offload your videos to a CDN, such as Amazon Cloudfront.
例如,您有一个大小为 50 GB 的文件,您可以将其并行写入 50 个磁盘,每个磁盘上 1 GB 部分,因此您只需要 1 秒即可写入,同样,从 50 个磁盘读取也需要 1 秒。磁盘。考虑像 HDFS 这样的文件系统。
So for example you have a file of size 50 GB , you can write it on 50 disks in parallel , 1 GB part on each disk , so it you take just 1 second to write and similarly then it should take 1 second to read from 50 disks. Consider file systems like HDFS.