扩展Nextdoor的数据库:第5部分

In this final installment of the Scaling Nextdoor’s Datastores blog series, we detail how the Core-Services team at Nextdoor solved cache consistency challenges as part of a holistic approach to improve our database and cache scalability and usability.

在《Scaling Nextdoor’s Datastores》博客系列的最后一篇中,我们详细介绍了Nextdoor的核心服务团队如何解决缓存一致性挑战,作为改善我们数据库和缓存可扩展性及可用性的整体方法的一部分。

In Part 4: Keeping the cache consistent, we highlighted a class of consistency issues arising from racing cache writes and introduced an approach for forward cache versioning as a mechanism to avoid inconsistencies. The cache is able to decide which write to persist and which to reject because it is aware of the version of data it currently has. However, this is only a partial solution because it assumes writers will always succeed in communicating with the cache in a timely manner, if at all.

第 4 部分:保持缓存一致性 中,我们强调了一类由于竞争缓存写入而产生的一致性问题,并介绍了一种前向缓存版本控制的方法,以避免不一致。缓存能够决定保留哪个写入和拒绝哪个写入,因为它知道当前拥有的数据版本。然而,这只是一个部分解决方案,因为它假设写入者总是能够及时与缓存进行通信(如果能够的话)。

Missed Writes

丢失的写入

Let’s consider the scenario where Writers A and B both performed an update to the same row in the database and have not yet updated the cache. Writer A holds Version 1 and Writer B holds Version 2. What happens if Writer B with Value 2 fails to talk with the cache?

让我们考虑一个场景,其中写入者 AB都对数据库中的同一行进行了更新,并且尚未更新缓存。写入者 A持有版本 1,而写入者 B持有版本 2。如果写入者 B 以值 2未能与缓存通信,会发生什么?

Writer B fails to write to the cache.

写入者 B 未能写入缓存。

In this case the result is that the cache becomes inconsistent and we can’t rely on the writers to provide that consistency. A process must exist outside of this interaction to fix-up the cache when Version 2 is written to the database but fails to be written to the cache.

在这种情况下,结果是缓存变得不一致,我们不能依赖写入者提供这种一致性。必须存在一个过程在此交互之外,以在版本 2 被写入数据库但未能写入缓存时修复缓存。

Change Data Stream

变更数据流

To solve this problem we tap into a common feature provided by most modern databases, a Change Data Capture (CDC) Stream. A CDC Stream is a mechanism to subscribe to row level changes in a database.

为了解决这个问题,我们利用了大多数现代数据库提供的一个常见特性,即...

开通本站会员,查看完整译文。

trang chủ - Wiki
Copyright © 2011-2025 iteam. Current version is 2.142.1. UTC+08:00, 2025-04-05 09:43
浙ICP备14020137号-1 $bản đồ khách truy cập$