保存和获取Azure BLOB存储或SQL SERVER的更好更快的方法是什么?

时间:2022-03-16 16:36:26

[Background] Now I am creating WCF for keeping and getting articles of our university.

【背景】现在我正在创建WCF,用于保存和获取我们大学的文章。

I need to save files and metadata of these files. My WCF need to be used by 1000 person a day. The storage will contains about 60000 aticles.

我需要保存这些文件的文件和元数据。我的WCF每天需要1000人使用。这个仓库里大约有60000个冰。

I have three different ways to do it.

我有三种不同的方法。

  1. I can save metadata(file name, file type) in sql server to create unique id) and save files into Azure BLOB storage.
  2. 我可以在sql server中保存元数据(文件名、文件类型)来创建唯一的id),并将文件保存到Azure BLOB存储中。
  3. I can save metadata and data into sql server.
  4. 我可以将元数据和数据保存到sql server中。
  5. I can save metadata and data into Azure BLOB storage.
  6. 我可以将元数据和数据保存到Azure BLOB存储中。

What way do chose and why ? If you suggest your own solution, it will be wondefull. P.S. Both of them use Azure.

选择什么方式,为什么?如果你提出你自己的解决办法,那将是非常有用的。另外,他们都使用Azure。

1 个解决方案

#1


4  

I would recommend going with option 1 - save metadata in database but save files in blob storage. Here're my reasons:

我建议使用选项1——在数据库中保存元数据,而在blob存储中保存文件。这里是我的原因:

  1. Blob storage is meant for this purpose only. As of today an account can hold 500TB of data and size of each blob can be of 200 GB. So space is not a limitation.
  2. Blob存储仅用于此目的。到目前为止,一个帐户可以保存500TB的数据,每个blob的大小可以是200gb。所以空间不是一个限制。
  3. Compared to SQL Server, it is extremely cheap to store in blob storage.
  4. 与SQL Server相比,存储在blob存储中非常便宜。
  5. The reason I am recommending storing metadata in database is because blob storage is a simple object store without any querying capabilities. So if you want to search for files, you can query your database to find the files and then return the file URLs to your users.
  6. 我之所以推荐在数据库中存储元数据,是因为blob存储是一个简单的对象存储,没有任何查询功能。所以如果你想搜索文件,你可以查询你的数据库找到文件,然后将文件url返回给你的用户。

However please keep in mind that because these (database server and blob storage) are two distinct data stores, you won't be able to achieve transactional consistency. When creating files, I would recommend uploading files in blob storage first and then create a record in the database. Likewise when deleting files, I would recommend deleting the record from the database first and then removing blob. If you're concerned about having orphaned blobs (i.e. blobs without a matching record in the database), I would recommend running a background task which finds the orphaned blobs and delete them.

但是请记住,因为这些(数据库服务器和blob存储)是两个不同的数据存储,所以您无法实现事务一致性。在创建文件时,我建议先在blob存储中上传文件,然后在数据库中创建一个记录。同样,在删除文件时,我建议先从数据库删除记录,然后删除blob。如果您担心有孤立的blobs(例如,在数据库中没有匹配的记录的blobs),我建议您运行一个查找孤立的blobs并删除它们的后台任务。

#1


4  

I would recommend going with option 1 - save metadata in database but save files in blob storage. Here're my reasons:

我建议使用选项1——在数据库中保存元数据,而在blob存储中保存文件。这里是我的原因:

  1. Blob storage is meant for this purpose only. As of today an account can hold 500TB of data and size of each blob can be of 200 GB. So space is not a limitation.
  2. Blob存储仅用于此目的。到目前为止,一个帐户可以保存500TB的数据,每个blob的大小可以是200gb。所以空间不是一个限制。
  3. Compared to SQL Server, it is extremely cheap to store in blob storage.
  4. 与SQL Server相比,存储在blob存储中非常便宜。
  5. The reason I am recommending storing metadata in database is because blob storage is a simple object store without any querying capabilities. So if you want to search for files, you can query your database to find the files and then return the file URLs to your users.
  6. 我之所以推荐在数据库中存储元数据,是因为blob存储是一个简单的对象存储,没有任何查询功能。所以如果你想搜索文件,你可以查询你的数据库找到文件,然后将文件url返回给你的用户。

However please keep in mind that because these (database server and blob storage) are two distinct data stores, you won't be able to achieve transactional consistency. When creating files, I would recommend uploading files in blob storage first and then create a record in the database. Likewise when deleting files, I would recommend deleting the record from the database first and then removing blob. If you're concerned about having orphaned blobs (i.e. blobs without a matching record in the database), I would recommend running a background task which finds the orphaned blobs and delete them.

但是请记住,因为这些(数据库服务器和blob存储)是两个不同的数据存储,所以您无法实现事务一致性。在创建文件时,我建议先在blob存储中上传文件,然后在数据库中创建一个记录。同样,在删除文件时,我建议先从数据库删除记录,然后删除blob。如果您担心有孤立的blobs(例如,在数据库中没有匹配的记录的blobs),我建议您运行一个查找孤立的blobs并删除它们的后台任务。