Logo Architecture Microservices Patterns

Architecture Microservices Patterns

Cộng đồng
j4flmao
architecture-microservices-patterns

Use this skill when the user says 'microservices patterns', 'split the monolith', 'saga', 'circuit breaker', 'service decomposition', 'database per service', 'API gateway', 'strangler fig', 'distributed monolith', 'service-to-service resilience'. Decides whether and how to decompose into services, then applies the core patterns: decomposition by capability, data ownership, sagas, resilience (timeouts, retries, circuit breakers, bulkheads), gateway/BFF, and migration via strangler fig. Do NOT use for: domain modeling inside a service (architecture/system-design/domain-driven-design), messaging infrastructure details (architecture/event-driven), or Kubernetes/service-mesh operations (devops skills).

Tổng quan

Nhà phát hànhj4flmao
Kho mãagent-skills
Tên kỹ năngarchitecture-microservices-patterns
Sao
41
Bản fork
6
Tệp đi kèm
Chỉ có hướng dẫn
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI là Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • Đầy đủ trong hướng dẫn

    Mọi thứ mô hình cần đều nằm trong hướng dẫn — không có tệp bổ sung cần đồng bộ.

  • Mã nguồn mở

    Được j4flmao công bố trên GitHub. Hãy đọc nội dung nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Architecture Microservices Patterns trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL thư mục kỹ năng bên dưới và xác nhận.
    https://github.com/j4flmao/agent-skills/tree/main/skills/architecture/system-design/microservices-patterns
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/j4flmao/agent-skills.git /tmp/agent-skills
mkdir -p .claude/skills
cp -r /tmp/agent-skills/skills/architecture/system-design/microservices-patterns .claude/skills/architecture-microservices-patterns
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Architecture Microservices Patterns trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự tải Architecture Microservices Patterns ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên Architecture Microservices Patterns không bị giới hạn ở mô hình mà kỹ năng này được viết cho. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên kỹ năng chưa dùng không tốn chi phí.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Microservices Architecture Patterns

Purpose

Microservices buy independent deployment and scaling per business capability at the cost of distributed-systems complexity: partial failure, network latency, eventual consistency, and operational overhead. This skill covers when that trade is worth it and the patterns that keep a service landscape from becoming a distributed monolith.

Agent Protocol

Trigger

"microservices", "service decomposition", "monolith to microservices", "saga", "compensating transaction", "circuit breaker", "bulkhead", "API gateway", "database per service", "strangler fig".

Input Context

  • Team count and structure; deployment frequency pain.
  • Domain map / bounded contexts.
  • Current architecture and data model; cross-entity transactions.
  • SLOs and traffic patterns.

Output Artifact

Decomposition proposal, per-service data ownership, interaction style per flow, resilience policy table, migration plan.

Response Format

Decision: {modular monolith|microservices} because {reason}
Services: {name}: capability, owns {data}, team {x}
Flow {name}: {sync|async} via {REST|gRPC|events}; consistency {saga orchestration|choreography}
Resilience per call: timeout={ms} retries={n, backoff+jitter, idempotent?} breaker={threshold}
Migration: strangler step {n}: route {path} -> {service}

Completion Criteria

  • Services aligned to business capabilities/bounded contexts.
  • Each service owns its data; no shared tables.
  • Every remote call has timeout; retries only on idempotent operations.
  • Multi-service business transactions modeled as sagas with compensations.
  • Observability: tracing across services, per-service SLOs.

When (Not) to Use

SituationRecommendation
Small team, unclear domainModular monolith with enforced module boundaries
Many teams blocked by shared deploysExtract services along team/capability lines
One component with very different scaling/runtime needsExtract that component only
Desire for "modern architecture"Not a reason

Decomposition

  • By business capability / bounded context (Ordering, Payments, Shipping), not by technical layer or by table (entity services).
  • Services should be able to fulfill most requests with their own data; frequent synchronous chains (A → B → C → D) signal wrong boundaries.
  • Database per service: other services access data only via API or events; read models replicate what they need.

Communication

StyleUse forRisks
Sync REST/gRPCQueries, user-facing request/responseTemporal coupling, latency chains
Async eventsPropagating state changesEventual consistency
Async commands (queue)Work requests to one ownerNeed correlation and replies

Gateway/BFF: single entry point for clients handling routing, auth, rate limiting; a BFF per client type when needs diverge.

Sagas

A saga is a sequence of local transactions; on failure, previously completed steps are undone by compensating transactions.

VariantCoordinationProsCons
ChoreographyServices react to each other's eventsNo central componentFlow hard to see; cyclic dependencies
OrchestrationOrchestrator sends commands, tracks stateExplicit flow, easier monitoringOrchestrator is extra component
python
from __future__ import annotations

import logging
from dataclasses import dataclass
from typing import Callable

log = logging.getLogger("saga")


@dataclass(frozen=True)
class Step:
    name: str
    action: Callable[[dict], None]        # must be idempotent (keyed by saga_id)
    compensate: Callable[[dict], None]    # must be idempotent and retryable


class SagaFailed(RuntimeError):
    pass


