Zum Inhalt springen
_CORE
AI & Agentic Systems Core Information Systems Cloud & Platform Engineering Data Platform & Integration Security & Compliance QA, Testing & Observability IoT, Automation & Robotics Mobile & Digital Banking & Finance Insurance Public Administration Defense & Security Healthcare Energy & Utilities Telco & Media Manufacturing Logistics & E-commerce Retail & Loyalty
Referenzen Technologien Blog Know-how Tools
Über uns Zusammenarbeit Karriere
CS EN DE
Lassen Sie uns sprechen

Event Sourcing a CQRS — alternativa k CRUD

10. 11. 2016 1 Min. Lesezeit CORE SYSTEMSai
Event Sourcing a CQRS — alternativa k CRUD

potřebujete vědět, JAK se systém dostal do aktuálního stavu? Event Sourcing ukládá sérii událostí místo aktuálního stavu. CQRS odděluje čtení od zápisu.

Event Sourcing

Místo UPDATE account SET balance = 950 uložíte událost: AccountDebited(amount=50). Aktuální stav = replay všech událostí. Audit trail zdarma, time-travel debugging, možnost projekce do různých pohledů.

// Události objednávky
OrderCreated { orderId: "123", customerId: "456" }
LineAdded { orderId: "123", productId: "789", qty: 2 }
LineAdded { orderId: "123", productId: "012", qty: 1 }
OrderSubmitted { orderId: "123", timestamp: "2016-11-10T10:30:00Z" }
PaymentReceived { orderId: "123", amount: 1500.00 }
OrderShipped { orderId: "123", trackingNumber: "CZ123456" }

// Aktuální stav = replay těchto událostí

CQRS: Command Query Responsibility Segregation

Oddělení write modelu (commands) od read modelu (queries). Write model je optimalizovaný pro business logiku a validaci. Read model je optimalizovaný pro dotazy — denormalizovaný, materialized views, search indexy.

Kdy to dává smysl

  • Komplexní doménová logika (DDD)
  • Audit requirements (finance, healthcare)
  • Různé read modely z jedněch dat (dashboard, report, search)
  • Event-driven architektura s Kafkou

Kdy NE

  • Jednoduché CRUD aplikace — overkill
  • Malý tým bez DDD zkušeností
  • Systémy vyžadující silnou konzistenci (eventual consistency je trade-off)

ES/CQRS je mocný vzor pro správné problémy

Event Sourcing a CQRS nejsou silver bullet. Ale pro systémy s komplexní doménou, audit požadavky a event-driven architekturou jsou game changer.

awsarchitekturaec2s3
Teilen:

CORE SYSTEMS

Stavíme core systémy a AI agenty, které drží provoz. 15 let zkušeností s enterprise IT.

Brauchen Sie Hilfe bei der Implementierung?

Unsere Experten helfen Ihnen bei Design, Implementierung und Betrieb. Von der Architektur bis zur Produktion.

Kontaktieren Sie uns