jpskill.com
🛠️ 開発・MCP コミュニティ

microservices-architecture

マイクロサービス設計や分散システムに関する複雑な課題に対し、APIゲートウェイやイベント駆動型アーキテクチャなどのパターンを用いて最適な解決策を提案するSkill。

📜 元の英語説明(参考)

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.

🇯🇵 日本人クリエイター向け解説

一言でいうと

マイクロサービス設計や分散システムに関する複雑な課題に対し、APIゲートウェイやイベント駆動型アーキテクチャなどのパターンを用いて最適な解決策を提案するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o microservices-architecture.zip https://jpskill.com/download/6106.zip && unzip -o microservices-architecture.zip && rm microservices-architecture.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/6106.zip -OutFile "$d\microservices-architecture.zip"; Expand-Archive "$d\microservices-architecture.zip" -DestinationPath $d -Force; ri "$d\microservices-architecture.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して microservices-architecture.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → microservices-architecture フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-17
取得日時
2026-05-17
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

マイクロサービスアーキテクチャ

マイクロサービスアーキテクチャの設計と実装のためのパターンとベストプラクティスです。

コアパターン

サービス分解

  • ドメイン駆動設計(境界付けられたコンテキスト)
  • ビジネス機能ベース
  • 所有権の明確化
  • 技術の多様性

API Gateway パターン

Client → API Gateway → Service 1
                    → Service 2
                    → Service 3
  • 単一のエントリポイント
  • 認証/認可
  • リクエストルーティング
  • レート制限

サービスごとのデータベース

  • 各サービスが自身のデータベースを所有
  • データ整合性の課題
  • 技術の多様性を可能にする

イベント駆動型通信

Service A → Event Bus → Service B
           → Service C
  • 疎結合
  • 結果整合性
  • イベントソーシング

信頼性パターン

サーキットブレーカー

// サービスが利用できない場合に高速に失敗します
const breaker = new CircuitBreaker(async () => {
  return await serviceCall();
}, {
  threshold: 5,        // 5回のエラー後に失敗
  timeout: 60000       // 60秒後にチェック
});

リトライロジック

// 指数バックオフ
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));
  }
}

タイムアウト管理

  • 適切なタイムアウトを設定
  • カスケードするタイムアウト計算
  • フェイルファスト戦略

整合性パターン

Two-Phase Commit (2PC)

  • 同期、強い整合性
  • ブロッキング、可用性の低下
  • 控えめに使用

Saga パターン

Transaction 1: Service A
  ↓ success
Transaction 2: Service B
  ↓ success
Transaction 3: Service C
  ↓ failure → Compensating transactions
  • 長時間実行されるトランザクション
  • 結果整合性
  • 失敗時の補償トランザクション

イベントソーシング

  • 追記専用のイベントログ
  • 再構築可能な状態
  • 監査証跡が組み込み

監視と運用

分散トレーシング

  • サービス間のリクエストを関連付け
  • レイテンシーのボトルネックを特定
  • ツール: Jaeger, Zipkin

ロギング

  • 相関ID付きの構造化ロギング
  • 集中型ログ集約
  • ツール: ELK, Splunk

メトリクス

  • サービスごとのメトリクス
  • リクエストレイテンシー、スループット
  • リソース使用量

サービスメッシュ

Istio/Linkerd

  • サービス間通信を管理
  • トラフィック管理
  • セキュリティポリシー
  • 可観測性

構成管理

# 環境固有の設定
app:
  database:
    url: ${DB_URL}
    timeout: ${DB_TIMEOUT:-5000}
  cache:
    ttl: ${CACHE_TTL:-3600}
  security:
    jwtSecret: ${JWT_SECRET}

デプロイ戦略

Blue-Green デプロイ

  • 2つの同一環境
  • トラフィックを即座に切り替え
  • 迅速なロールバック

Canary デプロイ

  • ユーザーの一部に段階的にロールアウト
  • メトリクスを監視
  • 成功すれば展開

