Skip to Content
Kafka权威指南
book

Kafka权威指南

by Neha Narkhede, Gwen Shapira, Todd Palino
January 2018
Beginner to intermediate
234 pages
7h 8m
Chinese
Posts & Telecom Press
Content preview from Kafka权威指南
196
11
迟到的旧事件
11-9:乱序事件
要让流处理应用程序处理好这些场景,需要做到以下几点。
识别乱序的事件。应用程序需要检查事件的时间,并将其与当前时间进行比较。
规定一个时间段用于重排乱序的事件。比如
3
个小时以内的事件可以重排,但
3
周以外
的事件就可以直接扔掉。
具有在一定时间段内重排乱序事件的能力。这是流式处理应用与批处理作业的一个主要
不同点。假设有一个每天运行的作业,一些事件在作业结束之后才到达,那么可以重新
运行昨天的作业来更新事件。而在流式处理中,“重新运行昨天的作业”这种情况是不
存在的,乱序事件和新到达的事件必须一起处理。
具备更新结果的能力。如果处理的结果保存到数据库里,那么可以通过
put
update
结果进行更新。如果流应用程序通过邮件发送结果,那么要对结果进行更新,就需要很
巧妙的手段。
有一些流式处理框架,比如
Google
Dataflow
Kafka
Streams
,都支持独立于处理时
间发生的事件,并且能够处理比当前处理时间更晚或更早的事件。它们在本地状态里维护
了多个聚合时间窗口,用于更新事件,并为开发者提供配置时间窗口大小的能力。当然,
时间窗口越大,维护本地状态需要的内存也越大。
Streams API
通常将聚合结果写到主题上。这些主题一般是压缩日志主题,也就是说,它
们只保留每个键的最新值。如果一个聚合时间窗口的结果需要被更新为晚到事件的结果,
Streams
会直接为这个聚合时间窗口写入一个新的结果,将前一个结果覆盖掉。
11.3.7
 重新处理 ...
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

精通機器學習

精通機器學習

Aurélien Géron
精通特征工程

精通特征工程

Alice Zheng, Amanda Casari
高效能PYTHON程式設計

高效能PYTHON程式設計

Micha Gorelick, Ian Ozsvald

Publisher Resources

ISBN: 9787115473271