Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: oopsguy

Rating No ratings yet

No description

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 A practical, seven-chapter guide to designing and deploying microservices, covering everything from API gateways and inter-service communication to service discovery and data management. Ideal for architects and developers moving from monolithic to microservice architectures, with concrete NGINX-based examples throughout. 【Book Arc】 - **Opening (~0%–9%)**: Introduces the microservices concept, contrasting it with monolithic applications and the "monolithic hell" of scaling, deployment, and technology adoption. Establishes the Scale Cube model (X, Y, Z axes) and the core principle of decentralized data. - **Early (~9%–27%)**: Details the advantages (independent deployment, scaling, polyglot persistence) and disadvantages (distributed complexity, testing challenges, cross-service changes) of microservices. Concludes with NGINX Plus as a reverse proxy and the first major pattern: the API Gateway. - **Early (~27%–41%)**: Explores the API Gateway pattern in depth—its role as a single entry point, benefits (encapsulation, custom APIs per client), drawbacks (development bottleneck), and implementation considerations like performance and reactive programming. - **Middle (~41%–55%)**: Covers process inter-communication (IPC), including interaction styles (one-to-one, one-to-many; sync vs. async), handling partial failures (timeouts, circuit breakers), and comparing synchronous (REST, Thrift) vs. asynchronous (messaging) mechanisms. - **Late (~55%–100%)**: Addresses service discovery (client-side vs. server-side patterns, registration approaches), event-driven data management (saga pattern, event sourcing), deployment strategies, and refactoring monoliths. Excerpts confirm these topics but do not provide full details. 【Key Takeaways】 - **Monoliths fail at scale** (Early): A single codebase with all modules in one process becomes a bottleneck for scaling, reliability, and adopting new technologies. Microservices solve this by decomposing the application into smaller, independently deployable services. - **The Scale Cube guides decomposition** (Early): The Y-axis (functional decomposition into services) is the core of microservices, while X-axis (load-balanced replicas) and Z-axis (data partitioning) handle scaling. Most applications combine all three. - **Each service owns its data** (Early): Decentralized data management (polyglot persistence) is essential for loose coupling, but it introduces complexity—distributed transactions are avoided in favor of eventual consistency. - **API Gateway is the single entry point** (Early): It encapsulates internal architecture, provides custom APIs per client (e.g., mobile vs. web), and handles routing, composition, and protocol translation. It's a trade-off: added complexity vs. simplified client communication. - **Partial failures must be designed for** (Middle): In distributed systems, services can be slow or unavailable. Strategies like network timeouts, limiting in-flight requests, circuit breakers, and fallbacks (e.g., Netflix Hystrix) prevent resource exhaustion and cascading failures. - **Choose IPC based on interaction needs** (Middle): Asynchronous messaging (AMQP, Kafka) decouples clients and buffers messages, while synchronous REST/Thrift is simpler for request/response. Message formats (JSON/XML vs. binary like Protocol Buffers) trade readability for efficiency. - **Service discovery is mandatory in dynamic environments** (Late): With auto-scaling and failures, service instances have dynamic network locations. Client-side and server-side discovery patterns, plus self-registration or third-party registration, are essential for locating services. - **Event-driven data management solves distributed data problems** (Late): Patterns like sagas (local transactions with events) and event sourcing maintain consistency without distributed transactions, which are impractical with modern NoSQL and message brokers. 【Reading Tips】 - **Skim the NGINX "实战" sections** if you're not using NGINX; they are vendor-specific add-ons. Focus on the core architectural patterns in the main chapters. - **Deep-read Chapter 2 (API Gateway)** and **Chapter 3 (IPC)**: These are the most actionable for design decisions. Pay attention to the trade-offs and the partial-failure strategies. - **Treat Chapter 1 as context**: The monolith vs. microservices comparison and the Scale Cube are foundational, but you can move quickly if you're already familiar with the basics. - **Watch for the data management chapter**: It's the most conceptually challenging (sagas, event sourcing). Read it twice if needed—it's critical for real-world implementations. - **Use the book as a decision framework**: For each pattern (gateway, IPC, discovery), list the pros/cons and match them to your project's constraints (team size, traffic, existing infrastructure). 【Coverage Limits】 This guide covers the first five chapters in detail (intro, API gateway, IPC, service discovery, data management). The final chapters on deployment strategies and refactoring monoliths are mentioned but not fully covered in the excerpts.
Page 3
............ 30 3.4 演化 API .......................................................... 30 3.5 处理局部故障 ...................................................... 31...
View in text
Page 10
有模块都运行在同一进程中。任何模块的一 个 bug,比如内存泄漏,可能会拖垮整个进程。此外,由于应用程序的所有实例都是 相同的,该错误将影响到整个应用的可用性。 最后但同样重要,单体应用使得采用新框架和语言变得非常困难。例如,我们假设您 有 200 万行代码使用了 XYZ 框架编写。如果使用较新的 ABC 框架来...
View in text
Excerpt 3
可以通过 LAN 发送许多请求,但在公共互联网下 效率低下,在移动网络必然是不切实际。 20 微服务:从设计到部署 客户端直接调用微服务存在的另一个问题是有些可能使用了非 web 友好协议。一个服 务可能使用了 Thrift 二进制 RPC,而另一个则可能使用 AMQP 消息协议。这两个协 议无论是对浏览器还是防...
View in text
Excerpt 4
ST 或 Thrift。或者,可以使用异步、基于消息的通信机制,如 AMQP 或 STOMP。还有各种不同的消息格式。服务可以使用人类可读、基于文本的格式,如 JSON 或 XML。或者,可以使用如 Avro 或 Protocol Buffers 等二进制格式(更加高 效)。稍后我们将讨论同步 IPC 机制,但在...
View in text
Excerpt 5
和注销自己。此外,如果有 必要,服务实例将通过发送心跳请求来防止其注册信息过期。 图 4-4 展示了该模式的结构。 图 4-4、服务可以自我处理注册 44 微服务:从设计到部署 该方式的一个很好的范例就是 Netflix OSS Eureka 客户端。Eureka 客户端负责处理 服务实例注册与注销 的所有方面。...
View in text
Excerpt 6
比如,将其作为事件发 布。 事务日志挖掘有各种好处与坏处。一个好处是它能保证被发布的事件每次更新都不依 赖于 2PC。事务日志挖掘还可以通过将事件发布与应用程序的业务逻辑分离来简化应 用程序。一个主要的缺点是事务日志的格式对于每个数据库来说都是专有的,甚至在 数据库版本之间格式就发生了改变。而且,记录于事务日志中...
View in text
Excerpt 7
设施以及可能运行的 VM 基础架构。 此外,容器通常部署在一个按单个 VM 收费的基础设施上。因此,如之前所述,可能 会产生超额配置 VM 的额外成本,以处理负载峰值。 有趣的是,容器和 VM 之间的区别可能会有些模糊。如之前所述,Boxfuse VM 可以很 快地构建和启动。Clear Containers 项...
View in text
Excerpt 8
使用了模块 Y。第一个重构步骤是定义一对粗粒度的 API。第一个接口是一个使用模块 X 来调用 模块 Z 的入站接口。第二个接口是一个使用模块 Z 调用模块 Y 的出站接口。 第二个重构步骤是将模块转换为一个独立服务。入站和出站接口使用 IPC 机制的代码 来实现。您将很可能需要通过将 Module Z 与 Mi...
View in text
Tags
AI categories
BackendCloud NativeProgramming Language
Publish Year: 2017
Language: Chinese
File Format: PDF
File Size: 2.6 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…