def run_saga(saga_id: str, steps: list[Step], ctx: dict) -> None:
    done: list[Step] = []
    for step in steps:
        try:
            step.action({**ctx, "saga_id": saga_id})
            done.append(step)          # persist progress in production (durable saga log)
        except Exception as exc:
            log.error("saga=%s step=%s failed: %s; compensating %d steps",
                      saga_id, step.name, exc, len(done))
            for prev in reversed(done):
                prev.compensate({**ctx, "saga_id": saga_id})
            raise SagaFailed(f"saga {saga_id} failed at {step.name}") from exc

# run_saga("ord-981", [Step("reserve_stock", reserve, release),
#                      Step("charge_payment", charge, refund),
#                      Step("schedule_shipping", schedule, cancel_shipment)], {"order_id": "981"})

In production, persist saga state (or use a durable workflow engine such as Temporal) so a crash mid-saga resumes or compensates; design for semantic rollback (refund, release) because steps are visible to others before the saga ends. Put the step most likely to fail early and irreversible steps (send email, ship) last.

Resilience Patterns

PatternPurposeGuidance
TimeoutBound waitingEvery call; inner timeouts shorter than outer; propagate deadlines
RetrySurvive transient faults2-3 attempts, exponential backoff + full jitter, idempotent ops only, one layer only
Circuit breakerStop hammering a failing dependencyOpen on failure rate over a sliding window; half-open probes
BulkheadContain resource exhaustionSeparate pools/concurrency limits per dependency
FallbackDegrade gracefullyCached/default data, feature off
Rate limiting / load sheddingProtect capacityReject early with 429/503

Resilience4j (Spring Boot) example; Hystrix is in maintenance mode since 2018:

yaml
resilience4j:
  circuitbreaker:
    instances:
      payments:
        slidingWindowType: COUNT_BASED
        slidingWindowSize: 50
        minimumNumberOfCalls: 20
        failureRateThreshold: 50
        waitDurationInOpenState: 30s
        permittedNumberOfCallsInHalfOpenState: 5
  timelimiter:
    instances:
      payments:
        timeoutDuration: 2s
  retry:
    instances:
      payments:
        maxAttempts: 3
        waitDuration: 200ms
        enableExponentialBackoff: true
        exponentialBackoffMultiplier: 2
        enableRandomizedWait: true

Other stacks: Polly (.NET), gobreaker / failsafe-go (Go), opossum (Node.js), or mesh-level outlier detection and retries (Envoy/Istio). Avoid retrying in both the mesh and the application.

Migration: Strangler Fig

  1. Put a routing facade (gateway/proxy) in front of the monolith.
  2. Extract one capability; route its endpoints to the new service.
  3. Sync data during transition (CDC from the monolith DB or events), then cut ownership over.
  4. Delete the old code path; repeat. Never big-bang rewrite.

Anti-Patterns

Anti-patternSymptomFix
Distributed monolithLockstep deploys, shared DBData ownership, async integration, contract tests
Entity servicesCustomerService, AddressService chatty callsCapability-based boundaries
Synchronous chainsLatency and availability multiplyEvents, local read models
Retry stormsOutage amplificationRetry budgets, jitter, breakers
No tracingUndebuggable incidentsOpenTelemetry across services and queues
2PC across servicesBlocking, couplingSagas

Checklist

  • Decomposition justified by teams/capabilities.
  • Data ownership matrix; no shared schemas.
  • Per-dependency timeout/retry/breaker/bulkhead table.
  • Sagas with compensations, idempotent steps, durable state.
  • Outbox for events; idempotent consumers.
  • Gateway/BFF, service discovery, tracing, per-service SLOs.
  • Consumer-driven contract tests in CI.

References

  • Richardson, "Microservices Patterns" (2018) and microservices.io; Newman, "Building Microservices" 2nd ed. (2021).
  • Nygard, "Release It!" 2nd ed. — stability patterns; Garcia-Molina & Salem, "Sagas" (SIGMOD 1987).
  • Resilience4j documentation.

Câu hỏi thường gặp

Kỹ năng AI Architecture Microservices Patterns làm được gì?

Use this skill when the user says 'microservices patterns', 'split the monolith', 'saga', 'circuit breaker', 'service decomposition', 'database per service', 'API gateway', 'strangler fig', 'distributed monolith', 'service-to-service resilience'. Decides whether and how to decompose into services, then applies the core patterns: decomposition by capability, data ownership, sagas, resilience (timeouts, retries, circuit breakers, bulkheads), gateway/BFF, and migration via strangler fig. Do NOT use for: domain modeling inside a service (architecture/system-design/domain-driven-design), messagi...

Vì sao nên dùng Architecture Microservices Patterns trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Architecture Microservices Patterns là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Architecture Microservices Patterns trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/j4flmao/agent-skills/tree/main/skills/architecture/system-design/microservices-patterns. TypingMind đọc tệp SKILL.md và cài đặt thành một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Architecture Microservices Patterns?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Bạn có thể dùng Architecture Microservices Patterns với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Architecture Microservices Patterns với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Architecture Microservices Patterns có miễn phí không?

Có. Kỹ năng này được j4flmao phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp cho mô hình các công cụ mới để gọi — mã được chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và tiêu chí của đầu ra tốt. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