Skip to Content
构建可扩展分布式系统:方法与实践
book

构建可扩展分布式系统:方法与实践

by Ian Gorton
May 2024
Intermediate
278 pages
5h 24m
Chinese
China Machine Press
Content preview from 构建可扩展分布式系统:方法与实践
可扩展的事件驱动处理
|
239
你可以修改现有的事件处理逻辑,以添加新功能或修复错误。然后,你可以在完整
的日志上执行新逻辑以丰富结果或修复错误。
如果发生服务器或磁盘故障,你可以从日志中恢复最后已知的状态并重播事件以恢
复数据集。这类似于事务日志在数据库系统中的作用。
消费者
14-2:使用事件日志实现跨微服务复制状态变更
与所有事情一样,不可变的、仅允许追加的日志也有缺点。我在下面的边栏中简要描述
其中之一
删除事件,以及
Apache Kafka
的相关功能。你可以阅读更多关于设计事件
驱动架构和模式的内容(例如事件协作和事件溯源)。我将在
14.3
节为你介绍几个优秀
的资源。然而,在本章的剩余部分,我想探索
Apache Kafka
平台的特性。
从日志中删除事件
有一些用例需要删除日志条目。一个著名的用例是欧盟《通用数据保护条例》GDPR
法律的“被遗忘权”监管要求。仅允许追加的不可变日志不是为删除条目而设计的,
可能会使删除条目出现问题。
Apache Kafka 提供了两种主要的日志条目删除机制:
生存时间
在默认的两周后删除日志条目。你可以调整它来满足你对日志条目保留和删除
的要求。
压缩主题
主题可以配置为仅保留给定事件键的最新条目。如果需要删除现有的日志条目,
你只需写入一个具有相同键和空值的新条目。然后,Kafka 会将较旧的条目标记
为删除。事件实际上在压缩主题中被标记为删除,并在稍后某个时间段(日志
压缩任务运行时)被删除。同样,此任务的频率是可配置的。
14.2 Apache Kafka ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

What Successful Brick-and-Mortar Retailers Get Right

What Successful Brick-and-Mortar Retailers Get Right

Rob Angell
What Successful Project Managers Do

What Successful Project Managers Do

W. Scott Cameron, Jeffrey S. Russell, Edward J. Hoffman, Alexander Laufer
Three Essentials for Agentic AI Security

Three Essentials for Agentic AI Security

Paolo Dal Cin, Daniel Kendzior, Yusof Seedat, Renato Marinho

Publisher Resources

ISBN: 9787111750697