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

微服务与事件驱动架构

by Adam Bellemare
October 2021
Beginner to intermediate
250 pages
7h 11m
Chinese
Posts & Telecom Press
Content preview from 微服务与事件驱动架构
172
13
13.4.1
 实时请求内部状态存储
如图
13-4
所示,微服务可以提供来自其内部状态的结果。客户端请求被分发到一个负载均
衡器,这个负载均衡器会将请求路由到其中一个底层微服务实例。在这个例子中,只有一
个微服务实例,并且因为它物化了该应用程序的所有状态数据,所以在这个实例上可以获
得应用程序的所有数据。状态是通过消费两个输入事件流(
A
B
)进行物化的
,变更日
志备份在事件代理上。
客户端
负载均衡器
物化表P0
变更日志
事件流A
事件流B
处理拓扑
事件代理
实例0
1) 客户端发起请求
2) 负载均衡器分发请求
13-4:用 REST API 向客户端提供内容的 EDM 概览
现在的问题是,很多时候需要多个微服务实例来处理负载,并且实例之间有不同的内部状
态。当使用多个微服务实例时,必须将请求路由到它所需要的状态数据所在的正确实例
上,因为所有的内部状态都是根据键分片的,一个键只会对应一个分区。图
13-5
展示了客
户端发起请求,然后被路由到包含所需状态的正确实例的情况。
如果你的框架支持,那么状态存储的热副本(参见
7.3.4
节)也可以用于服
务直接调用的请求。请记住,热副本数据可能是过时的,过时程度与主状态
存储的复制延迟成比例。
集成事件驱动型和
请求
响应
型微服务
173
客户端
负载均衡器
物化表 ...
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