基于单元的架构
Architecture
基于单元的架构图,展示地理路由到独立、自包含的单元(US-East、EU-West),每个单元拥有自己的网关、计算、数据库、缓存和消息队列,加上用于跨单元复制和全局配置的共享服务。该模板模拟超大规模系统使用的单元架构模式以实现爆炸半径隔离,一个单元的故障不会影响另一个单元的用户。对于设计需要极高可用性和故障隔离的系统的架构师至关重要。
完整 FlowZap 代码
GlobalRouter { # Global Router
n1: circle label:"User Request"
n2: rectangle label:"Geographic Routing"
n3: diamond label:"User Cell Assignment?"
n4: rectangle label:"Route to Cell A"
n5: rectangle label:"Route to Cell B"
n1.handle(right) -> n2.handle(left)
n2.handle(right) -> n3.handle(left)
n3.handle(right) -> n4.handle(left) [label="US-East"]
n3.handle(bottom) -> n5.handle(top) [label="EU-West"]
n4.handle(bottom) -> CellA.n6.handle(top) [label="Forward"]
n5.handle(bottom) -> CellB.n12.handle(top) [label="Forward"]
}
CellA { # Cell A (US-East)
n6: rectangle label:"Cell Gateway"
n7: rectangle label:"Compute Layer"
n8: rectangle label:"Cell Database"
n9: rectangle label:"Cell Cache"
n10: rectangle label:"Cell Message Queue"
n11: circle label:"Cell Response"
n6.handle(right) -> n7.handle(left) [label="Process"]
n7.handle(right) -> n8.handle(left) [label="Read/Write"]
n7.handle(bottom) -> n9.handle(top) [label="Cache"]
n7.handle(bottom) -> n10.handle(top) [label="Async"]
n8.handle(right) -> n11.handle(left)
}
CellB { # Cell B (EU-West)
n12: rectangle label:"Cell Gateway"
n13: rectangle label:"Compute Layer"
n14: rectangle label:"Cell Database"
n15: rectangle label:"Cell Cache"
n16: rectangle label:"Cell Message Queue"
n17: circle label:"Cell Response"
n12.handle(right) -> n13.handle(left) [label="Process"]
n13.handle(right) -> n14.handle(left) [label="Read/Write"]
n13.handle(bottom) -> n15.handle(top) [label="Cache"]
n13.handle(bottom) -> n16.handle(top) [label="Async"]
n14.handle(right) -> n17.handle(left)
}
SharedServices { # Shared Services (Cross-Cell)
n18: rectangle label:"Global Config Service"
n19: rectangle label:"Cross-Cell Replication"
n20: rectangle label:"Monitoring and Alerting"
n18.handle(right) -> n19.handle(left) [label="Sync Config"]
n19.handle(top) -> CellA.n8.handle(bottom) [label="Replicate"]
n19.handle(top) -> CellB.n14.handle(bottom) [label="Replicate"]
n19.handle(right) -> n20.handle(left) [label="Health"]
}
为什么需要这个工作流?
Traditional multi-region deployments share databases and services across regions, meaning a failure in one component can affect all users globally. Cell-based architecture creates fully independent, self-contained cells where each cell serves a subset of users—limiting the blast radius of any failure to only the users in that cell.
工作原理
- Step 1: A global router assigns users to cells based on geographic location or account ID.
- Step 2: Each cell contains its own gateway, compute, database, cache, and message queue.
- Step 3: Cells operate independently—a failure in Cell A does not affect Cell B.
- Step 4: Shared services handle cross-cell concerns like global configuration and monitoring.
- Step 5: Cross-cell replication synchronizes data for disaster recovery.
- Step 6: New cells can be added to handle growth without affecting existing cells.
替代方案
Multi-region active-active shares resources and has larger blast radius. Single-region with failover has longer recovery times. This template shows the cell architecture used by hyperscale systems like AWS and Azure.
Key Facts
| Template Name | 基于单元的架构 |
| Category | Architecture |
| Steps | 6 workflow steps |
| Format | FlowZap Code (.fz file) |
相关模板
微服务 API 网关架构
Architecture
微服务 API 网关架构图,展示请求路由、JWT 身份验证、速率限制、服务发现以及跨分布式后端服务的响应聚合。该模板模拟微服务生态系统中所有客户端流量的入口点,在请求到达内部服务之前执行安全策略。适合设计具有集中式横切关注点的可扩展 API 基础设施的平台工程师。
微服务每服务独立数据库架构
Architecture
每服务独立数据库架构图,每个微服务拥有其专用数据存储,通过 Kafka 进行事件驱动同步以实现跨服务数据一致性。该模板展示了微服务数据隔离的核心原则,展示 PostgreSQL 和 MongoDB 如何在多语言持久化策略中共存。对于在保持最终一致性的同时强制服务自治的架构师至关重要。
按业务能力分解微服务架构
Architecture
按业务能力组织的微服务分解架构图:身份认证、产品目录、定价和订单履行,每个都有独立的数据存储和 API。该模板展示如何将单体应用拆分为与业务领域对齐的服务,使用 Backend-for-Frontend (BFF) 模式进行客户端特定的聚合。适合规划领域驱动微服务边界的架构师。
微服务绞杀者模式迁移架构
Architecture
绞杀者模式迁移架构图,展示使用路由层在新旧系统之间分流流量,逐步用新微服务替换遗留单体应用。该模板模拟经过验证的迁移策略,新功能作为微服务构建,遗留端点逐步退役。对于在不进行高风险大爆炸重写的情况下现代化遗留系统的团队至关重要。