본문으로 건너뛰기
Skillpedia
기타48k · #5233

patterns

하는 일

이 문서는 CQRS, Event Sourcing, Saga 같은 프로그래밍의 설계 패턴을 다루는 참고 자료입니다. 각 패턴이 무엇인지, 언제 쓰는지, 어떻게 작동하는지 설명합니다.

사용하는 경우

  • ✓디자인 패턴에 대해 배우고 싶을 때.
  • ✓복잡한 시스템을 정리하는 방법을 이해하고 싶을 때.
  • ✓흔한 소프트웨어 문제에 대한 해결책을 찾을 때.

스킬 링크

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/monopoly/patterns/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/monopoly/patterns/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“서킷 브레이커(Circuit Breaker) 패턴을 설명해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

이 문서는 여러 소프트웨어 설계 패턴을 나열하고 설명합니다. 각 패턴마다 무엇인지, 언제 유용한지, 어떻게 구현하는지, 장단점이 무엇인지 자세히 설명합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

MONOPOLY — Design Patterns Deep Dive

When to Use

  • Use this skill when the task matches this description: Reference document for monopoly patterns.

Table of Contents

  1. CQRS
  2. Event Sourcing
  3. Saga Pattern
  4. Circuit Breaker
  5. Bulkhead
  6. Strangler Fig
  7. Sidecar / Service Mesh
  8. Outbox Pattern
  9. Consistent Hashing
  10. Backpressure
  11. Leader Election
  12. Two-Phase Commit

1. CQRS (Command Query Responsibility Segregation)

What it is: Separate the read model (Query) from the write model (Command) into distinct services, databases, or code paths.

When to use:

  • Read load is 10×+ write load (most web apps)
  • Read queries are complex aggregations over write data
  • Need to optimize read and write paths independently
  • Domain model is complex (DDD contexts)

Implementation:

Write Path:  Client → Command API → Write DB (normalized, PostgreSQL)
Read Path:   Client → Query API  → Read DB (denormalized, Redis / Elasticsearch)
Sync:        Write DB → CDC (Debezium) → Message Queue → Read DB updater

Trade-offs:

  • ✅ Independent scaling of read and write
  • ✅ Optimized schemas for each operation type
  • ❌ Eventual consistency between write and read models
  • ❌ Increased complexity; two models to maintain

Real-world users: Amazon (order service), LinkedIn (feed)


2. Event Sourcing

What it is: Store state as a sequence of immutable events rather than current state. Rebuild current state by replaying events.

When to use:

  • Full audit trail is a regulatory requirement (fintech, healthcare)
  • Need to replay history for debugging or analytics
  • Complex domain with many state transitions
  • Need to derive multiple read projections from same data

Implementation:

Event Store: append-only log (Kafka, EventStoreDB)
Snapshots:   periodic snapshots to speed up state rebuild
Projections: consumers build read models from events

Trade-offs:

  • ✅ Complete audit history; perfect for compliance
  • ✅ Replay and time-travel debugging
  • ❌ Querying current state requires projection maintenance
  • ❌ Event schema evolution is hard
  • ❌ High storage overhead over time

3. Saga Pattern

What it is: Manage distributed transactions across microservices via a sequence of local transactions, each publishing an event. If a step fails, compensating transactions undo previous steps.

Two variants:

  • Choreography: Services react to events autonomously (decentralized)
  • Orchestration: A central Saga Orchestrator coordinates steps (centralized)

When to use:

  • Multi-service workflows where ACID across services is impossible
  • Long-running business transactions (order → payment → inventory → shipping)
  • Need rollback across service boundaries

Choreography Example:

OrderService creates order →
  [event: OrderCreated] →
    PaymentService charges card →
      [event: PaymentProcessed] →
        InventoryService reserves stock →
          [event: StockReserved] →
            ShippingService books courier

Compensating Transactions (on failure):

ShippingService fails →
  [event: ShippingFailed] →
    InventoryService releases stock →
      PaymentService refunds card →
        OrderService marks order failed

Trade-offs:

  • ✅ No distributed locking; high availability
  • ✅ Scales well across services
  • ❌ Hard to debug; distributed trace required
  • ❌ Compensating transactions are complex to implement correctly

4. Circuit Breaker

What it is: A proxy that monitors calls to a service. If failure rate exceeds threshold, the circuit "opens" and calls fail fast instead of waiting for timeout.

States:

CLOSED  → calls pass through; monitor failure rate
OPEN    → calls fail immediately; no calls to downstream
HALF-OPEN → let a probe call through; if success, close; if fail, stay open

When to use:

  • Calling any external service (payment gateway, SMS, email)
  • Microservices calling each other
  • Preventing timeout cascade when downstream is slow

Implementation tools: Hystrix (deprecated), Resilience4j, Polly (.NET), Envoy proxy

Thresholds (starting point):

  • Open after 50% failure rate over 10 requests
  • Stay open for 30 seconds
  • Half-open: allow 1 probe request

Trade-offs:

  • ✅ Prevents cascade failures
  • ✅ Gives downstream time to recover
  • ❌ Adds latency overhead for monitoring
  • ❌ Requires fallback behavior when circuit is open

5. Bulkhead

…

자주 묻는 질문

「디자인 패턴」이란 무엇인가요?

소프트웨어 개발에서 흔히 마주치는 문제에 대한 재사용 가능한 해결책입니다. 더 체계적이고, 효율적이며, 유지보수하기 쉬운 코드를 만드는 데 도움이 됩니다.

CQRS와 Event Sourcing의 차이는 무엇인가요?

CQRS는 읽기와 쓰기 작업을 분리하고, Event Sourcing은 모든 변경 사항을 일련의 이벤트로 기록합니다.

「Saga 패턴」이란 무엇인가요?

여러 서비스가 관련된 트랜잭션을 관리하는 방식입니다. 한 부분이 실패하더라도 모든 것이 올바르게 완료되거나 되돌려지도록 보장합니다.

상세 정보

작성자의 원본 설명

Reference document for monopoly patterns.

repo: sickn33/agentic-awesome-skills

인기도

GitHub 스타
48k
순위
#5233
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