Rolling デプロイ

  • 古いインスタンスを段階的に置き換え
  • ダウンタイムなし
  • デプロイ時間が長い

マイクロサービスのためのAPI設計

  • RESTful または gRPC
  • バージョニング戦略
  • 後方互換性
  • ドキュメント (OpenAPI)

課題と解決策

課題 解決策
分散トランザクション Saga パターン、イベントソーシング
データ整合性 結果整合性の受け入れ
サービスディスカバリ サービスレジストリ (Consul, Eureka)
レイテンシー キャッシング、非同期通信
デバッグ 分散トレーシング、相関ID
複雑性 API Gateway、サービスメッシュ

チーム編成

  • サービスごとのクロスファンクショナルチーム
  • 明確なAPI契約
  • 所有権と説明責任
  • コミュニケーションパターン

参考文献

  • Sam Newman - Building Microservices
  • Chris Richardson - Microservices Patterns
  • Kubernetes in Action
  • AWS Microservices Architecture
  • Kong API Gateway Guide
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Microservices Architecture

Patterns and best practices for designing and implementing microservices architectures.

Core Patterns

Service Decomposition

  • Domain-driven design (bounded contexts)
  • Business capability based
  • Ownership clarity
  • Technology diversity

API Gateway Pattern

Client → API Gateway → Service 1
                    → Service 2
                    → Service 3
  • Single entry point
  • Authentication/authorization
  • Request routing
  • Rate limiting

Database per Service

  • Each service owns its database
  • Data consistency challenges
  • Enables technology diversity

Event-Driven Communication

Service A → Event Bus → Service B
           → Service C
  • Loose coupling
  • Eventual consistency
  • Event sourcing

Reliability Patterns

Circuit Breaker

// 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
});

Retry Logic

// 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));
  }
}

Timeout Management

  • Set reasonable timeouts
  • Cascading timeout calculation
  • Fail fast strategy

Consistency Patterns

Two-Phase Commit (2PC)

  • Synchronous, strong consistency
  • Blocking, reduced availability
  • Use sparingly

Saga Pattern

Transaction 1: Service A
  ↓ success
Transaction 2: Service B
  ↓ success
Transaction 3: Service C
  ↓ failure → Compensating transactions
  • Long-running transactions
  • Eventual consistency
  • Compensating actions on failure

Event Sourcing

  • Append-only event log
  • Reconstible state
  • Audit trail built-in

Monitoring & Operations

Distributed Tracing

  • Correlate requests across services
  • Identify latency bottlenecks
  • Tools: Jaeger, Zipkin

Logging

  • Structured logging with correlation IDs
  • Centralized log aggregation
  • Tools: ELK, Splunk

Metrics

  • Per-service metrics
  • Request latency, throughput
  • Resource usage

Service Mesh

Istio/Linkerd

  • Manages service-to-service communication
  • Traffic management
  • Security policies
  • Observability

Configuration Management

# Environment-specific config
app:
  database:
    url: ${DB_URL}
    timeout: ${DB_TIMEOUT:-5000}
  cache:
    ttl: ${CACHE_TTL:-3600}
  security:
    jwtSecret: ${JWT_SECRET}

Deployment Strategies

Blue-Green Deployment

  • Two identical environments
  • Switch traffic instantly
  • Quick rollback

Canary Deployment

  • Gradual rollout to subset of users
  • Monitor metrics
  • Expand if successful

Rolling Deployment

  • Gradual replacement of old instances
  • No downtime
  • Longer deploy time

API Design for Microservices

  • RESTful or gRPC
  • Versioning strategy
  • Backward compatibility
  • Documentation (OpenAPI)

Challenges & Solutions

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

Team Organization

  • Cross-functional teams per service
  • Clear API contracts
  • Ownership and accountability
  • Communication patterns

References

  • Sam Newman - Building Microservices
  • Chris Richardson - Microservices Patterns
  • Kubernetes in Action
  • AWS Microservices Architecture
  • Kong API Gateway Guide