gpt4 book ai didi

amazon-web-services - AWS S3 读取是否保证返回新创建的对象?

转载 作者:行者123 更新时间:2023-12-04 08:10:38 25 4
gpt4 key购买 nike

我一直在阅读有关 AWS S3 的读写一致性的文档,但我仍然不确定这一点。

如果我将一个对象写入 S3 并且在从我的写入操作中获得成功响应后,我立即尝试读取它,读取操作是否保证返回该对象?

换句话说,读操作有没有可能因为找不到对象而失败?因为在写入后读取发生得太快了?

我在这里只讨论新的 PUT,而不是对现有对象的更新。

最佳答案

Yes 保证返回对象(仅适用于新对象),但有一个警告:

根据 AWS documentation :

Amazon S3 provides read-after-write consistency for PUTS of new objects in your S3 bucket in all regions with one caveat. The caveat is that if you make a HEAD or GET request to the key name (to find if the object exists) before creating the object, Amazon S3 provides eventual consistency for read-after-write.

Amazon S3 offers eventual consistency for overwrite PUTS and DELETES in all regions.



编辑:归功于@Michael - sqlbot,更多关于 HEAD(或)GET 警告:

If you send a GET or HEAD before the object exists, such as to check whether there's an object there before you upload, then the upload is not immediately consistent for read requests even after the upload is complete, because S3 has already made the only immediately consistent internal query it's going to make for that object, discovering, authoritatively, that there's no such key. The object creation becomes eventually consistent, since the creation has to "overwrite" the previous lookup that found nothing.



根据链接中提供的下表,“一致读取”永远不会过时。
enter image description here

上面提供的链接有关于“写后读一致性”和“最终一致性”如何工作的很好的例子。

我想在此答案中添加此注意事项以使事情更清楚:

Amazon S3 achieves high availability by replicating data across multiple servers within Amazon's data centers. If a PUT request is successful, your data is safely stored. However, information about the changes must replicate across Amazon S3, which can take some time, and so you might observe the following behaviors:

A process writes a new object to Amazon S3 and immediately lists keys within its bucket. Until the change is fully propagated, the object might not appear in the list.

关于amazon-web-services - AWS S3 读取是否保证返回新创建的对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44679029/

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