gpt4 book ai didi

ruby - 分布式校验和生成

转载 作者:IT王子 更新时间:2023-10-29 06:10:17 25 4
gpt4 key购买 nike

我有一个通过 HTTP 运行的服务,它获取文件 block (通常为 10MB)并将它们作为 block 存储在远程文件系统上。这些 block 的组合将构成一个完整的文件。

我想从 block 中生成一些关于文件的元数据。具体来说,我想生成文件的总文件大小和 MD5 校验和。

结束文件可能相对较大(500+ MBytes)。有没有办法以分布式方式迭代生成校验和?例如,假设我有两个 Web 服务器在负载均衡器后面运行此服务,该负载均衡器在两个服务器之间分配请求。是否可以使用共享 Redis 服务器之类的东西即时生成完整文件的 MD5 校验和?

我试图避免在磁盘上本地缓存 block 或在完全上传后查询远程数据存储以获取实际文件内容。

最佳答案

您可以使用 Merkle Tree 来做到这一点, like Cassandra .

引自 Amazon 的 Dynamo 第 4.7 节,

To detect the inconsistencies between replicas faster and to minimize the amount of transferred data, Dynamo uses Merkle trees. A Merkle tree is a hash tree where leaves are hashes of the values of individual keys. Parent nodes higher in the tree are hashes of their respective children. The principal advantage of Merkle tree is that each branch of the tree can be checked independently without requiring nodes to download the entire [...] data set.

关于ruby - 分布式校验和生成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14329715/

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