是否保证可以读取AWS S3返回新创建的对象? [英] Is AWS S3 read guaranteed to return a newly created object?

查看:88
本文介绍了是否保证可以读取AWS S3返回新创建的对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在阅读有关与AWS S3的写后读取一致性的文档,但是我仍然不确定.

I've been reading the docs regarding read-after-write consistency with AWS S3 but I'm still unsure about this.

如果我向S3写了一个对象,并且在写操作中获得成功的响应后,我立即尝试读取它,那么读操作是否可以保证返回对象?

If I write an object to S3 and after getting a successful response from my write operation, I immediately attempt to read it, is the read operation guaranteed to return the object?

换句话说,读取操作是否可能因为找不到对象而失败?因为读是在写之后太早发生的?

In other words, is it possible that the read operation will fail because it can't find the object? Because the read happened too soon after the write?

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

I'm only talking about new PUTs here, not updates to existing objects.

推荐答案

是的,要保证返回带有警告的对象(仅适用于新对象):

Yes guaranteed to return the object (only for new objects) with one caveat:

根据 AWS文档:

Amazon S3为新PUTS提供写后读取一致性 请注意,所有区域中S3存储桶中的所有对象均需注意.注意事项 是如果您向键名发出HEAD或GET请求(以查找是否 对象存在)在创建对象之前,Amazon S3提供 最终一致性,写后读取.

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最终为覆盖PUTS和DELETES提供了一致性 在所有地区.

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

感谢@Michael-sqlbot,更多有关HEAD(或)的警告:

credits to @Michael - sqlbot, more on HEAD (or) GET caveat:

如果在对象存在之前发送GET或HEAD,例如在上传之前检查是否存在对象,那么即使上传完成后,上传也不立即与读取请求保持一致,因为S3已经完成它将对该对象进行的唯一立即一致的内部查询,是权威地发现没有这样的键.对象创建最终变得一致,因为创建必须覆盖"没有发现任何内容的先前查找.

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.

基于链接中提供的下表,一致读取"永远不会过时.

Based on following table provided in the link, "consistent reads" will never be stale.

以上提供的链接中有一个很好的示例,说明了写后读一致性"和"最终一致性"有效.

Above provided link has nice example regarding how "read-after-write consistency" & "eventual consistency" works.

我想在此答案中添加此警告说明,以使事情更清楚:

I would like to add this caution note to this answer to make things more clear:

Amazon S3通过跨Amazon数据中心内的多台服务器复制数据来实现高可用性.如果PUT请求成功,则将安全地存储您的数据.但是,有关更改的信息必须跨Amazon S3复制,这可能需要一些时间,因此您可能会观察到以下行为:

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:

一个进程将一个新对象写入Amazon S3,并立即列出密钥 在它的桶里.在更改完全传播之前,对象 可能不会出现在列表中.

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.

这篇关于是否保证可以读取AWS S3返回新创建的对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