存储图像:数据库或文件系统 -

发布于 2024-07-30 01:09:30 字数 355 浏览 6 评论 0原文

我读过一些这方面的文章,但我仍然不明白我的情况最好的解决方案是什么。

我开始编写一个新的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

李不 2024-08-06 01:09:31

您的第一句话表明您已经阅读了有关该主题的一些帖子,因此我不会费心添加涵盖此主题的文章的链接。 根据我的经验,根据您发布的图像数量和图像大小,如果将它们存储在数据库中,您将在数据库性能方面付出高昂的代价。 我会将它们存储在文件系统上。

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.

祁梦 2024-08-06 01:09:31

你使用什么数据库? MS SQL Server 2008 提供 FILESTREAM 存储

允许使用 SQL Server 2008 和 NTFS 文件系统的组合来存储和有效访问 BLOB 数据。 它涵盖了 BLOB 存储的选择、配置 Windows 和 SQL Server 以使用 FILESTREAM 数据、将 FILESTREAM 与其他功能相结合的注意事项以及分区和性能等实现细节。

详细信息

What database are you using? MS SQL Server 2008 provides FILESTREAM storage

allows storage of and efficient access to BLOB data using a combination of SQL Server 2008 and the NTFS file system. It covers choices for BLOB storage, configuring Windows and SQL Server for using FILESTREAM data, considerations for combining FILESTREAM with other features, and implementation details such as partitioning and performance.

details

枕头说它不想醒 2024-08-06 01:09:31

我们使用 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.

躲猫猫 2024-08-06 01:09:30

将所有这些图像放入数据库中将使数据库变得非常非常大。 这意味着您的数据库引擎将忙于缓存所有这些图像(它并不是真正设计的任务),而它本来可以缓存热应用程序数据。

将文件缓存留给操作系统和/或您的反向代理 - 他们会更擅长。

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.

一袭水袖舞倾城 2024-08-06 01:09:30

在文件系统上存储图像的其他一些原因:

  • 即使数据库繁忙或关闭,图像服务器也可以运行。
  • 文件系统是用来存储文件并且非常高效的。
  • 在数据库中转储数据意味着备份和其他操作会变慢。
  • 无需服务器端编码即可提供图像,只需普通的旧 IIS/Apache。
  • 您可以使用非常便宜的 Web 服务器或潜在的 CDN 更快地进行扩展。
  • 您可以在不涉及数据库的情况下执行相关工作(生成缩略图等)。
  • 您的数据库服务器可以在内存中保留更多“真实”表数据,这是您获得数据库查询速度的地方。 如果它使用宝贵的内存来缓存图像文件,那么与内存中更多的照片索引相比,这并不能提高速度。

Some other reasons to store images on the file system:

  • Image servers can run even when the database is busy or down.
  • File systems are made to store files and are quite efficient at it.
  • Dumping data in your database means slower backups and other operations.
  • No server-side coded needed to serve up an image, just plain old IIS/Apache.
  • You can scale up faster with dirt-cheap web servers, or potentially to a CDN.
  • You can perform related work (generating thumbnails, etc.) without involving the database.
  • Your database server can keep more of the "real" table data in memory, which is where you get your database speed for queries. If it uses its precious memory to keep image files cached, that doesn't buy you hardly anything speed-wise versus having more of the photo index in memory.
孤芳又自赏 2024-08-06 01:09:30

大多数大型站点都使用文件系统。

请参阅 将图片存储为文件或存储在Web 应用程序的数据库?

Most large sites use the filesystem.

See Store pictures as files or in the database for a web app?

不念旧人 2024-08-06 01:09:30

处理二进制对象时,请遵循以文档为中心的架构方法,而不是将 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文