AWS Blogs 07月01日
Build the highest resilience apps with multi-Region strong consistency in Amazon DynamoDB global tables
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

本文介绍了Amazon DynamoDB全局表的新功能——多区域强一致性(MRSC),该功能旨在为对数据一致性和可用性有极高要求的应用提供更强的弹性。通过MRSC,即使某个区域发生故障,应用程序也能从其他区域读取最新数据,实现零恢复点目标(RPO)。文章详细介绍了如何启用MRSC,包括创建全局表、配置副本和见证者,以及使用ConsistentRead参数实现强一致性读取。此外,文章还提供了代码示例和定价信息,帮助读者了解和应用这项新功能。

🛡️ DynamoDB 的多区域强一致性(MRSC)功能,为需要最高级别弹性的应用程序提供了保障。当一个区域的应用处理中断时,可以重定向流量到包含MRSC副本的另一个区域,确保读取到最新数据。

🚀 要使用MRSC,需要在现有的DynamoDB表的基础上创建全局表。创建过程包括在“全局表”选项卡中选择“创建副本”,并配置三个AWS区域,可选择配置三个完整副本或两个副本加一个见证者。见证者仅包含复制的更改数据,以提供所需的可用性,而无需维护表数据的完整副本。

💡 通过使用ConsistentRead参数,可以在应用程序中实现强一致性读取。对于需要最强弹性的操作,使用ConsistentRead=True;对于不太关键的操作,可以省略此参数以提高性能并降低成本。

💰 MRSC的定价遵循现有的全局表定价结构。DynamoDB最近降低了按需吞吐量和全局表的定价,使得这种高弹性架构比以往更具成本效益。

