Source
Brief overview in Russian
My book review on Tell Me About Tech
Microservice Patterns and Best Practices
Authors: Vinicius Feitosa Pacheco
Publisher: Packt Publishing, 2018
Length: 366 pages
CQRS patterns, Event Sourcing, communication strategies and best practices for scalable microservices from Vinicius Feitosa Pacheco.
OriginalRelated topic
Monolith to Microservices
Detailed migration patterns from Sam Newman
From monolith to microservices
The book begins with an analysis of the evolution of architectural approaches. Monolithic applications work great at startup, but the word "success" becomes a problem - when the system grows, difficulties arise with scaling, deployment and support.
Evolution of architectural patterns
Benefits of Microservices
Related book
Building Microservices
Sam Newman's seminal work on microservices
Key patterns
The author examines in detail patterns that help solve typical problems of distributed systems:
CQRS
Command Query Responsibility Segregation - separation of read and write
Event Sourcing
Storing all changes as a sequence of events
Event-Driven
Asynchronous communication through events
Circuit Breaker
Protection against cascading failures
API Gateway
Single point of entry for clients
Saga Pattern
Distributed transactions via events
CQRS and Event Sourcing
CQRS (Command Query Responsibility Segregation)
Dividing the model into two parts: Command for recording and Query for reading. This allows each part to be optimized independently.
- Different data models for reading and writing
- Independent read/write scaling
- Optimization for specific use cases
Event Sourcing
Instead of storing the current state, we store all eventsthat led to this condition. This gives a complete history of changes.
- Full audit log out of the box
- Ability to replay events
- Temporal queries (state at any point in time)
💡 CQRS and Event Sourcing are often used together, but this independent patterns. You can use CQRS without Event Sourcing and vice versa.
Integration Patterns
Enterprise Integration Patterns
Integration classics: messaging, routing, transformation
Communication Strategies
Synchronous communication
REST, gRPC - the client waits for a response from the server.
Asynchronous communication
Message queues, event streaming — fire-and-forget.
Practical examples from the book
The book contains several practical examples of building microservice systems using different technologies:
Python + nameko
Microservice framework for Python with RPC and event-driven patterns.
Go + gRPC
High performance services with Protocol Buffers.
Event Streaming
Kafka/RabbitMQ for asynchronous communication.
