Files
vibe_coding/.cursor/rules/017-architecture.mdc
2026-03-05 21:27:11 +08:00

46 lines
1.3 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
description: >
百万级并发架构设计规范。当讨论水平扩展、限流降级、熔断、
高可用架构、容量规划或发布策略时激活。
alwaysApply: false
---
# 🏗️ Million-Level Concurrency Architecture Standards (Core)
## 架构目标
- 无状态应用,可水平扩展
- 高并发下保持可用与可观测
- 峰值流量具备限流、降级、熔断能力
## 核心设计原则
- 入口层Nginx/网关统一限流与基础防护
- 应用层Hyperf 服务无状态,异步化非关键链路
- 数据层MySQL 主从 + Redis 缓存 + 队列削峰
- 可靠性:幂等、重试、超时、隔离舱、降级兜底
## 关键实践
- 热点读走缓存,写后失效或异步刷新
- 长耗时任务走队列/事件,避免阻塞请求线程
- 对外依赖必须有 timeout + retry + fallback
- 关键业务链路必须可追踪(日志/指标/告警)
## 容量与发布
- 扩容前先压测,确认瓶颈位置
- 灰度发布与回滚路径必须预案化
- 变更优先小步快跑,减少单次风险面
## 验证清单
- [ ] 高峰流量下核心接口可用
- [ ] 限流/降级策略可触发且可恢复
- [ ] 异步任务可观测且可重试
- [ ] 发布失败可快速回滚
## Tier 3 深度参考
- `.cursor/rules/references/017-architecture-deep.md` — 完整并发架构规范与拓扑示例