<section class="blog-post-content lb-rtxt"><table id="amazon-polly-audio-table"><tbody><tr><td id="amazon-polly-audio-tab"><p></p></td></tr></tbody></table><p>While tens of thousands of customers are successfully using <a href="https://aws.amazon.com/dynamodb/?trk=c4ea046f-18ad-4d23-a1ac-cdd1267f942c&amp;amp;sc_channel=el&quot;&gt;Amazon DynamoDB</a> <a href="https://aws.amazon.com/dynamodb/global-tables/?trk=c4ea046f-18ad-4d23-a1ac-cdd1267f942c&amp;amp;sc_channel=el&quot;&gt;global tables</a> with eventual consistency, we’re seeing emerging needs for even stronger resilience. Many organizations find that the DynamoDB multi-Availability Zone architecture and eventually consistent global tables meet their requirements, but critical applications like payment processing systems and financial services demand more.</p><p>For these applications, customers require a zero Recovery Point Objective (RPO) during rare Region-wide events, meaning you can direct your app to read the latest data from any Region. Your multi-Region applications always need to access the same data regardless of location.</p><p>Starting today, you can use a new Amazon DynamoDB global tables capability that provides multi-Region strong consistency (MRSC), enabling zero RPO. This capability, first announced as a <a href="https://aws.amazon.com/about-aws/whats-new/2024/12/amazon-dynamodb-global-tables-previews-multi-region-strong-consistency/?trk=c4ea046f-18ad-4d23-a1ac-cdd1267f942c&amp;amp;sc_channel=el&quot;&gt;preview at AWS re:Invent 2024</a>, simplifies building highly resilient global applications.</p><p>Here’s how you can enable MRSC starting with an existing empty DynamoDB table:</p><p><img class="aligncenter wp-image-97615 size-full c4" src="https://d2908q01vomqb2.cloudfront.net/da4b9237bacccdf19c0760cab7aec4a8359010b0/2025/06/30/2025-06-ddbmrsc-rev-4.png&quot; alt="" width="1232" height="731" /></p><p>With MRSC, DynamoDB now offers you the highest level of resilience for your applications. If application processing is interrupted in a Region, you can redirect traffic to another Region containing a MRSC replica and know that you’ll be processing the latest data.</p><p><strong>Getting started</strong><br />Let me walk you through how you can use this new capability.</p><p>To start using MRSC, I need to create a global table from an existing DynamoDB table that doesn’t contain any data. I navigate to my existing table, select the <strong>Global tables</strong> tab and select <strong>Create replica</strong>.</p><p><img class="aligncenter wp-image-97618 size-full c4" src="https://d2908q01vomqb2.cloudfront.net/da4b9237bacccdf19c0760cab7aec4a8359010b0/2025/06/30/2025-06-ddbmrsc-rev-1-1-1.png&quot; alt="" width="1235" height="390" /></p><p>The MRSC availability architecture requires three AWS Regions. I can configure MRSC with either three full replicas or with two replicas and a witness. A witness contains only replicated change data to provide the required availability without maintaining a full copy of my table data.</p><p>The following screenshot shows how I configure MRSC with two replicas and a witness. To configure MRSC with three full replicas instead, I can clear <strong>Configure Region 2 as Witness</strong>.</p><p><img class="aligncenter wp-image-97611 size-full c4" src="https://d2908q01vomqb2.cloudfront.net/da4b9237bacccdf19c0760cab7aec4a8359010b0/2025/06/30/2025-06-ddbmrsc-rev-3.png&quot; alt="" width="1232" height="731" /></p><p>If I need to update my existing table programmatically, I can use the <a href="https://aws.amazon.com/developer/learning/q-developer-cli/?trk=c4ea046f-18ad-4d23-a1ac-cdd1267f942c&amp;amp;sc_channel=el&quot;&gt;Amazon Q CLI</a> to generate the required command with the following prompt:</p><p><code>&gt; Hey Q! Update my existing DynamoDB table called "demo-mrsc" in us-east-1 with multi-Region strong consistency across us-east-2 with witness in us-west-2 Regions</code></p><p>Shortly after, Q CLI will respond back with following command:</p><pre class="lang-bash">&gt; To update your DynamoDB table with multi-Region strong consistency, you'll need to use the update-table command with the appropriate parameters. Here's how you would do it:aws dynamodb update-table \ --table-name demo-mrsc \ --replica-updates '[{"Create": {"RegionName": "us-east-2"}}]' \ --global-table-witness-updates '[{"Create": {"RegionName": "us-west-2"}}]' \ --multi-region-consistency STRONG \ --region us-east-1</pre><p>After it’s finished processing, I can check the status of my MRSC global table. I can see I have a <strong>witness</strong> configured for my DynamoDB global table. A witness reduces costs while still providing the resilience benefits of multi-Region strong consistency.</p><p><img class="aligncenter wp-image-97610 size-full c4" src="https://d2908q01vomqb2.cloudfront.net/da4b9237bacccdf19c0760cab7aec4a8359010b0/2025/06/30/2025-06-ddbmrsc-rev-2.png&quot; alt="" width="1196" height="629" /></p><p>Then, in my application, I can use <code>ConsistentRead</code> to read data with strong consistency. Here’s a Python example:</p><pre class="language-python">import boto3# Configure the DynamoDB client for your regiondynamodb = boto3.resource('dynamodb', region_name='us-east-2')table = dynamodb.Table('demo-mrsc')pk_id = "demo#test123"# Read with strong consistency across regionsresponse = table.get_item( Key={ 'PK': pk_id }, ConsistentRead=True)print(response)</pre><p>For operations that require the strongest resilience, I can use <code>ConsistentRead=True</code>. For less critical operations where eventual consistency is acceptable, I can omit this parameter to improve performance and reduce costs.</p><p><strong>Additional things to know<br /></strong>Here are a couple of things to note:</p><ul><li><strong>Availability</strong> – The Amazon DynamoDB multi-Region strong consistency capability is available in following AWS Regions: US East (Ohio, N. Virginia), US West (Oregon), Asia Pacific (Osaka, Seoul, Tokyo), and Europe (Frankfurt, Ireland, London, Paris)</li><li><strong>Pricing</strong> – Multi-Region strong consistency pricing follows the existing global tables pricing structure. DynamoDB recently reduced global tables pricing by up to 67 percent, making this highly resilient architecture more affordable than ever. Visit <a href="https://aws.amazon.com/blogs/database/new-amazon-dynamodb-lowers-pricing-for-on-demand-throughput-and-global-tables/?trk=c4ea046f-18ad-4d23-a1ac-cdd1267f942c&amp;amp;sc_channel=el&quot;&gt;Amazon DynamoDB lowers pricing for on-demand throughput and global tables</a> in the AWS Database Blog to learn more.</li></ul><p>Learn more about how you can achieve the highest level of application resilience, enable your applications to be always available and always read the latest data regardless of the Region by visiting <a href="https://aws.amazon.com/dynamodb/global-tables/?trk=c4ea046f-18ad-4d23-a1ac-cdd1267f942c&amp;amp;sc_channel=el&quot;&gt;Amazon DynamoDB global tables</a>.</p><p>Happy building!</p><p>— <a href="https://linkedin.com/in/donnieprakoso?trk=c4ea046f-18ad-4d23-a1ac-cdd1267f942c&amp;amp;sc_channel=el&quot;&gt;Donnie&lt;/a&gt;&lt;/p&gt;&lt;/section&gt;&lt;aside id="Comments" class="blog-comments"><div data-lb-comp="aws-blog:cosmic-comments" data-env="prod" data-content-id="b1f3d304-094e-493e-b8d3-5589b3cd55c7" data-title="Build the highest resilience apps with multi-Region strong consistency in Amazon DynamoDB global tables" data-url="https://aws.amazon.com/blogs/aws/build-the-highest-resilience-apps-with-multi-region-strong-consistency-in-amazon-dynamodb-global-tables/&quot;&gt;&lt;p data-failed-message="Comments cannot be loaded… Please refresh and try again.">Loading comments…</p></div></aside>

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

DynamoDB 多区域 强一致性 MRSC
相关文章