算法艺术创作
algorithmic-art
通过代码和可调参数创作生成艺术与交互式视觉效果。
microservice-design-patterns【设计与创意】Hardcore microservice patterns including SAGA, CQRS, and Event Sourcing mechanics.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Distributed systems demand rigorous data consistency models and scalable communication pipelines. This reference explores advanced patterns for transaction management and state propagation in highly decoupled topologies.
In microservices, traditional ACID transactions (2PC/Two-Phase Commit) are antipatterns due to synchronous blocking and lock contention. SAGA mitigates this by decomposing a distributed transaction into a sequence of local ACID transactions.
If a local transaction fails, the SAGA executes compensating transactions to rollback the preceding steps, achieving eventual consistency.
CQRS separates the data modification (Command) and data retrieval (Query) pipelines, acknowledging that read and write workloads scale asymmetrically and require different storage paradigms.
Instead of storing the current state of an entity, Event Sourcing stores a purely append-only log of immutable domain events. The current state is derived by replaying the event stream (Left Fold).
%%{init: {"theme": "default", "flowchart": {"useMaxWidth": true}}}%%
flowchart TD
Client[Client Application] --> API[API Gateway]
API --> CMD[Command Handler / SAGA Orchestrator]
API --> QRY[Query Handler]
CMD --> ES[(Event Store - Append Only)]
ES -->|Event Bus / Message Broker| Proj[Event Projector]
Proj --> ReadDB[(Denormalized Read DB)]
QRY --> ReadDB
CMD --> ServiceA[Participant Service A]
CMD --> ServiceB[Participant Service B]
ServiceA -.->|Compensating Action| CMD