"Distributed Systems in Go" — a practical guide to designing, developing, and deploying reliable distributed systems using the Go language. The book is based on the author's real experience in creating and operating cloud distributed systems and covers the entire journey from developing individual HTTP services to building a full-fledged microservices architecture.
Sooner or later, every Go developer encounters a situation where a single application is no longer sufficient. The need arises to create multiple interacting services, ensure authentication, organize data storage, configure message exchange, and maintain stable system operation even in the event of failures.
Knowledge of the CAP theorem and the basic principles of distributed computing is just a starting point. The real challenges begin in actual conditions when Kafka consumers can't process messages in time, inter-service requests timeout, and identifying the problem's source becomes increasingly difficult.
This book helps bridge the gap between theory and practice. The author systematically demonstrates the creation of a complete distributed system, covering authentication, databases, message queues, gRPC, failure recovery mechanisms, and distributed tracing.
Each chapter is dedicated to a specific architectural pattern, which is then implemented as reusable components of a platform SDK. By chapter 15, the reader will have created a deployable system consisting of six services and their own SDK, simplifying the development of subsequent applications.
What You Will Learn and Create
- HTTP Services: Developing HTTP services in Go using composable middleware without the need for additional frameworks.
- Authentication and Security: Implementing JWT authentication with ECDSA digital signatures and pluggable authentication agents.
- PostgreSQL and Data Management: Organizing work with databases, performing migrations without stopping the system, and implementing the Transactional Outbox pattern.
- Apache Kafka: Creating message producers and consumers, managing backpressure, and using Dead Letter Queues.
- gRPC and Inter-Service Interaction: Setting up service interactions with retry mechanisms, timeouts, and Circuit Breakers.
- Distributed Consistency: Applying the Saga pattern, idempotency keys, and data reconciliation mechanisms.
- Monitoring and Observability: Implementing structured logging using slog, metrics collection through Prometheus, and distributed tracing with OpenTelemetry.
- Testing and Resilience: Testing components on real infrastructure using Testcontainers, modeling failures, and applying chaos testing approaches.
- Deployment in Kubernetes: Preparing configuration manifests and deploying a full-scale distributed system consisting of six services.
Practical Outcome
The main feature of the book is the consistent creation of a real system, rather than studying individual tools in isolation from practice.
Each code example is complete and self-sufficient. As you progress through the material, you will not only master architectural approaches but also build your own library of reusable components.
As a result, you will have a working distributed system consisting of six services, ready for deployment, as well as a platform SDK that will allow you to create new services faster and more efficiently.
Who This Book Is For
This book is intended for Go developers who already know how to create individual applications and services but want to move to designing full-fledged distributed systems.
It will be especially useful for engineers working with microservices, cloud infrastructure, databases, and asynchronous message processing.
If you have ever had to copy middleware without fully understanding its function, dealt with context deadline exceeded errors, or searched for the causes of failures across several interacting services, this book will help you systematize your knowledge and master practical tools to solve such tasks.