Leanpub Header

Skip to main content

Distributed Systems in Go: The Course

Build Go services that communicate, fail and recover, ending with one complete distributed system.

The instructor has published 100% of this course.Last updated on 2026-10-26

Go from two services and a queue to a complete distributed system in Go. Chapter quizzes and a final exam lead to a certificate.

Minimum price

$149

$149

You pay

Author earns

$

Also available for 1 course credit with a Learner Membership

PDF
EPUB
WEB
61,387Words
About

About

About the Course

Distributed Systems in Go

Build Go services that communicate, fail and recover, ending with one complete distributed system.

What You'll Learn

✔ Understand the cost of coordination and when to distribute

✔ Use Go concurrency as distributed systems in miniature

✔ Build HTTP services, middleware and JWT auth across services

✔ Propagate context across service boundaries

✔ Work with Kafka: backpressure and consumer groups

✔ Make gRPC calls with retries and circuit breakers

✔ Handle consistency, observability, config and secrets

✔ Test distributed systems and assemble a capstone system

Who Is This Course For?

Go developers and backend engineers moving from single services to systems of cooperating services.

Prerequisites

Working knowledge of Go basics (types, functions, goroutines). Familiarity with HTTP and databases helps.

Why This Course?

Each chapter grows the same codebase, so you see how queues, RPC, consistency and observability fit together in one running system.

How It Works

  • 15 chapters, each ending with a 5-question multiple-choice quiz (3 attempts, best score counts)
  • A 20-question final exam covering the whole course
  • 95 quiz questions in total
  • Score 70% to pass; 85% or more earns honors
  • Pass to receive a certificate of completion

Written by Joel Bryan Juliano.

Instructor

About the Instructor

Joel Bryan Juliano

Hi, I'm Joel.

I am Dutch-Filipino Software Engineer with 20+ years of experience.

And with over 20 years in the game, I’ve seen it all and loved every minute of it.

My journey has taken me through a variety of industries, from sports streaming to cybersecurity, both in the private sector and for the Dutch government, and everything in between.

Along the way, I’ve picked up a diverse set of skills and experiences, in which I document into books.

Material

Course Material

  • Preface

  • Why Cloud-Native Distributed Systems?

  • Who This Book Is For

  • How to Read This Book

  • About the Code

  • What This Book Is Not

  • Introduction

  • The Problem with Distributed Systems Books

  • The Mental Model

  • The Company SDK

  • The System We Build

  • The Code Style

  • Before You Begin

  • Chapter 1: Why Distributed? The Cost of Coordination

  • The Limits of One

  • The Eight Things You Cannot Assume

  • When You Have To

  • The Hidden Tax

  • Latency math

  • Failure taxonomy

  • Operational surface area

  • The Struct-to-Service Progression

  • Go’s Fit

  • The Monolith-First Principle

  • What You Will Build

  • Q&A

  • Chapter 1 Quiz

    3 attempts allowed

  • Chapter 2: Concurrency as Distributed Systems in Miniature

  • Goroutines

  • The lifecycle problem

  • Channels

  • Directional channels

  • Buffered vs unbuffered

  • Closing channels

  • select

  • Timeout with select

  • Non-blocking operations

  • sync.WaitGroup

  • context.Context

  • The cancellation tree

  • WithCancel

  • WithTimeout and WithDeadline

  • Checking cancellation

  • Context values

  • Putting It Together: A Worker Pool

  • Graceful Shutdown

  • The Concurrency Mental Model

  • Q&A

  • What Goes in the SDK

  • Chapter 2 Quiz

    3 attempts allowed

  • Chapter 3: Two Services, One Queue

  • Why a Queue and Not an HTTP Call?

  • NATS for a First Example

  • The Interfaces

  • The Producer

  • The Consumer

  • Running It

  • Loose Coupling in Practice

  • Error Handling and Reconnection

  • The Complete Picture

  • What Goes in the SDK

  • Chapter 3 Quiz

    3 attempts allowed

  • Chapter 4: HTTP Services and Middleware Chains

  • net/http in Go 1.22

  • The Handler Interface

  • Building a Middleware Chain

  • The Essential Middleware

  • Recovery

  • Request ID

  • Logging

  • Body Close

  • Request Timeout

  • CORS

  • Structured Error Responses

  • JSON Request Binding

  • Health Check Patterns

  • The Complete Service

  • Testing HTTP Handlers

  • What Frameworks Add

  • Q&A

  • What Goes in the SDK

  • Chapter 4 Quiz

    3 attempts allowed

  • Chapter 5: Authentication and JWT Across Services

  • What a JWT Is

  • HMAC vs RSA vs ECDSA

  • Generating and Validating Tokens with ECDSA

  • The JWKS Endpoint

  • Auth Middleware

  • Scope-Based Authorization

  • The Auth Service

  • Pluggable Authentication Agents

  • Token Propagation Between Services

  • Adding Auth to the Service Chain

  • Testing Auth

  • Q&A

  • What Goes in the SDK

  • Chapter 5 Quiz

    3 attempts allowed

  • Chapter 6: Database Access and Migrations

  • pgx: PostgreSQL Done Right

  • Connection pool sizing

  • PgBouncer for connection pooling at scale

  • The Repository Pattern

  • Transactions

  • Savepoints

  • sqlc: Type-Safe SQL Without an ORM

  • Schema Migrations

  • Zero-Downtime Migrations

  • One Database Per Service

  • Observability for Database Operations

  • Q&A

  • What Goes in the SDK

  • Chapter 6 Quiz

    3 attempts allowed

  • Chapter 7: Context Propagation — The Thread Connecting Everything

  • How the Context Tree Fails

  • The Context Discipline

  • Deadline Propagation

  • Narrowing Deadlines

  • Context Values in Practice

  • The Context Anti-Patterns

  • Context across goroutine trees

  • Detaching from the parent context

  • Connecting the Layers

  • Q&A

  • What Goes in the SDK

  • Chapter 7 Quiz

    3 attempts allowed

  • Chapter 8: Message Queues in Depth — Kafka, Backpressure, and Consumer Groups

  • How Kafka Works

  • Message keys and partition assignment

  • Writing a Kafka Producer

  • Writing a Kafka Consumer

  • Consumer rebalancing

  • Backpressure

  • Scale out consumers

  • Process in batches

  • Dead-letter queues

  • Consumer Groups in Action

  • Dynamic Topic Subscriptions

  • Message Schema Management

  • Q&A

  • What Goes in the SDK

  • Chapter 8 Quiz

    3 attempts allowed

  • Chapter 9: Service-to-Service Calls — gRPC, Protobuf, Retries, and Circuit Breakers

  • Why gRPC for Internal Communication

  • Defining a Service with Protocol Buffers

  • Generating Go Code with buf

  • Implementing the gRPC Server

  • Running the gRPC Server

  • The gRPC Client with Interceptors

  • Service Token Authentication

  • The Dual API Pattern: Management vs Consumption

  • Timeouts and Retries

  • HTTP timeouts

  • Retries with exponential backoff

  • The Circuit Breaker

  • Choosing: HTTP vs gRPC

  • Q&A

  • What Goes in the SDK

  • Chapter 9 Quiz

    3 attempts allowed

  • Chapter 10: Orchestration — Parallel Flows and Fan-Out

  • The Sequential Problem

  • Fan-Out with errgroup

  • Concurrency safety

  • SetLimit: capping concurrency

  • Partial Failure Handling

  • Pipeline Composition

  • Fan-Out to Dynamic Targets

  • Collecting results concurrently

  • Timeout Budget Across a Multi-Step Flow

  • Measuring the Impact

  • What Goes in the SDK

  • Q&A

  • Chapter 10 Quiz

    3 attempts allowed

  • Chapter 11: Distributed Consistency in Practice

  • The CAP Theorem, Applied

  • Eventual Consistency

  • Idempotency Keys

  • Optimistic Locking

  • The Saga Pattern

  • Event-Driven Consistency

  • Detecting Inconsistency

  • The Outbox Pattern

  • Reconciliation in Practice

  • What Goes in the SDK

  • Q&A

  • Chapter 11 Quiz

    3 attempts allowed

  • Chapter 12: Observability — Logging, Metrics, and Tracing

  • Structured Logging with slog

  • Setting up slog

  • Log levels and when to use them

  • Context-aware logging

  • Multi-transport log aggregation

  • Metrics with Prometheus

  • The three metric types

  • Recording metrics in middleware

  • Business metrics alongside technical metrics

  • Distributed Tracing with OpenTelemetry

  • Setting up the trace provider

  • Automatic HTTP instrumentation

  • Manual spans for database and queue operations

  • Connecting the three pillars

  • Alerting: When Metrics Become Alarms

  • Q&A

  • What Goes in the SDK

  • Chapter 12 Quiz

    3 attempts allowed

  • Chapter 13: Testing Distributed Systems

  • The Testing Pyramid for Distributed Systems

  • Testing with Real Databases: testcontainers

  • Sharing containers across tests

  • The -race Flag

  • Testing with Fake Implementations

  • Testing Idempotency

  • Chaos Testing: Kill a Dependency Mid-Test

  • goleak: Finding Goroutine Leaks

  • Table-Driven Tests for Edge Cases

  • Q&A

  • What Goes in the SDK

  • Chapter 13 Quiz

    3 attempts allowed

  • Chapter 14: Configuration and Secrets

  • The Twelve-Factor Principle

  • Configuration With Struct Tags

  • Viper for Complex Configuration

  • Configuration Validation at Startup

  • The startup sequence

  • Secrets Management

  • Conditional Secret Exposure

  • Live Reload via Signal Handler

  • Configuration in a Multi-Service System

  • Configuration Testing

  • Q&A

  • What Goes in the SDK

  • Chapter 14 Quiz

    3 attempts allowed

  • Chapter 15: Capstone — One Complete System

  • The Design

  • The Data Flows

  • The Repository Structure

  • Implementing the Core: The Order Service

  • The docker-compose

  • The API Gateway

  • Service Discovery

  • Two-Phase Service Startup

  • Deploying to Kubernetes

  • The cloud-native contract

  • Tracing a Request

  • Running It

  • The Integration Test

  • What You Have Built

  • Production Hardening Checklist

  • Q&A

  • Chapter 15 Quiz

    3 attempts allowed

  • Final Exam

  • Final Exam

    2 attempts allowed

  • Appendix A: Go Concurrency Quick Reference

  • Goroutines

  • Channels

  • select

  • context.Context

  • sync.WaitGroup

  • sync.Mutex / sync.RWMutex

  • sync/atomic

  • errgroup

  • signal.NotifyContext (graceful shutdown)

  • Common Patterns

  • Appendix B: File and Object Storage Abstraction

  • The Storage Interface

  • The S3 Adapter

  • The Local Filesystem Adapter

  • Wiring It Up

  • The Platform SDK Package

  • When to Reach for Afero

  • Appendix C: CLI Tooling for Operations

  • The CLI Structure

  • The Migration Runner

  • The Health Checker

  • Admin Commands

  • Reconciliation

  • Testing CLI Commands

  • What Goes in the SDK

  • Beyond CLI: Operational TUIs

  • Glossary

  • Acknowledgements

  • Credits

  • Further Reading

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.)

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