Loading...
Loading...
Microservices architecture patterns and design. Use when user asks to "design microservices", "service decomposition", "API gateway", "distributed transactions", "circuit breaker", "service mesh", "event-driven architecture", "saga pattern", "service discovery", or mentions microservices design patterns and distributed systems.
npx skill4agent add 1mangesh1/dev-skills-collection microservices-architectureClient → API Gateway → Service 1
→ Service 2
→ Service 3Service A → Event Bus → Service B
→ Service C// Fails fast when service is unavailable
const breaker = new CircuitBreaker(async () => {
return await serviceCall();
}, {
threshold: 5, // Fail after 5 errors
timeout: 60000 // Check after 60s
});// Exponential backoff
const maxRetries = 3;
const baseDelay = 1000;
for (let i = 0; i < maxRetries; i++) {
try {
return await service.call();
} catch (e) {
if (i === maxRetries - 1) throw e;
await sleep(baseDelay * Math.pow(2, i));
}
}Transaction 1: Service A
↓ success
Transaction 2: Service B
↓ success
Transaction 3: Service C
↓ failure → Compensating transactions# Environment-specific config
app:
database:
url: ${DB_URL}
timeout: ${DB_TIMEOUT:-5000}
cache:
ttl: ${CACHE_TTL:-3600}
security:
jwtSecret: ${JWT_SECRET}| Challenge | Solution |
|---|---|
| Distributed transactions | Saga pattern, event sourcing |
| Data consistency | Eventual consistency acceptance |
| Service discovery | Service registry (Consul, Eureka) |
| Latency | Caching, async communication |
| Debugging | Distributed tracing, correlation IDs |
| Complexity | API gateway, service mesh |