微服务每服务独立数据库架构
Architecture
每服务独立数据库架构图,每个微服务拥有其专用数据存储,通过 Kafka 进行事件驱动同步以实现跨服务数据一致性。该模板展示了微服务数据隔离的核心原则,展示 PostgreSQL 和 MongoDB 如何在多语言持久化策略中共存。对于在保持最终一致性的同时强制服务自治的架构师至关重要。
Architecture
多租户 SaaS 架构图,展示租户识别、基于层级的路由(共享池与专用池)、行级安全、每租户加密密钥以及标准和企业隔离模型的独立备份策略。该模板模拟构建从共享基础设施服务多个客户同时保持严格数据隔离的 SaaS 平台的架构决策。对于平衡成本效率与企业安全需求的 SaaS 架构师至关重要。
Tenant { # Tenant Request
n1: circle label:"Tenant API Call"
n2: rectangle label:"Tenant Identification"
n3: rectangle label:"Receive Response"
n4: circle label:"End"
n1.handle(right) -> n2.handle(left) [label="X-Tenant-ID"]
n2.handle(bottom) -> Routing.n5.handle(top) [label="Resolve Tenant"]
n3.handle(right) -> n4.handle(left)
}
Routing { # Tenant Routing Layer
n5: rectangle label:"Tenant Config Lookup"
n6: diamond label:"Isolation Model?"
n7: rectangle label:"Route to Shared Pool"
n8: rectangle label:"Route to Dedicated Pool"
n9: rectangle label:"Apply Tenant Rate Limits"
n5.handle(right) -> n6.handle(left) [label="Tier"]
n6.handle(right) -> n7.handle(left) [label="Standard Tier"]
n6.handle(bottom) -> n8.handle(top) [label="Enterprise Tier"]
n7.handle(right) -> n9.handle(left)
n8.handle(right) -> n9.handle(left)
n9.handle(bottom) -> Application.n10.handle(top) [label="Tenant Context"]
}
Application { # Application Layer
n10: rectangle label:"Inject Tenant Context"
n11: rectangle label:"Execute Business Logic"
n12: rectangle label:"Apply Row-Level Security"
n13: rectangle label:"Return Tenant-Scoped Data"
n10.handle(right) -> n11.handle(left) [label="Middleware"]
n11.handle(right) -> n12.handle(left) [label="Query"]
n12.handle(right) -> n13.handle(left) [label="Filtered"]
n13.handle(top) -> Tenant.n3.handle(bottom) [label="Response"]
n12.handle(bottom) -> DataLayer.n14.handle(top) [label="Tenant Filter"]
}
DataLayer { # Data Isolation
n14: rectangle label:"Shared Database (Schema per Tenant)"
n15: rectangle label:"Dedicated Database (Enterprise)"
n16: rectangle label:"Tenant Encryption Keys"
n17: rectangle label:"Backup per Tenant"
n14.handle(right) -> n16.handle(left) [label="Encrypt at Rest"]
n15.handle(right) -> n16.handle(left) [label="Dedicated Key"]
n16.handle(right) -> n17.handle(left) [label="Isolated Backup"]
}
SaaS platforms must serve multiple customers from shared infrastructure while maintaining strict data isolation, security, and performance guarantees. The multi-tenant architecture balances cost efficiency (shared resources) with enterprise requirements (dedicated isolation) through tier-based routing and row-level security.
Single-tenant deployments are simpler but expensive to operate at scale. Shared-everything models are cheapest but risk data leakage. This template shows the hybrid approach with tier-based isolation levels.
| Template Name | 多租户 SaaS 架构 |
| Category | Architecture |
| Steps | 6 workflow steps |
| Format | FlowZap Code (.fz file) |
Architecture
每服务独立数据库架构图,每个微服务拥有其专用数据存储,通过 Kafka 进行事件驱动同步以实现跨服务数据一致性。该模板展示了微服务数据隔离的核心原则,展示 PostgreSQL 和 MongoDB 如何在多语言持久化策略中共存。对于在保持最终一致性的同时强制服务自治的架构师至关重要。
Architecture
微服务 API 网关架构图,展示请求路由、JWT 身份验证、速率限制、服务发现以及跨分布式后端服务的响应聚合。该模板模拟微服务生态系统中所有客户端流量的入口点,在请求到达内部服务之前执行安全策略。适合设计具有集中式横切关注点的可扩展 API 基础设施的平台工程师。
Architecture
按业务能力组织的微服务分解架构图:身份认证、产品目录、定价和订单履行,每个都有独立的数据存储和 API。该模板展示如何将单体应用拆分为与业务领域对齐的服务,使用 Backend-for-Frontend (BFF) 模式进行客户端特定的聚合。适合规划领域驱动微服务边界的架构师。
Architecture
绞杀者模式迁移架构图,展示使用路由层在新旧系统之间分流流量,逐步用新微服务替换遗留单体应用。该模板模拟经过验证的迁移策略,新功能作为微服务构建,遗留端点逐步退役。对于在不进行高风险大爆炸重写的情况下现代化遗留系统的团队至关重要。