Skip to Content
微服务与事件驱动架构
book

微服务与事件驱动架构

by Adam Bellemare
October 2021
Beginner to intermediate
250 pages
7h 11m
Chinese
Posts & Telecom Press
Content preview from 微服务与事件驱动架构
86
6
6.8
 再处理与近实时处理
不可变事件流提供了重置消费者组偏移量和从任意时间点重新处理事件的能力。这被称
再处理
,每个事件驱动型微服务都需要在设计时考虑再处理问题。通常只有使用事件
时间进行事件处理的微服务要执行再处理,那些依赖于挂钟时间的聚合和窗口化的微服
务则不用。
事件调度是能够正确再处理来自事件流的历史数据的重要部分。它确保了微服务以它们在
近实时处理事件时一样的顺序来处理事件。处理乱序事件也是这个过程中的重要部分,因
为通过事件代理对事件流再分区(而不是使用像
Spark
Flink
Beam
这样的重量级框架)
会导致乱序事件。
当你想要对事件流进行再处理时,下面是一些可遵循的步骤。
1.
确定起始点
作为最佳实践,所有有状态的消费者应该从它们订阅的每个事件流的起
点开始再处理事件。这尤其适用于实体事件流,因为它们包含有关所讨论实体的重要
事实。
2.
确定重置哪些消费者偏移量
所有包含用于有状态处理的流的偏移量都应该被重置到流
的起点,因为如果你从一个错误的位置开始再处理,那么很难确保最终能得到正确的状
态。(考虑一下,如果你重新处理某人的银行存款余额,而不小心漏掉了以前的工资支
票,会发生什么情况。)
3.
考虑数据量
有些微服务可能要处理大量事件。考虑再处理事件需要花费多长时间,以
及任何可能存在的瓶颈。可能需要采用限额(参见
14.4
节)以确保不会因大量
I/O
压垮事件代理。此外,如果预计会产生大量再处理输出数据,则需要通知所有的下游消
费者。如果不具备自动伸缩能力(参见
1
1.7.3 ...
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

监控运维实践:原则与策略

监控运维实践:原则与策略

Mike Julian
Kafka权威指南

Kafka权威指南

Neha Narkhede, Gwen Shapira, Todd Palino
Web容量规划之美

Web容量规划之美

Arun Kejariwal, John Allspaw

Publisher Resources

ISBN: 9787115571106