存储图像:数据库或文件系统 -
我读过一些这方面的文章,但我仍然不明白我的情况最好的解决方案是什么。
我开始编写一个新的 web 应用程序,后端将提供大约1-1000 万张图像。 (单个图像的平均大小200-500kB)
我的网站将同时向100-1000个用户提供内容和图像。
我'我还希望使提供商成本尽可能低(但这是次要要求)。 我认为与数据库大小的成本相比,文件系统空间更便宜。
就我个人而言,我喜欢将所有图像存储在数据库中的想法,但任何建议都将非常感激:)
您认为在我的情况下数据库方法是正确的选择吗?
I read some post in this regard but I still don't understand what's the best solution in my case.
I'm start writing a new webApp and the backend is going to provide about 1-10 million images. (average size 200-500kB for a single image)
My site will provide content and images to 100-1000 users at the same time.
I'd like also to keep Provider costs as low as possible (but this is a secondary requirement).
I'm thinking that File System space is less expensive if compared to the cost of DB size.
Personally I like the idea of having all my images in the DB but any suggestion will be really appreciated :)
Do you think that in my case the DB approach is the right choice?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
您的第一句话表明您已经阅读了有关该主题的一些帖子,因此我不会费心添加涵盖此主题的文章的链接。 根据我的经验,根据您发布的图像数量和图像大小,如果将它们存储在数据库中,您将在数据库性能方面付出高昂的代价。 我会将它们存储在文件系统上。
Your first sentence says that you've read some posts on the subject, so I won't bother putting in links to articles that cover this. In my experience, and based on what you've posted as far as the number of images and sizes of the images, you're going to pay dearly in DB performance if you store them in the DB. I'd store them on the file system.
你使用什么数据库? MS SQL Server 2008 提供 FILESTREAM 存储
详细信息
What database are you using? MS SQL Server 2008 provides FILESTREAM storage
details
我们使用 FileNet,这是一种针对成像进行优化的服务器。 这个很贵。 一个更便宜的解决方案是使用文件服务器。
请不要考虑在数据库服务器上存储大文件。
正如其他人提到的,在数据库中存储对大文件的引用。
We use FileNet, a server optimized for imaging. It's very expensive. A cheaper solution is to use a file server.
Please don't consider storing large files on a database server.
As others have mentioned, store references to the large files in the database.
将所有这些图像放入数据库中将使数据库变得非常非常大。 这意味着您的数据库引擎将忙于缓存所有这些图像(它并不是真正设计的任务),而它本来可以缓存热应用程序数据。
将文件缓存留给操作系统和/或您的反向代理 - 他们会更擅长。
Putting all of those images in your database will make it very, very large. This means your DB engine will be busy caching all those images (a task it's not really designed for) when it could be caching hot application data instead.
Leave the file caching up to the OS and/or your reverse proxy - they'll be better at it.
在文件系统上存储图像的其他一些原因:
Some other reasons to store images on the file system:
大多数大型站点都使用文件系统。
请参阅 将图片存储为文件或存储在Web 应用程序的数据库?
Most large sites use the filesystem.
See Store pictures as files or in the database for a web app?
处理二进制对象时,请遵循以文档为中心的架构方法,而不是将 pdf 和图像等文档存储在数据库中,当您开始看到数据库的各种性能问题时,您最终将不得不重构它。 只需将文件存储在文件系统上,并将路径放在数据库的表中即可。 用于序列化并将其保存在数据库中的数据类型的大小也存在物理限制。 只需将其存储在文件系统上并访问即可。
When dealing with binary objects, follow a document centric approach for architecture, and not store documents like pdf's and images in the database, you will eventually have to refactor it out when you start seeing all kinds of performance issues with your database. Just store the file on the file system and have the path inside a table of your databse. There is also a physical limitation on the size of the data type that you will use to serialize and save it in the database. Just store it on the file system and access it.