亚马逊 - DynamoDB 强一致性读取,它们是最新的吗?如何?

本文介绍了亚马逊 - DynamoDB 强一致性读取,它们是最新的吗?如何?的处理方法,对大家解决问题具有一定的参考价值

问题描述

在尝试将 Dynamodb 用于其中一个项目时,我对 dynamodb 的强一致性模型有疑问.来自常见问题解答

In an attempt to use Dynamodb for one of projects, I have a doubt regarding the strong consistency model of dynamodb. From the FAQs

强一致性读取 — 除了最终一致性之外,Amazon DynamoDB 还为您提供如果您的应用程序或应用程序的一个元素需要它,则可以灵活和控制请求强一致的读取.强一致性读取返回的结果反映了在读取之前收到成功响应的所有写入.

Strongly Consistent Reads — in addition to eventual consistency, Amazon DynamoDB also gives you the flexibility and control to request a strongly consistent read if your application, or an element of your application, requires it. A strongly consistent read returns a result that reflects all writes that received a successful response prior to the read.

从上面的定义,我得到的是强一致性读会返回最新的写值.

From the definition above, what I get is that a strong consistent read will return the latest write value.

举个例子:假设 Client1 在 Key K1 上发出写入命令,将值从 V0 更新到 V1.几毫秒后,Client2 发出对 Key K1 的读取命令,然后在强一致性的情况下,将始终返回 V1,但在最终一致性的情况下,可能会返回 V1 或 V0.我的理解正确吗?

Taking an example: Lets say Client1 issues a write command on Key K1 to update the value from V0 to V1. After few milliseconds Client2 issues a read command for Key K1, then in case of strong consistency V1 will be returned always, however in case of eventual consistency V1 or V0 may be returned. Is my understanding correct?

如果是,如果写操作返回成功,但数据没有更新到所有副本,我们发出强一致性读,这种情况下如何保证返回最新的写值?

If it is, What if the write operation returned success but the data is not updated to all replicas and we issue a strongly consistent read, how it will ensure to return the latest write value in this case?

以下链接AWS DynamoDB 读后写一致性 - 它是如何做到的理论上可行? 试图解释这背后的架构,但不知道这是否是它的实际运作方式?浏览完这个链接后,我想到的下一个问题是:DynamoDb 是否基于单主多从架构,其中写入和强一致性读取是通过主副本,而正常读取是通过其他副本.

The following link AWS DynamoDB read after write consistency - how does it work theoretically? tries to explain the architecture behind this, but don't know if this is how it actually works? The next question that comes to my mind after going through this link is: Is DynamoDb based on Single Master, multiple slave architecture, where writes and strong consistent reads are through master replica and normal reads are through others.

推荐答案

简答:在强一致性模式下成功写入要求您的写入在大多数可以包含该记录的服务器上成功,因此任何未来的一致性读取将始终看到相同的数据,因为一致的读取必须读取可以包含所需记录的大多数服务器.如果不进行强一致性读,系统会随机向服务器请求记录,有可能数据不是最新的.

Short answer: Writing successfully in strongly consistent mode requires that your write succeed on a majority of servers that can contain the record, therefore any future consistent reads will always see the same data, because a consistent read must read a majority of the servers that can contain the desired record. If you do not perform a strongly consistent read, the system will ask a random server for the record, and it is possible that the data will not be up-to-date.

想象三台服务器.服务器 1、服务器 2 和服务器 3.要写入强一致性记录,您至少选择两台服务器,然后写入数据.让我们选择 1 和 2.

Imagine three servers. Server 1, server 2 and server 3. To write a strongly consistent record, you pick two servers at minimum, and write the data. Let's pick 1 and 2.

现在您想要一致地读取数据.选择大多数服务器.假设我们选择了 2 和 3.

Now you want to read the data consistently. Pick a majority of servers. Let's say we picked 2 and 3.

服务器 2 有新数据,这是系统返回的.

Server 2 has the new data, and this is what the system returns.

最终一致的读取可能来自服务器 1、2 或 3.这意味着如果随机选择服务器 3,您的新写入将不会出现,直到复制发生.

Eventually consistent reads could come from server 1, 2, or 3. This means if server 3 is chosen by random, your new write will not appear yet, until replication occurs.

如果单个服务器出现故障,您的数据仍然是安全的,但如果三分之二的服务器出现故障,您的新写入可能会丢失,直到离线服务器恢复.

If a single server fails, your data is still safe, but if two out of three servers fail your new write may be lost until the offline servers are restored.

更多解释:DynamoDB(假设它类似于亚马逊发布的 Dynamo 论文中描述的数据库)使用环形拓扑,其中数据分布到许多服务器.因为您直接查询所有相关服务器并从中获取当前数据,所以保证了强一致性.擂台上没有主人,擂台上也没有奴隶.给定的记录将映射到环中许多相同的主机,并且所有这些服务器都将包含该记录.没有可以落后的奴隶,也没有可以失败的主人.

More explanation: DynamoDB (assuming it is similar to the database described in the Dynamo paper that Amazon released) uses a ring topology, where data is spread to many servers. Strong consistency is guaranteed because you directly query all relevant servers and get the current data from them. There is no master in the ring, there are no slaves in the ring. A given record will map to a number of identical hosts in the ring, and all of those servers will contain that record. There is no slave that could lag behind, and there is no master that can fail.

