Architecture, Implementation, Reliability and Production Operations
Introduction
- What this book covers
- Technology choices
- Prerequisites
- How to read this book
- The reliability mindset
Chapter 1: The Problem with Synchronous Communication
- The synchronous trap: tight coupling and cascading failures
- Latency, throughput and resource exhaustion under load
- The network is not a memory bus: partitions, timeouts and partial failures
- Decoupling time, space and synchronization with messages
- When synchronous communication is still the right choice
Chapter 1 Summary
Chapter 2: Core Messaging Concepts
- Producers, consumers, brokers and message brokers versus message buses
- Topics, queues, partitions and exchange patterns
- Point-to-point versus publish-subscribe semantics
- Message anatomy: headers, keys, bodies and metadata
- Acknowledgments, offsets and delivery semantics
Chapter 2 Summary
Chapter 3: Delivery Guarantees and Their Meaning
- At-most-once: semantics, use cases and failure modes
- At-least-once: duplicate delivery, retries and crash windows
- Effectively-once processing: idempotency, deduplication and application guarantees
- The broker-consumer-database coordination problem
- Why true end-to-end exactly-once is a myth in practice
Chapter 3 Summary
Chapter 4: The CAP Theorem, PACELC and Messaging Trade-offs
- CAP revisited: consistency, availability, partition tolerance in messaging
- PACELC: understanding trade-offs during normal and failure conditions
- How messaging systems position themselves on the spectrum
- Throughput, latency, durability and operational complexity
- Choosing consistency levels for different business needs
Chapter 4 Summary
Chapter 5: Apache Kafka
- The log, partitions, replication and the controller
- Producers: batching, compression, acknowledgments and ordering
- Consumers, consumer groups, offsets and rebalancing
- Kafka transactions: write-ahead logs, transactional IDs and exactly-once semantics
- Limits: retention, replay constraints, latency tail behavior and operational overhead
Chapter 5 Summary
Chapter 6: RabbitMQ
- Exchanges, queues, bindings and routing keys
- Message durability, confirmations and negative acknowledgments
- Clustering, mirrored queues and quorum queues
- The transaction API, publisher confirms and reliability trade-offs
- When to choose RabbitMQ and when not to
Chapter 6 Summary
Chapter 7: NATS and JetStream
- The NATS core protocol and supercluster architecture
- Subjects, wildcards and request-reply patterns
- JetStream: stream storage, consumers and durable subscriptions
- Deliveries guarantees, ack policies and message retention
Chapter 7 Summary
Chapter 8: Redis Streams, Amazon SQS/SNS, Apache Pulsar and Database-Backed Queues
- Redis Streams: lightweight persistence with Redis familiarity
- Amazon SQS and SNS: managed, simple and opinionated
- Apache Pulsar: unified messaging and streaming with tiered storage
- Relational-database-backed queues: polling, locking and simplicity trade-offs
- Comparative summary: protocol, delivery, ordering, durability and ops complexity
Chapter 8 Summary
Chapter 9: Technology Selection Framework
- Defining selection criteria: workload patterns, data volume, latency SLAs and team skills
- Scenario analysis: high-throughput event streaming, reliable task queues, pub-sub eventing
- Stack recommendations: Kafka-first, RabbitMQ-first, managed-cloud-first, lightweight
- Multi-broker architectures and interoperability challenges
- Migration considerations and technology debt
Chapter 9 Summary
Chapter 10: The Reference Application
- Business domain: orders, inventory, payments, shipping and notifications
- Initial synchronous architecture and its failure modes
- Target microservice decomposition
- Data models, APIs and consistency requirements
- Technology stack decision: choosing the reference stack
Chapter 10 Summary
Chapter 11: Producers and Consumer Design
- Producer configuration: retries, acknowledgments, batching and compression
- Consumer design: processing loops, batching and graceful shutdown
- Serialization choices: JSON, Protobuf and schema registries
- Error handling: transient versus permanent failures
- Connection management and resource limits
Chapter 11 Summary
Chapter 12: Message Ordering and Partitioning
- Ordering guarantees within partitions
- Partition-key design for the order-processing domain
- Hot partitions and load imbalance
- Ordering across partitions and aggregates
- Trade-offs between ordering, parallelism and latency
Chapter 12 Summary
Chapter 13: Retries, Dead-Letter Queues and Poison Messages
- Retry strategies: exponential backoff, jitter and circuit breakers
- Dead-letter queues: routing, inspection and replay
- Poison messages: detection, isolation and remediation
- Retry limits and escalation
- Observability for failure patterns
Chapter 13 Summary
Chapter 14: Idempotency and Deduplication
- Idempotent operations in the order-processing domain
- Idempotency keys and deduplication tables
- Set-based versus record-based deduplication
- Handling idempotency with distributed locks
- Idempotency as a design principle, not a fix
Chapter 14 Summary
Chapter 15: Flow Control, Backpressure and Batching
- Backpressure: signals, pauses and graceful degradation
- Consumer rate limiting and prefetch tuning
- Batching: producer batching and consumer batching
- Memory management and resource exhaustion
- Coordinated flow control across services
Chapter 15 Summary
Chapter 16: ACID and Local Transactions
- ACID properties: atomicity, consistency, isolation, durability
- Isolation levels: read uncommitted through serializable
- Concurrency control: locking versus MVCC
- Transaction isolation anomalies
- When local transactions are sufficient
Chapter 16 Summary
Chapter 17: The Saga Pattern
- The distributed transaction problem across services
- Choreographed sagas: event-driven compensating transactions
- Orchestrated sagas: central coordinator and state machines
- Saga design for the order-processing reference application
- Choosing orchestration versus choreography
Chapter 17 Summary
Chapter 18: Two-Phase Commit and XA
- Two-phase commit: prepare and commit phases
- Transaction coordinators and participant failures
- Three-phase commit: reducing blocking
- XA specification and database support
- Why two-phase commit is rarely the right choice in microservices
Chapter 18 Summary
Chapter 19: The Transactional Outbox Pattern
- The crash window between commit and publish
- Outbox table design and transactional writes
- Publishing from the outbox: polling versus change data capture
- Idempotent event handling and consumer guarantees
Chapter 19 Summary
Chapter 20: Change Data Capture and Event Sourcing
- Change data capture: WAL readers, Debezium and log-based CDC
- CDC pipeline architecture and latency
- Event sourcing: events as the source of truth
- Combining CDC with the outbox pattern
- Trade-offs: complexity, auditability and debugging
Chapter 20 Summary
Chapter 21: Distributed Transaction Failure Modes
- Crash windows: commit without publish, publish without commit
- Duplicate delivery and compensating transaction idempotency
- Concurrent processing and race conditions
- Network partitions and split-brain scenarios
- Recovery procedures and state reconciliation
Chapter 21 Summary
Chapter 22: Deployment and Infrastructure
- Docker Compose for local development
- Kubernetes deployment: StatefulSets, storage and networking
- Resource planning: CPU, memory, disk IOPS and networking
- Infrastructure as code and environment parity
- Multi-region deployment and data locality
Chapter 22 Summary
Chapter 23: Security and Access Control
- Authentication: SASL, TLS and cloud IAM integration
- Authorization: topic-level and queue-level access control
- Encryption: in transit and at rest
- Secrets management and credential rotation
- Least privilege and audit logging
Chapter 23 Summary
Chapter 24: Observability: Logging, Metrics and Tracing
- Structured logging with correlation IDs
- Metrics: throughput, latency, queue depth and error rates
- Distributed tracing across services and message hops
- Dashboards and alerting: SLOs and meaningful thresholds
- Debugging message flow and dead-letter analysis
Chapter 24 Summary
Chapter 25: Reliability, Scaling and Disaster Recovery
- High availability: replication, failover and rolling upgrades
- Horizontal scaling: brokers, partitions and consumers
- Capacity planning and load testing methodology
- Backup, restore and disaster recovery procedures
- Incident response and postmortem practices
Chapter 25 Summary
Chapter 26: Anti-Patterns, Migration and Evolution
- Anti-patterns: chatty services, message bloating and hidden synchronous calls
- Schema evolution and backward compatibility
- Migrating between messaging technologies
- Breaking change management in event-driven systems
- When to abandon messaging and simplify
Chapter 26 Summary
Conclusion: The Reliability Mindset
- Summary of core principles
- Choosing simplicity where possible, sophistication where necessary
- Continuous learning and staying current
- Final recommendations for practice