Leanpub Header

Skip to main content

Distributed Systems with Python and RabbitMQ

Designing Reliable, Scalable Messaging Architectures for Production

This book is 100% completeLast updated on 2026-08-04

Build distributed systems that keep working when things go wrong. This hands-on guide shows you how to design reliable messaging architectures with Python and RabbitMQ, from core concepts to production-ready patterns. Follow real projects, write practical code and learn how to build scalable services that recover gracefully under load.

Minimum price

$19.00

$29.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
WEB
APP
246
Pages
About

About

About the Book

This book teaches intermediate to advanced software engineers how to design, implement, deploy, operate, scale, and maintain robust distributed systems using Python and RabbitMQ. You will move from fundamental concepts of distributed computing through practical messaging patterns to production-ready architectures with complete, runnable code examples. Every chapter builds on the previous one, culminating in real-world projects that demonstrate event-driven microservices, distributed transactions via sagas, and comprehensive observability. By the end, you will have both the theoretical foundation and hands-on experience to build systems that stay reliable under load and recover gracefully from failure.

Author

About the Author

Steve Publications

Steve is a technology professional with more than 20 years of experience in software development, server infrastructure, cybersecurity, vulnerability research and reverse engineering. Throughout his career, he has designed, secured, analyzed and tested complex software and infrastructure, with a particular focus on understanding how systems fail and how they can be made more secure.

Outside of work, Steve enjoys sharing knowledge with the technology community. He collaborates with researchers, industry experts and technology professionals to write practical books covering software development, cybersecurity, cloud computing, networking, DevOps, artificial intelligence and enterprise technologies. His books focus on practical learning through clear explanations, real-world examples and hands-on exercises. With more than two decades of industry experience, his goal is to help IT professionals, students and technology enthusiasts build useful skills and stay current in a rapidly changing industry.

We believe readers deserve to know how our books are created. Most of our authors are not native English speakers, so we use AI to help translate, proofread manuscripts, fix grammar, improve sentence structure and make technical explanations easier to read. AI is used as an editing tool only. It does not replace the research, technical knowledge or hands-on experience behind our books. Some of our authors also prefer to remain anonymous for privacy or professional reasons. In those cases, we publish their work under a different name. The author's name may be different, but the quality of the content and our review process remain the same.

Every book is written, reviewed and maintained by experienced technology professionals, with contributions from our private technical community of more than 420 engineers and researchers. We spend far more time validating technical accuracy and keeping our content up to date than generating text. We are always interested in working with experienced professionals who have deep expertise in a particular technology or domain. If you would like to publish a book with us or help review an existing manuscript, we'd love to hear from you. Send us a message describing your area of expertise. We are especially interested in niche technologies, specialized skills and emerging topics that are underrepresented in existing technical literature.

If you look through the contents of our books, you'll see practical examples, detailed explanations and material that is regularly updated. Our goal is to publish books that professionals can actually rely on, not low-effort AI-generated content. If you ever feel that one of our books does not meet that standard, Leanpub offers a 60-day money-back guarantee. Feel free to request a refund if you are not satisfied with your purchase.

Contents

Table of Contents

Designing Reliable, Scalable Messaging Architectures for Production

Chapter 1: Why Distributed Systems Matter

  1. The Inevitability of Distribution
  2. What Goes Wrong (and Often Does)
  3. The Cost of Getting It Right
  4. How This Book Is Structured

Chapter 2: Foundations of Distributed Systems

  1. The CAP Theorem (and What It Really Means)
  2. Consistency Models from Strong to Eventual
  3. Fault Tolerance and Failure Modes
  4. Reliability, Availability, Durability
  5. Idempotency as a Design Principle

Chapter 3: Messaging and Communication Patterns

  1. Synchronous vs Asynchronous Communication
  2. Point-to-Point and Queue-Based Messaging
  3. Publish/Subscribe and Event Streaming
  4. Request/Reply Patterns
  5. Event-Driven Architecture Fundamentals

Chapter 4: RabbitMQ Architecture and Core Concepts

  1. Installing and Configuring RabbitMQ
  2. Nodes, Clusters, and Topology
  3. Virtual Hosts and Namespaces
  4. Exchanges and Their Types
  5. Queues, Bindings, and Routing Keys
  6. The Message Lifecycle

Chapter 5: Python Clients and Connection Management

  1. Choosing Your Client Library
  2. Connection Parameters and Heartbeats
  3. Channel Management Best Practices
  4. Async vs Sync Clients
  5. Robust Reconnection Strategies
  6. Resource Cleanup and Graceful Shutdown

Chapter 6: Building Reliable Producers and Consumers

  1. Publishing Messages Correctly
  2. Consumer Acknowledgements and Nacks
  3. Publisher Confirms for Delivery Guarantees
  4. Message Durability and Persistence
  5. Prefetch Tuning and Flow Control
  6. Error Handling Patterns

Chapter 7: Advanced RabbitMQ Features

  1. Priority Queues for Critical Workloads
  2. Delayed and Scheduled Messaging
  3. Dead-Letter Exchanges and Retry Strategies
  4. Message Time-to-Live and Expiration
  5. RabbitMQ RPC Pattern Implementation
  6. Queue Arguments and Advanced Configuration

Chapter 8: Designing Robust Distributed Systems

  1. Retry Strategies with Exponential Backoff
  2. Circuit Breaker Pattern Implementation
  3. The Saga Pattern for Distributed Transactions
  4. Idempotent Consumer Design
  5. Message Ordering Guarantees
  6. Handling Duplicate and Out-of-Order Messages

Chapter 9: Project One - Production Task Queue System

  1. Requirements and Architecture Decisions
  2. Project Structure and Configuration
  3. Task Serialization and Schema Design
  4. Worker Implementation with Graceful Shutdown
  5. Retry Logic and Dead-Letter Handling
  6. Testing the Task Queue System
  7. Docker and Deployment Configuration

Chapter 10: Event-Driven Microservices with CQRS

  1. Microservice Communication via Events
  2. Implementing the CQRS Pattern
  3. Event Sourcing Integration Concepts
  4. Inter-Service Saga Orchestration
  5. Domain Events and Event Versioning
  6. Handling Schema Evolution

Chapter 11: Observability in Production

  1. Structured Logging for Distributed Systems
  2. Metrics Collection with Prometheus
  3. Distributed Tracing with OpenTelemetry
  4. Health Checks and Readiness Probes
  5. Debugging Message Flow Issues
  6. Correlation IDs Across Services

Chapter 12: Security, Authentication, and Authorization

  1. TLS/SSL Encryption End-to-End
  2. User Authentication and Password Policies
  3. Authorization and Access Control
  4. VHost Isolation Strategies
  5. Secrets Management in Production
  6. Network Security and Firewalls

Chapter 13: Deployment, Scaling, and High Availability

  1. Docker and Docker Compose Setup
  2. RabbitMQ Clustering Fundamentals
  3. Quorum Queues for High Availability
  4. Federation and Shovel Plugins
  5. Kubernetes Deployment Patterns
  6. Performance Tuning and Capacity Planning

Chapter 14: Production Pitfalls and Troubleshooting

  1. Memory Pressure and Flow Control
  2. Disk Alarms and Storage Management
  3. Diagnosing Consumer Lag
  4. Connection Storms and Resource Exhaustion
  5. Split-Brain Scenarios
  6. Systematic Troubleshooting Methodology

Conclusion

References

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub