microservices-expert
Expert microservices architecture including service decomposition, communication patterns, and resilience
When & Why to Use This Skill
The Microservices Expert skill provides comprehensive guidance on designing, implementing, and optimizing distributed systems. It specializes in Domain-Driven Design (DDD) for service decomposition, robust inter-service communication patterns (REST, gRPC, Pub/Sub), and advanced resilience strategies like circuit breakers and the Saga pattern to ensure system reliability, scalability, and high availability.
Use Cases
- Monolith to Microservices Migration: Decomposing legacy monolithic applications into manageable microservices using bounded contexts and business capability mapping.
- Distributed Transaction Management: Designing complex workflows across multiple services using the Saga pattern to maintain eventual consistency without distributed locks.
- System Resilience Engineering: Implementing fault-tolerance mechanisms such as circuit breakers, retries with backoff, and bulkheads to prevent cascading failures in high-traffic environments.
- Communication Strategy Optimization: Selecting the ideal protocol (Synchronous vs. Asynchronous) and pattern (Request/Reply vs. Pub/Sub) based on latency requirements and system decoupling needs.
- Data Architecture Design: Establishing data ownership boundaries and implementing patterns like Database-per-service, CQRS, and Event Sourcing for scalable data management.
| name | microservices-expert |
|---|---|
| description | Expert microservices architecture including service decomposition, communication patterns, and resilience |
| version | 1.0.0 |
| author | USER |
| tags | [microservices, distributed, service-mesh, saga, resilience] |
Microservices Expert
Purpose
Design and implement microservices architectures including service decomposition, inter-service communication, and resilience patterns.
Activation Keywords
- microservices, micro-services
- service decomposition, bounded context
- service mesh, sidecar
- saga pattern, eventual consistency
- circuit breaker, resilience
Core Capabilities
1. Service Decomposition
- Domain-driven design
- Bounded contexts
- Service boundaries
- Data ownership
- API contracts
2. Communication Patterns
- Synchronous (REST, gRPC)
- Asynchronous (Events, Messages)
- Request/Reply
- Pub/Sub
- Event sourcing
3. Resilience Patterns
- Circuit breaker
- Retry with backoff
- Bulkhead
- Timeout
- Fallback
4. Data Management
- Database per service
- Saga pattern
- Eventual consistency
- CQRS
- Event sourcing
5. Service Mesh
- Istio/Linkerd
- Traffic management
- mTLS
- Observability
- Policy enforcement
Decomposition Guidelines
1. Business Capabilities
→ Group by business function
→ Each service = one capability
2. Bounded Contexts (DDD)
→ Identify domain boundaries
→ Define ubiquitous language
3. Data Boundaries
→ Each service owns its data
→ No shared databases
4. Team Boundaries
→ Conway's Law
→ One team per service (ideal)
Communication Decision Matrix
| Scenario | Pattern |
|---|---|
| Query data | Sync (REST/gRPC) |
| Command | Async (Message queue) |
| Event notification | Pub/Sub |
| Long-running process | Saga |
| Data replication | Event sourcing |
Saga Pattern
Choreography:
Service A → Event → Service B → Event → Service C
↓ (failure)
Compensating transactions automatically triggered
Orchestration:
Orchestrator → Command → Service A
→ Command → Service B
→ Command → Service C
→ Rollback commands on failure
Resilience Implementation
// Circuit breaker example
const breaker = new CircuitBreaker(fetchData, {
timeout: 3000,
errorThresholdPercentage: 50,
resetTimeout: 30000
});
breaker.fire()
.then(data => handleSuccess(data))
.catch(err => handleFallback(err));
Example Usage
User: "Decompose a monolith e-commerce into microservices"
Microservices Expert Response:
1. Identify bounded contexts
- User Management
- Product Catalog
- Inventory
- Order Management
- Payment
- Shipping
- Notifications
2. Define service boundaries
- API contracts (OpenAPI)
- Event schemas
- Data ownership
3. Communication design
- Order → Payment (Saga)
- Inventory updates (Events)
- Product queries (REST)
4. Resilience patterns
- Circuit breakers for external calls
- Retry for transient failures
- Fallbacks for degraded mode