Streams, Queues and Distributed State
Introduction
- What You Will Learn
- The Reference Application: EdgeFleet
- Technology Stack
- How to Use This Book
- What This Book Does Not Cover
Chapter 1: Why Event-Driven? The Promise and the Peril
- The Connected World at Scale
- From Monolith to Events
- The Cost of Getting It Wrong
- What This Book Will Build
- How to Read This Book
Chapter 2: Event-Driven Architecture Foundations
- Events, Messages and Commands
- The Producer-Consumer Model
- Point-to-Point Versus Publish-Subscribe
- Coupling, Cohesion and Autonomy
- Anti-Patterns and Common Mistakes
Chapter 3: Message Brokers, Queues and Streams
- Queues: Load Leveling and Work Distribution
- Topic-Based Pub/Sub: Broadcasting and Filtering
- Event Streams: Ordered, Persistent, Replayable
- Broker Architectures: From RabbitMQ to Kafka to NATS
- Choosing a Messaging Primitive
Chapter 4: Kafka Internals and Architecture
- Topics, Partitions and Offsets
- The Broker and Controller
- Replication and ISR
- Producer Semantics and Batched Writes
- Consumer Groups and Offset Management
- Log Compaction and Retention
- Summary
Chapter 5: NATS, Pulsar and Cloud-Native Alternatives
- NATS and JetStream: Simplicity and Speed
- Apache Pulsar: Multi-Tenant Cloud Scale
- Managed Cloud Services: Kinesis, Pub/Sub, Event Hubs
- Brokerless and Mesh Architectures
- Platform Selection Matrix
- Summary
Chapter 6: Events, Schemas and Serialization
- Designing Domain Events
- Serialization Formats: JSON, Protobuf, Avro
- Schema Registry and Evolution Rules
- Backward and Forward Compatibility
- Summary
Chapter 7: Producers - Publishing Events Reliably
- Producer Design Patterns
- Kafka Producer Configuration
- Idempotent Producers
- Ordering Guarantees and Key-Based Routing
- Reference application: EdgeFleet producers
- Error Handling and Retries
- Summary
Chapter 8: Consumers - Processing Events Correctly
- Consumer Group Dynamics
- At-Least-Once and At-Most-Once Consumption
- Idempotent Consumers and Deduplication
- Backpressure and Graceful Degradation
- Reference Application: EdgeFleet Consumers
- Summary
Chapter 9: Stream Processing - Transformations and Joins
- Map, Filter and Aggregate
- Tumbling, Sliding and Session Windows
- Stream-Stream and Stream-Table Joins
- Stateful Processing and Checkpoints
- Reference Application: The Stream Processor
Chapter 10: Kafka Streams and Flink
- Kafka Streams: Embedded and Lightweight
- Apache Flink: Batch-and-Stream Unified
- State Stores and RocksDB
- Fault Tolerance and Recovery
- When to Use Which
- Summary
Chapter 11: Event Sourcing and CQRS
- Command Query Responsibility Segregation
- Event Sourcing: Appending the Truth
- Sagas and Distributed Transactions
- Read Models and Projections
- Reference Application: Event-Sourced Domain
Chapter 12: Distributed State Management
- Stateful Services in a Stateless World
- Distributed Caches and KV Stores
- Eventual Consistency and Conflict Resolution
- Partitioning State and Hot Keys
- Reference Application: Distributed State Store
- Summary
Chapter 13: Edge Computing Fundamentals
- Cloud, Fog and Edge: A Continuum
- Latency, Bandwidth and Autonomy
- Edge Runtimes: Containers, Functions and WASM
- Edge Deployment Models
- Reference Application: The Edge Topology
- Summary
Chapter 14: Serverless Event Processing
- Serverless Execution Models
- Cloud Functions: AWS Lambda, Cloudflare Workers, Azure Functions
- Edge Functions and CDNs
- Cold Starts, Limits and Workarounds
- Reference Application: Serverless Handlers
- Wrapping up
Chapter 15: Cloud-to-Edge Communication
- Edge-to-Cloud Patterns
- Store-and-Forward for Intermittent Connectivity
- Delta Sync and Operational Transformations
- Bi-Directional Event Routing
- Reference Application: Edge-to-Cloud Pipeline
- Summary
Chapter 16: Delivery Guarantees, Deep Dive
- At-Most-Once, At-Least-Once, Exactly-Once
- The Two-Phase Commit Problem
- Transactional Outbox Pattern
- Idempotent Operations: Making At-Least-Once Safe
- Reference Application: Transactional Messaging
- Summary
Chapter 17: Consistency, Ordering and Partitioning
- CAP and the PACELC Theorem
- Linearizability Versus Sequential Consistency
- Partition Key Design and Hot Spots
- Compensating for Disordered Events
- Reference Application: Consistency Choices
- Summary
Chapter 18: Fault Tolerance and Recovery
- Failure Modes in Distributed Systems
- Retries, Dead Letter Queues and Alerting
- Circuit Breakers and Bulkheads
- Leader Election and Raft
- Reference Application: Failure Handling
- Summary
Chapter 19: Observability and Operations
- Logging: Structure, Correlation and Volume
- Metrics: Red Signals and SLOs
- Distributed Tracing End to End
- Capacity Planning and Cost Control
- Reference Application: Observability Stack
- Summary
Chapter 20: Security, Secrets and Multi-Tenancy
- Authentication and Authorization Models
- TLS, mTLS and Encryption at Rest
- Secret Management Patterns
- Multi-Tenant Isolation and Quotas
- Reference Application: Security Layer
- Summary
Chapter 21: CI/CD, IaC and Deployment Automation
- Infrastructure as Code with Terraform
- Containerization and Kubernetes
- GitOps and Progressive Delivery
- Schema and Migration Pipelines
- Reference Application: Complete Deployment
- Summary
Chapter 22: Production Hardening and the Full System
- The Complete Reference Architecture
- Load Testing and Performance Validation
- Runbooks and On-Call
- Migrating from Monolith to Event-Driven
- What Comes Next