事件驱动死信队列架构
Architecture
死信队列架构图,展示重试策略、指数退避、最大重试阈值、失败消息的 DLQ 路由、运维告警和手动重处理工作流。该模板模拟异步消息系统的关键错误处理模式,确保处理失败时不会静默丢失任何消息。对于构建具有适当故障恢复机制的可靠事件驱动系统至关重要。
Architecture
指数退避重试架构图,展示完整的重试策略引擎,包括可重试与不可重试错误分类、带抖动的指数延迟计算、最大重试阈值和优雅的耗尽处理。该模板模拟处理分布式系统中瞬态故障的基本弹性模式,通过随机退避延迟防止惊群问题。对于云架构中任何服务间通信都是基础性的。
Caller { # Calling Service
n1: circle label:"Initiate Request"
n2: rectangle label:"Send HTTP Request"
n3: rectangle label:"Receive Response"
n4: circle label:"Request Complete"
n1.handle(right) -> n2.handle(left)
n2.handle(bottom) -> RetryPolicy.n5.handle(top) [label="Execute"]
n3.handle(right) -> n4.handle(left)
}
RetryPolicy { # Retry Policy Engine
n5: rectangle label:"Attempt Request"
n6: diamond label:"Response Status?"
n7: rectangle label:"Return Success"
n8: diamond label:"Retryable Error?"
n9: rectangle label:"Return Permanent Failure"
n10: rectangle label:"Calculate Backoff Delay"
n11: diamond label:"Max Retries Exceeded?"
n12: rectangle label:"Wait with Jitter"
n13: rectangle label:"Return Exhausted Error"
n5.handle(right) -> n6.handle(left)
n6.handle(right) -> n7.handle(left) [label="2xx"]
n6.handle(bottom) -> n8.handle(top) [label="Error"]
n7.handle(top) -> Caller.n3.handle(bottom) [label="Success"]
n8.handle(right) -> n10.handle(left) [label="429/503/Timeout"]
n8.handle(bottom) -> n9.handle(top) [label="400/401/404"]
n9.handle(top) -> Caller.n3.handle(bottom) [label="Non-Retryable"]
n10.handle(right) -> n11.handle(left) [label="2^n * base"]
n11.handle(bottom) -> n13.handle(top) [label="Yes"]
n11.handle(right) -> n12.handle(left) [label="No"]
n12.handle(top) -> n5.handle(bottom) [label="Retry"]
n13.handle(top) -> Caller.n3.handle(bottom) [label="Max Retries"]
}
Target { # Target Service
n14: rectangle label:"Process Request"
n15: diamond label:"Service Healthy?"
n16: rectangle label:"Return 200 OK"
n17: rectangle label:"Return 503 Unavailable"
n14.handle(right) -> n15.handle(left)
n15.handle(right) -> n16.handle(left) [label="Yes"]
n15.handle(bottom) -> n17.handle(top) [label="No"]
n16.handle(top) -> RetryPolicy.n6.handle(bottom) [label="Success"]
n17.handle(top) -> RetryPolicy.n6.handle(bottom) [label="Error"]
n5.handle(bottom) -> Target.n14.handle(top) [label="HTTP"]
}
Transient failures (network blips, temporary overloads) are inevitable in distributed systems. Naive retry strategies with fixed intervals cause thundering herd problems where all clients retry simultaneously. Exponential backoff with jitter spreads retries over time, giving the failing service time to recover.
Fixed-interval retries cause thundering herds. No retries mean transient failures become permanent. Circuit breakers complement retries by stopping attempts to known-failing services. This template shows the complete retry policy engine.
| Template Name | 指数退避重试架构 |
| Category | Architecture |
| Steps | 6 workflow steps |
| Format | FlowZap Code (.fz file) |
Architecture
死信队列架构图,展示重试策略、指数退避、最大重试阈值、失败消息的 DLQ 路由、运维告警和手动重处理工作流。该模板模拟异步消息系统的关键错误处理模式,确保处理失败时不会静默丢失任何消息。对于构建具有适当故障恢复机制的可靠事件驱动系统至关重要。
Architecture
微服务 API 网关架构图,展示请求路由、JWT 身份验证、速率限制、服务发现以及跨分布式后端服务的响应聚合。该模板模拟微服务生态系统中所有客户端流量的入口点,在请求到达内部服务之前执行安全策略。适合设计具有集中式横切关注点的可扩展 API 基础设施的平台工程师。
Architecture
每服务独立数据库架构图,每个微服务拥有其专用数据存储,通过 Kafka 进行事件驱动同步以实现跨服务数据一致性。该模板展示了微服务数据隔离的核心原则,展示 PostgreSQL 和 MongoDB 如何在多语言持久化策略中共存。对于在保持最终一致性的同时强制服务自治的架构师至关重要。