Installer avec Codex ou Claude Copiez ce prompt, collez-le dans Codex, Claude ou un autre assistant, puis laissez-le vérifier la page du skill et l'installer pour vous.
Une commande directe contourne le prompt de vérification. Examinez la source avant de l'exécuter.
Provide expert-level guidance on microservice architecture, including service decomposition strategies, inter-service communication patterns, saga orchestration, CQRS/event sourcing, API gateway design, resilience patterns, and distributed data management.
When to Use Microservices
Start with a modular monolith. Extract microservices only when you have:
Different scaling requirements per module
Different deployment cadences per team
Technology diversity needs (e.g., ML service in Python, API in Go)
Team autonomy requirements (Conway's Law)
Do NOT use microservices for:
Small teams (< 10 engineers)
Simple CRUD applications
Premature optimization of theoretical scaling needs
Key Patterns
1. Service Decomposition
# Bounded Context identification (Domain-Driven Design)
┌─────────────────────────────────────────────────────┐
│ E-Commerce System │
├──────────────┬──────────────┬────────────────────────┤
│ Order │ Inventory │ Payment │
│ Context │ Context │ Context │
│ │ │ │
│ - Order │ - Product │ - Payment │
│ - OrderItem │ - Stock │ - Refund │
│ - Shipping │ - Warehouse │ - PaymentMethod │
│ │ │ │
│ Team: Order │ Team: Ops │ Team: Payments │
│ DB: Postgres│ DB: Postgres│ DB: Postgres │
│ Lang: Go │ Lang: Go │ Lang: Node.js │
└──────────────┴──────────────┴────────────────────────┘
# Each service owns its data -- no shared databases
# Communication via APIs (sync) or events (async)
Decomposition heuristics:
Business capability: Order management, inventory, billing
Subdomain: Core, supporting, generic (DDD)
Data ownership: Group by data that changes together
Team ownership: Align with organizational structure
2. Communication Patterns
Synchronous (Request-Response):
┌─────────┐ HTTP/gRPC ┌─────────┐
│ Service A│───────────────→│Service B │
│ │←───────────────│ │
└─────────┘ └─────────┘
Use for: Queries, commands needing immediate response
Asynchronous (Event-Driven):
┌─────────┐ Event Bus ┌─────────┐
│ Service A│───→ [Event] ───→│Service B │
└─────────┘ └─────────┘
┌─────────┐
───→│Service C │
└─────────┘
Use for: Notifications, eventual consistency, decoupling
// API Gateway pattern (Node.js with Express)import express from'express';
import { createProxyMiddleware } from'http-proxy-middleware';
import rateLimit from'express-rate-limit';
importCircuitBreakerfrom'opossum';
const app = express();
// Rate limiting per client
app.use(rateLimit({
windowMs: 60_000,
max: 100,
standardHeaders: true,
keyGenerator: (req) => req.headers['x-api-key'] || req.ip,
}));
// Circuit breaker for downstream servicesfunctioncreateServiceProxy(name: string, target: string) {
const breaker = newCircuitBreaker(
async (req: express.Request) => {
returnfetch(`${target}${req.path}`, {
method: req.method,
headers: req.headersasHeadersInit,
body: req.method !== 'GET' ? JSON.stringify(req.body) : undefined,
signal: AbortSignal.timeout(5000),
});
},
{
timeout: 5000, // Request timeouterrorThresholdPercentage: 50, // Open circuit at 50% failureresetTimeout: 30000, // Try again after 30svolumeThreshold: 10, // Min requests before tripping
}
);
breaker.on('open', () => logger.warn(`Circuit breaker OPEN for ${name}`));
breaker.on('halfOpen', () => logger.info(`Circuit breaker half-open for ${name}`));
breaker.on('close', () => logger.info(`Circuit breaker CLOSED for ${name}`));
return breaker;
}
// Route to servicesconst services = {
orders: createServiceProxy('orders', 'http://order-service:3001'),
inventory: createServiceProxy('inventory', 'http://inventory-service:3002'),
payments: createServiceProxy('payments', 'http://payment-service:3003'),
};