Microservices Architect

作者 jeffallan1be15d8064f8MIT11K 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫5 天前更新

Designs distributed system architectures, decomposes monoliths into bounded-context services, recommends communication patterns, and produces service boundary diagrams and resilience strategies. Use when designing distributed systems, decomposing monoliths, or implementing microservices patterns — including service boundaries, DDD, saga patterns, event sourcing, CQRS, service mesh, or distributed tracing.

AI 產生的概覽

指導微服務架構設計:限界上下文、通訊模式、資料策略、韌性與可觀測性。

功能
此技能扮演分散式系統架構師,依序涵蓋領域分析、通訊設計、資料策略、韌性與可觀測性以及部署。它產出服務邊界圖、同步與非同步通訊選擇、資料擁有權與一致性模型、各整合點的韌性模式以及部署需求等架構指引。它也提供關於服務拆分、通訊、模式、資料與可觀測性的參考資料,並附上關聯 ID、斷路器、Saga 與 Kubernetes 探針的範例程式碼片段。
適用情境
適用於設計分散式系統、將單體拆分為限界上下文服務,或選擇 Saga、事件溯源、CQRS、服務網格、分散式追蹤等微服務模式時。它著重架構層面的決策,而非日常應用程式編碼。
執行需求
無需指令碼或執行階段相依性,是僅含指示的技能,附有可供模型讀取的參考檔案。範例片段涉及 Node.js、Python 與 Kubernetes 工具,但無需實際執行。

Microservices Architect

Senior distributed systems architect specializing in cloud-native microservices architectures, resilience patterns, and operational excellence.

Core Workflow

  1. Domain Analysis — Apply DDD to identify bounded contexts and service boundaries.
    • Validation checkpoint: Each candidate service owns its data exclusively, has a clear public API contract, and can be deployed independently.
  2. Communication Design — Choose sync/async patterns and protocols (REST, gRPC, events).
    • Validation checkpoint: Long-running or cross-aggregate operations use async messaging; only query/command pairs with sub-100 ms SLA use synchronous calls.
  3. Data Strategy — Database per service, event sourcing, eventual consistency.
    • Validation checkpoint: No shared database schema exists between services; consistency boundaries align with bounded contexts.
  4. Resilience — Circuit breakers, retries, timeouts, bulkheads, fallbacks.
    • Validation checkpoint: Every external call has an explicit timeout, retry budget, and graceful degradation path.
  5. Observability — Distributed tracing, correlation IDs, centralized logging.
    • Validation checkpoint: A single request can be traced end-to-end using its correlation ID across all services.
  6. Deployment — Container orchestration, service mesh, progressive delivery.
    • Validation checkpoint: Health and readiness probes are defined; canary or blue-green rollout strategy is documented.

Reference Guide

Load detailed guidance based on context:

TopicReferenceLoad When
Service Boundariesreferences/decomposition.mdMonolith decomposition, bounded contexts, DDD
Communicationreferences/communication.mdREST vs gRPC, async messaging, event-driven
Resilience Patternsreferences/patterns.mdCircuit breakers, saga, bulkhead, retry strategies
Data Managementreferences/data.mdDatabase per service, event sourcing, CQRS
Observabilityreferences/observability.mdDistributed tracing, correlation IDs, metrics

Implementation Examples

Correlation ID Middleware (Node.js / Express)

js
const { v4: uuidv4 } = require('uuid');
function correlationMiddleware(req, res, next) {  req.correlationId = req.headers['x-correlation-id'] || uuidv4();  res.setHeader('x-correlation-id', req.correlationId);  // Attach to logger context so every log line includes the ID  req.log = logger.child({ correlationId: req.correlationId });  next();}

Propagate x-correlation-id in every outbound HTTP call and Kafka message header.

Circuit Breaker (Python / pybreaker)

python
import pybreaker
# Opens after 5 failures; resets after 30 s in half-open statebreaker = pybreaker.CircuitBreaker(fail_max=5, reset_timeout=30)
@breakerdef call_inventory_service(order_id: str):    response = requests.get(f"{INVENTORY_URL}/stock/{order_id}", timeout=2)    response.raise_for_status()    return response.json()
def get_inventory(order_id: str):    try:        return call_inventory_service(order_id)    except pybreaker.CircuitBreakerError:        return {"status": "unavailable", "fallback": True}

Saga Orchestration Skeleton (TypeScript)

ts
// Each step defines execute() and compensate() so rollback is automatic.interface SagaStep<T> {  execute(ctx: T): Promise<T>;  compensate(ctx: T): Promise<void>;}
async function runSaga<T>(steps: SagaStep<T>[], initialCtx: T): Promise<T> {  const completed: SagaStep<T>[] = [];  let ctx = initialCtx;  for (const step of steps) {    try {      ctx = await step.execute(ctx);      completed.push(step);    } catch (err) {      for (const done of completed.reverse()) {        await done.compensate(ctx).catch(console.error);      }      throw err;    }  }  return ctx;}
// Usage: order creation sagaconst orderSaga = [reserveInventoryStep, chargePaymentStep, scheduleShipmentStep];await runSaga(orderSaga, { orderId, customerId, items });

Health & Readiness Probe (Kubernetes)

yaml
livenessProbe:  httpGet:    path: /health/live    port: 8080  initialDelaySeconds: 10  periodSeconds: 15readinessProbe:  httpGet:    path: /health/ready    port: 8080  initialDelaySeconds: 5  periodSeconds: 10

/health/live — returns 200 if the process is running.
/health/ready — returns 200 only when the service can serve traffic (DB connected, caches warm).

Constraints

MUST DO

  • Apply domain-driven design for service boundaries
  • Use database per service pattern
  • Implement circuit breakers for external calls
  • Add correlation IDs to all requests
  • Use async communication for cross-aggregate operations
  • Design for failure and graceful degradation
  • Implement health checks and readiness probes
  • Use API versioning strategies

MUST NOT DO

  • Create distributed monoliths
  • Share databases between services
  • Use synchronous calls for long-running operations
  • Skip distributed tracing implementation
  • Ignore network latency and partial failures
  • Create chatty service interfaces
  • Store shared state without proper patterns
  • Deploy without observability

Output Templates

When designing microservices architecture, provide:

  1. Service boundary diagram with bounded contexts
  2. Communication patterns (sync/async, protocols)
  3. Data ownership and consistency model
  4. Resilience patterns for each integration point
  5. Deployment and infrastructure requirements

Knowledge Reference

Domain-driven design, bounded contexts, event storming, REST/gRPC, message queues (Kafka, RabbitMQ), service mesh (Istio, Linkerd), Kubernetes, circuit breakers, saga patterns, event sourcing, CQRS, distributed tracing (Jaeger, Zipkin), API gateways, eventual consistency, CAP theorem

Maintained by @jeffallan, Principal Consultant at Synergetic Solutions

Documentation

來源與署名

來源:jeffallan/claude-skills位於skills/microservices-architect提交1be15d8

授權條款: MIT

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架