微服务每服务独立数据库架构
Architecture
每服务独立数据库架构图,每个微服务拥有其专用数据存储,通过 Kafka 进行事件驱动同步以实现跨服务数据一致性。该模板展示了微服务数据隔离的核心原则,展示 PostgreSQL 和 MongoDB 如何在多语言持久化策略中共存。对于在保持最终一致性的同时强制服务自治的架构师至关重要。
Architecture
事件驱动发布-订阅架构图,展示 Kafka 或 RabbitMQ 消息代理、事件序列化、主题分区、向多个消费者的扇出交付以及死信队列错误处理。该模板模拟了生产者和消费者通过消息代理完全解耦的基础异步消息传递模式。对于构建松耦合、可扩展的事件驱动系统的架构师至关重要。
Producer { # Event Producer
n1: circle label:"Business Action"
n2: rectangle label:"Create Domain Event"
n3: rectangle label:"Serialize Event"
n4: rectangle label:"Publish to Topic"
n1.handle(right) -> n2.handle(left)
n2.handle(right) -> n3.handle(left) [label="OrderCreated"]
n3.handle(right) -> n4.handle(left) [label="Avro/JSON"]
n4.handle(bottom) -> Broker.n5.handle(top) [label="Produce"]
}
Broker { # Message Broker (Kafka/RabbitMQ)
n5: rectangle label:"Receive Event"
n6: rectangle label:"Partition by Key"
n7: rectangle label:"Persist to Log"
n8: rectangle label:"Fan-Out to Subscribers"
n9: rectangle label:"Dead Letter Queue"
n5.handle(right) -> n6.handle(left)
n6.handle(right) -> n7.handle(left) [label="Append"]
n7.handle(right) -> n8.handle(left) [label="Notify"]
n8.handle(bottom) -> Consumers.n10.handle(top) [label="Deliver"]
n9.handle(bottom) -> Consumers.n17.handle(top) [label="Failed Events"]
}
Consumers { # Event Consumers
n10: rectangle label:"Inventory Consumer"
n11: rectangle label:"Update Stock Level"
n12: rectangle label:"Notification Consumer"
n13: rectangle label:"Send Order Email"
n14: rectangle label:"Analytics Consumer"
n15: rectangle label:"Update Dashboard"
n16: diamond label:"Processing OK?"
n17: rectangle label:"Retry Handler"
n10.handle(right) -> n16.handle(left)
n16.handle(right) -> n11.handle(left) [label="Yes"]
n16.handle(bottom) -> n17.handle(top) [label="No"]
n17.handle(top) -> Broker.n9.handle(bottom) [label="DLQ"]
n12.handle(right) -> n13.handle(left) [label="Email"]
n14.handle(right) -> n15.handle(left) [label="Aggregate"]
}
Synchronous request-response communication between microservices creates tight coupling, cascading failures, and latency chains. The publish-subscribe pattern decouples producers from consumers through a message broker, enabling independent scaling, temporal decoupling, and resilient event processing with built-in retry mechanisms.
Synchronous HTTP calls are simpler but create coupling. Point-to-point queues limit fan-out. Managed services like AWS SNS/SQS or Google Pub/Sub reduce operational overhead. This template visualizes the complete pub/sub lifecycle including error handling.
| Template Name | 事件驱动发布-订阅架构 |
| Category | Architecture |
| Steps | 6 workflow steps |
| Format | FlowZap Code (.fz file) |
Architecture
每服务独立数据库架构图,每个微服务拥有其专用数据存储,通过 Kafka 进行事件驱动同步以实现跨服务数据一致性。该模板展示了微服务数据隔离的核心原则,展示 PostgreSQL 和 MongoDB 如何在多语言持久化策略中共存。对于在保持最终一致性的同时强制服务自治的架构师至关重要。
Architecture
实时事件流管道架构图,IoT 传感器、应用日志和用户点击流数据通过 Kafka 流入 Apache Flink 进行窗口聚合、异常检测以及向数据湖和仪表板的多目标输出。该模板可视化从摄取到转换、存储和告警的端到端流处理。对于构建实时分析和监控平台的数据工程师至关重要。
Architecture
死信队列架构图,展示重试策略、指数退避、最大重试阈值、失败消息的 DLQ 路由、运维告警和手动重处理工作流。该模板模拟异步消息系统的关键错误处理模式,确保处理失败时不会静默丢失任何消息。对于构建具有适当故障恢复机制的可靠事件驱动系统至关重要。
Architecture
API 组合架构图,组合器服务向多个微服务扇出并行请求,收集带超时处理的响应,并将结果合并为单一统一响应,支持部分降级。该模板模拟当单个客户端查询需要来自多个服务的数据时使用的 API 组合模式,避免直接的服务间调用。适合在微服务架构中构建聚合层的团队。
Architecture
事件驱动通知中心架构图,展示多源事件摄取、基于模板的消息渲染、按用户偏好路由到邮件(SendGrid/SES)、推送(FCM)、短信(Twilio)和 Slack 渠道,以及交付跟踪和重试机制。该模板模拟将业务服务与交付基础设施解耦的集中式通知系统,支持用户控制偏好的多渠道通信。适合构建可扩展通知基础设施的平台团队。