Skip to content

Latest commit

 

History

History
97 lines (71 loc) · 4.36 KB

File metadata and controls

97 lines (71 loc) · 4.36 KB

What is CQRS Manager for Distributed Reactive Services?

CQRS Manager for Distributed Reactive Services (herein abbreviated CMDR) is a component that provides the organizing principle in a specific architecture for building real-time, event-driven APIs with complex business logic at large scale. This architecture incorporates several well-known patterns:

  • CQRS (Command Query Responsibility Segregation), the separation of the write and read paths in an application
  • Event Sourcing, the modeling of state by capturing all domain events
  • Immutable Log-centric, Using an append-only log of immutable values to capture domain events
  • Reactive Responsive, Resilient, Elastic, and Message Driven. Discrete components react to messages (commands and events) independently, with low latency, and in a fault-tolerant way.

The combination of the above ideas has the potential to solve many of the thorny problems in existing service architectures.

Problem

Many APIs and services are architected something like this:

Problematic Architecture

This architecture is problematic in several ways:

Data Loss by Design

Lack of System Data Contracts Discourages Integration

Coupling of Action and Perception

Leaky Database Abstraction

Cross-cutting Concerns Interwoven with Application Concerns

Goals

In contrast, the CMDR architecture seeks to:

Capture Entire Narrative

Ease Integration via Data Contracts

Separate Action from Perception

Satisfy Cross-cutting Concerns given Conway's Law

CMDR Architecture

CMDR Architecture Diagram

CMDR provides web interfaces to handle incoming writes/commands, performs basic structural validation, and then writes them down to the commands topic in the log (Kafka for now, with support for other distributed log systems planned). See the data contract docs for more information on the specific data definition of the terms "command" and "event".

The application's own processes take over from there, first processing the incoming commands from the log, determining how to handle them, and then emitting one or more events to the event topic in the log. This command processor is a special case, and each command should only be handled by a single command processor.

Downstream event processors are a bit different, as many event processors can react to the same set of events, and can emit zero or more events in response to those events.

Some of these events will cause side effects of some kind, such as writing to a database. Most distributed log systems (like Kafka) provide at-least-once message processing semantics, so event processors should be idempotent in terms of side-effects.

Context and References