简体   繁体   English

存储大量图像数据库或文件系统

[英]Storing large number of images database or filesystem

I am working on a project where we need to store large no of images say some 10 millions so which is the best way to store the images.Best way in terms of speed and efficient. 我正在开发一个项目,我们需要存储大量没有图像说大约1000万,所以这是存储图像的最佳方式。在速度和效率方面最好的方式。 It is a web based project so the image retrieval should be fast. 它是一个基于Web的项目,因此图像检索应该很快。

  1. Database 数据库

    Storing images as base64 in database. 将图像存储为数据库中的base64。
    we are working on a nosql database. 我们正在开发一个nosql数据库。

  2. File System 文件系统

    To make an unique id and store it under an folder. 创建唯一ID并将其存储在文件夹下。

1)Database 1)数据库

  • will require much code for processing image as using streams 将使用流来处理图像需要很多代码
  • Heavier load on the database server 数据库服务器上的负载较重
  • database storage is usually more expensive than file system storage 数据库存储通常比文件系统存储更昂贵
  • databases win out where transactional integrity between the image and metadata are important. 数据库赢得了图像和元数据之间的事务完整性很重要的地方。
  • it is more complex to manage integrity between db metadata and file system data 管理db元数据和文件系统数据之间的完整性更加复杂
  • it is difficult (within the context of a web application) to guarantee data has been flushed to disk on the filesystem 很难(在Web应用程序的上下文中)保证数据已经刷新到文件系统上的磁盘

2) File system 2)文件系统

  • To store images on a unique id and storing it to harddisk will be a better option . 将图像存储在唯一ID上并将其存储到硬盘将是更好的选择。
  • things like web servers, etc, need no special coding or processing to access images in the file system 像Web服务器之类的东西,不需要特殊的编码或处理来访问文件系统中的图像

refer http://perspectives.mvdirona.com/2008/06/30/FacebookNeedleInAHaystackEfficientStorageOfBillionsOfPhotos.aspx 参考http://perspectives.mvdirona.com/2008/06/30/FacebookNeedleInAHaystackEfficientStorageOfBillionsOfPhotos.aspx

also see Storing Images in DB - Yea or Nay? 还看到在DB中存储图像 - 是或不是?

There is a trade off - it will depend on your exact situation and needs. 有一个权衡 - 它将取决于您的确切情况和需求。 The benefits of each include 每个的好处包括

Filesystem 文件系统

  • Performance, especially caching and I/O 性能,尤其是缓存和I / O.

  • Storing file paths in the database to be best. 将数据库中的文件路径存储为最佳。

There are a couple of issues: 有几个问题:

  • database storage is usually more expensive than file system storage 数据库存储通常比文件系统存储更昂贵
  • you can super-accelerate file system access with standard off the shelf products 您可以使用标准的现成产品来加速文件系统访问
    • for example, many web servers use the operating system's sendfile() system call to asynchronously send a file directly from the file system to the network interface. 例如,许多Web服务器使用操作系统的sendfile()系统调用将文件直接从文件系统异步发送到网络接口。 Images stored in a database don't benefit from this optimization. 存储在数据库中的图像不会受益于此优化。
  • things like web servers, etc, need no special coding or processing to access images in the file system 像Web服务器之类的东西,不需要特殊的编码或处理来访问文件系统中的图像
  • databases win out where transactional integrity between the image and metadata are important. 数据库赢得了图像和元数据之间的事务完整性很重要的地方。
    • it is more complex to manage integrity between db metadata and file system data 管理db元数据和文件系统数据之间的完整性更加复杂
    • it is difficult (within the context of a web application) to guarantee data has been flushed to disk on the filesystem 很难(在Web应用程序的上下文中)保证数据已经刷新到文件系统上的磁盘

Database 数据库

  • Easier to scale out to multiple web servers 更容易扩展到多个Web服务器
  • Easier to administer (backup, security etc) 更易于管理(备份,安全等)

If you have a SQL 2008 DB, have a look at FileStream in this SO article - this gives the best of both worlds. 如果你有一个SQL 2008数据库,请看这篇SO文章中的FileStream - 这可以提供两全其美的优势。

See Storing Images in DB - Yea or Nay? 请参阅在DB中存储图像 - 是或否?

Edit 编辑

See for Nosql: 参见Nosql:

  1. Is it a good idea to store hundreds of millions small images to a key/value store or other nosql database? 将数亿个小图像存储到键/值存储或其他nosql数据库中是一个好主意吗?
  2. Storing images in NoSQL stores 在NoSQL商店中存储图像

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM