gpt4 book ai didi

python-2.7 - 如何使用 azure cosmos db 最大化数据库上传速率

转载 作者:行者123 更新时间:2023-12-02 07:07:57 26 4
gpt4 key购买 nike

这是我的问题。我正在尝试将一个大型 csv 文件上传到 cosmos db (~14gb),但我发现很难最大化我所支付的吞吐量。在 Azure 门户指标概述 UI 上,它显示当我支付 16600 RU/s 时,我正在使用 73 RU/s。现在,我正在使用 pymongo 的批量写入功能上传到数据库,但我发现任何大于 5 的bulk_write 长度都会抛出硬 Request rates is big. 异常。我这样做错了吗?在这种情况下,有没有更高效的方式来上传数据呢?互联网带宽可能不是问题,因为我正在从 azure vm 上传到 cosmos db。

我现在如何在 python 中上传的结构:

for row in csv.reader:
row[id_index_1] = convert_id_to_useful_id(row[id_index_1])

find_criteria = {
# find query
}

upsert_dict = {
# row data
}
operations.append(pymongo.UpdateOne(find_criteria, upsert_dict, upsert=True))

if len(operations) > 5:

results = collection.bulk_write(operations)

operations = []

如有任何建议,我们将不胜感激。

最佳答案

亚伦.是的,正如您在评论中所说,Azure Cosmos DB MongoDB API 支持迁移工具。您可以在 official doc 中找到打击声明。 .

The Data Migration tool does not currently support Azure Cosmos DB MongoDB API either as a source or as a target. If you want to migrate the data in or out of MongoDB API collections in Azure Cosmos DB, refer to Azure Cosmos DB: How to migrate data for the MongoDB API for instructions. You can still use the Data Migration tool to export data from MongoDB to Azure Cosmos DB SQL API collections for use with the SQL API.

我只是为您提供了一个可以使用的解决方法 Azure Data Factory 。请引用这个doc使 cosmos db 作为接收器。并引用此 doc将Azure Blob存储中的csv文件作为源。在管道中,您可以配置批量大小。

enter image description here

当然,您可以通过编程来完成此操作。您没有错过任何内容,错误请求率较大仅意味着您超出了预配置的 RU 配额。您可以提高 RU 设置的值。请引用这个doc .

如有任何疑问,请随时告诉我。

关于python-2.7 - 如何使用 azure cosmos db 最大化数据库上传速率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52016070/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com