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

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

by Ian Gorton
May 2024
Intermediate
278 pages
5h 24m
Chinese
China Machine Press
Content preview from 构建可扩展分布式系统:方法与实践
126
|
7
法以便管理副本,并在领导者不可用时选择新的领导者
译注
1
。我将在第
12
章详细讨论
RAFT
算法。
1
仲裁队列必须是持久性的,因此主要适用于数据安全性和可用性优先于性能的用例。在
故障处理方面,它比镜像队列的实现更有优势。考虑到这些原因,镜像队列的实现将在
未来版本中被弃用。
7.3
消息传递模式
这个网站(
https://oreil.ly/DuhYA
)为使用消息传递的应用程序提供了一份全面的设计模
式目录,这些设计模式在企业级系统中有着悠久的使用历史。虽然其中许多都与构建和
修改系统的便捷性以及消息安全性的最佳设计实践有关,但也有一些直接适用于分布式
系统中的可扩展性。接下来的小节我将介绍三种最常用的模式。
7.3.1
竞争消费者
消息传递系统的一个常见需求是尽可能快地消费队列中的消息。竞争消费者模式(
https://
oreil.ly/WHatQ
)是通过运行多个消费者线程或进程并发处理消息来实现的。这使得应用程
序能够根据需要通过水平扩展消费者来扩展消息处理能力。总体设计如图
7-7
所示。
发布者
消息代理
消费者
消费者
消费者
7-7:竞争消费者模式
通过竞争消费者模式,可以利用推送或拉取模型动态地在消费者之间分发消息。使
用推送方法时,代理要负责选择将消息传递到哪一个消费者。例如,在
RabbitMQ
ActiveMQ
中实现的一种常见方法是简单的循环分发算法。这种方法确保了将消息均衡
地分发给消费者。
使用拉取方法时,消费者只需尽可能快地处理消息。假设有一个多线程消费者,如果一
个消费者在八核节点上运行,另一个在双核节点上运行 ...
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