Agent Skills
› cosmicstack-labs/mercury-agent-skills
› microservices
microservices
GitHub指导微服务架构设计与运维,涵盖服务边界划分、通信模式选择、CQRS及分布式追踪实践,并提供避免反模式的建议。
Trigger Scenarios
设计微服务架构
选择服务间通信方式
实施事件驱动或CQRS
配置分布式追踪
Install
npx skills add cosmicstack-labs/mercury-agent-skills --skill microservices -g -y
SKILL.md
Frontmatter
{
"name": "microservices",
"metadata": {
"tags": [
"microservices",
"architecture",
"distributed-systems",
"event-sourcing",
"cqrs"
],
"author": "cosmicstack-labs",
"version": "1.0.0",
"category": "backend"
},
"description": "Service boundaries, communication patterns, event sourcing, CQRS, and distributed tracing"
}
Microservices
Design and operate microservice architectures.
Service Boundaries
Bounded Context (DDD)
- Each service owns a domain concept
- Service has its own database (no DB sharing)
- Communication via API or events
- Avoid "shared" services (leads to tight coupling)
Service Sizing
- Too small: Nano-services — high overhead, hard to debug
- Too large: Distributed monolith — worst of both worlds
- Right size: Team can build, test, deploy independently
Communication Patterns
| Pattern | Type | When |
|---|---|---|
| REST | Sync | Request-response, CRUD |
| gRPC | Sync (fast) | Internal, high throughput |
| Event | Async | Decoupled workflows |
| Message Queue | Async | Buffered, reliable delivery |
Event-Driven Communication
Service A → Event Bus → Service B
→ Service C
→ Service D
Benefits: eventual consistency, loose coupling, replayability.
CQRS (Command Query Responsibility Segregation)
- Separate read and write models
- Queries go to optimized read stores (materialized views)
- Commands go to write stores (normalized)
- Eventually consistent between them
Distributed Tracing
- Correlation ID passed across all services
- Use OpenTelemetry for instrumentation
- Trace each request: Service → Queue → DB → External API
- Visualize in Jaeger or Zipkin
- Alert on traces that exceed latency SLOs
Anti-Patterns to Avoid
❌ Shared database between services ❌ Sync chains (A → B → C → D blocking) ❌ Distributed monolith (microservices but deployed together) ❌ Absent monitoring ("it works in dev") ❌ Premature decomposition (start monolith, extract carefully)
Version History
- 38e2523 Current 2026-07-05 19:36