请随意阅读有关该主题的众多论文中的任何一篇.有一个类似的数据库叫做 Apache Cassandra,它也使用环复制.

Feel free to read any of the many papers on the topic. A similar database called Apache Cassandra is available which also uses ring replication.

http://www.read.seas.harvard.edu/~kohler/class/cs239-w08/decandia07dynamo.pdf

这篇关于亚马逊 - DynamoDB 强一致性读取,它们是最新的吗?如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,WP2

admin_action_{$_REQUEST[‘action’]}

do_action( "admin_action_{$_REQUEST[‘action’]}" )动作钩子::在发送“Action”请求变量时激发。Action Hook: Fires when an ‘action’ request variable is sent.目录锚点:#说明#源码说明(Description)钩子名称的动态部分$_REQUEST['action']引用从GET或POST请求派生的操作。源码(Source)更新版本源码位置使用被使用2.6.0 wp-admin/admin.php:...

日期:2020-09-02 17:44:16 浏览:1167

admin_footer-{$GLOBALS[‘hook_suffix’]}

do_action( "admin_footer-{$GLOBALS[‘hook_suffix’]}", string $hook_suffix )操作挂钩:在默认页脚脚本之后打印脚本或数据。Action Hook: Print scripts or data after the default footer scripts.目录锚点:#说明#参数#源码说明(Description)钩子名的动态部分,$GLOBALS['hook_suffix']引用当前页的全局钩子后缀。参数(Parameters)参数类...

日期:2020-09-02 17:44:20 浏览:1069

customize_save_{$this->id_data[‘base’]}

do_action( "customize_save_{$this->id_data[‘base’]}", WP_Customize_Setting $this )动作钩子::在调用WP_Customize_Setting::save()方法时激发。Action Hook: Fires when the WP_Customize_Setting::save() method is called.目录锚点:#说明#参数#源码说明(Description)钩子名称的动态部分,$this->id_data...

日期:2020-08-15 15:47:24 浏览:806

customize_value_{$this->id_data[‘base’]}

apply_filters( "customize_value_{$this->id_data[‘base’]}", mixed $default )过滤器::过滤未作为主题模式或选项处理的自定义设置值。Filter Hook: Filter a Customize setting value not handled as a theme_mod or option.目录锚点:#说明#参数#源码说明(Description)钩子名称的动态部分,$this->id_date['base'],指的是设置...

日期:2020-08-15 15:47:24 浏览:898

get_comment_author_url

过滤钩子:过滤评论作者的URL。Filter Hook: Filters the comment author’s URL.目录锚点:#源码源码(Source)更新版本源码位置使用被使用 wp-includes/comment-template.php:32610...

日期:2020-08-10 23:06:14 浏览:930

network_admin_edit_{$_GET[‘action’]}

do_action( "network_admin_edit_{$_GET[‘action’]}" )操作挂钩:启动请求的处理程序操作。Action Hook: Fires the requested handler action.目录锚点:#说明#源码说明(Description)钩子名称的动态部分$u GET['action']引用请求的操作的名称。源码(Source)更新版本源码位置使用被使用3.1.0 wp-admin/network/edit.php:3600...

日期:2020-08-02 09:56:09 浏览:876

network_sites_updated_message_{$_GET[‘updated’]}

apply_filters( "network_sites_updated_message_{$_GET[‘updated’]}", string $msg )筛选器挂钩:在网络管理中筛选特定的非默认站点更新消息。Filter Hook: Filters a specific, non-default site-updated message in the Network admin.目录锚点:#说明#参数#源码说明(Description)钩子名称的动态部分$_GET['updated']引用了非默认的...

日期:2020-08-02 09:56:03 浏览:863

pre_wp_is_site_initialized

过滤器::过滤在访问数据库之前是否初始化站点的检查。Filter Hook: Filters the check for whether a site is initialized before the database is accessed.目录锚点:#源码源码(Source)更新版本源码位置使用被使用 wp-includes/ms-site.php:93910...

日期:2020-07-29 10:15:38 浏览:833

WordPress 的SEO 教学:如何在网站中加入关键字(Meta Keywords)与Meta 描述(Meta Description)?

你想在WordPress 中添加关键字和meta 描述吗?关键字和meta 描述使你能够提高网站的SEO。在本文中,我们将向你展示如何在WordPress 中正确添加关键字和meta 描述。为什么要在WordPress 中添加关键字和Meta 描述?关键字和说明让搜寻引擎更了解您的帖子和页面的内容。关键词是人们寻找您发布的内容时,可能会搜索的重要词语或片语。而Meta Description则是对你的页面和文章的简要描述。如果你想要了解更多关于中继标签的资讯,可以参考Google的说明。Meta 关键字和描...

日期:2020-10-03 21:18:25 浏览:1718

谷歌的SEO是什么

SEO (Search Engine Optimization)中文是搜寻引擎最佳化,意思近于「关键字自然排序」、「网站排名优化」。简言之,SEO是以搜索引擎(如Google、Bing)为曝光媒体的行销手法。例如搜寻「wordpress教学」,会看到本站的「WordPress教学:12个课程…」排行Google第一:关键字:wordpress教学、wordpress课程…若搜寻「网站架设」,则会看到另一个网页排名第1:关键字:网站架设、架站…以上两个网页,每月从搜寻引擎导入自然流量,达2万4千:每月「有机搜...

日期:2020-10-30 17:23:57 浏览:1308