Distributed Services with Go

Book description

This is the book for Gophers who want to learn how to build distributed systems. You know the basics of Go and are eager to put your knowledge to work. Build distributed services that are highly available, resilient, and scalable. This book is just what you need to apply Go to real-world situations. Level up your engineering skills today.

Take your Go skills to the next level by learning how to design, develop, and deploy a distributed service. Start from the bare essentials of storage handling, then work your way through networking a client and server, and finally to distributing server instances, deployment, and testing. All this will make coding in your day job or side projects easier, faster, and more fun.

Create your own distributed services and contribute to open source projects. Build networked, secure clients and servers with gRPC. Gain insights into your systems and debug issues with observable services instrumented with metrics, logs, and traces. Operate your own Certificate Authority to authenticate internal web services with TLS. Automatically handle when nodes are added or removed to your cluster with service discovery. Coordinate distributed systems with replicated state machines powered by the Raft consensus algorithm. Lay out your applications and libraries to be modular and easy to maintain. Write CLIs to configure and run your applications. Run your distributed system locally and deploy to the cloud with Kubernetes. Test and benchmark your applications to ensure they're correct and fast.

Dive into writing Go and join the hundreds of thousands who are using it to build software for the real world.

What You Need:

Go 1.13+ and Kubernetes 1.16+

Publisher resources

View/Submit Errata

Table of contents

  1.  Acknowledgments
  2.  Introduction
    1. Who This Book Is For
    2. What’s in This Book
    3. Online Resources
  3. Part I. Get Started
    1. 1. Let’s Go
      1. How JSON over HTTP Services Fits into Distributed Systems
      2. Set Up the Project
      3. Build a Commit Log Prototype
      4. Build a JSON over HTTP Server
      5. Run Your Server
      6. Test Your API
      7. What You Learned
    2. 2. Structure Data with Protocol Buffers
      1. Why Use Protocol Buffers?
      2. Install the Protocol Buffer Compiler
      3. Define Your Domain Types as Protocol Buffers
      4. Compile Protocol Buffers
      5. Work with the Generated Code
      6. What You Learned
    3. 3. Write a Log Package
      1. The Log Is a Powerful Tool
      2. How Logs Work
      3. Build a Log
      4. What You Learned
  4. Part II. Network
    1. 4. Serve Requests with gRPC
      1. What Is gRPC?
      2. Goals When Building a Service
      3. Define a gRPC Service
      4. Compile with the gRPC Plugin
      5. Implement a gRPC Server
      6. Register Your Server
      7. Test a gRPC Server and Client
      8. What You Learned
    2. 5. Secure Your Services
      1. Secure Services in Three Steps
      2. Authenticate the Server with TLS
      3. Authenticate the Client with Mutual TLS Authentication
      4. Authorize with Access Control Lists
      5. What You Learned
    3. 6. Observe Your Systems
      1. Three Types of Telemetry Data
      2. Make Your Service Observable
      3. What You Learned
  5. Part III. Distribute
    1. 7. Server-to-Server Service Discovery
      1. Why Use Service Discovery?
      2. Embed Service Discovery
      3. Discover Services with Serf
      4. Request Discovered Services and Replicate Logs
      5. Test Discovery and the Service End-to-End
      6. What You Learned
    2. 8. Coordinate Your Services with Consensus
      1. What Is Raft and How Does It Work?
      2. Implement Raft in Our Service
      3. Multiplex to Run Multiple Services on One Port
      4. What You Learned
    3. 9. Discover Servers and Load Balance from the Client
      1. Three Load-Balancing Strategies
      2. Load Balance on the Client in gRPC
      3. Make Servers Discoverable
      4. Resolve the Servers
      5. Route and Balance Requests with Pickers
      6. Test Discovery and Balancing End-to-End
      7. What You Learned
  6. Part IV. Deploy
    1. 10. Deploy Applications with Kubernetes Locally
      1. What Is Kubernetes?
      2. Install kubectl
      3. Use Kind for Local Development and Continuous Integration
      4. Write an Agent Command-Line Interface
      5. Build Your Docker Image
      6. Configure and Deploy Your Service with Helm
      7. Advertise Raft on the Fully Qualified Domain Name
      8. What You Learned
    2. 11. Deploy Applications with Kubernetes to the Cloud
      1. Create a Google Kubernetes Engine Cluster
      2. Create Custom Controllers with Metacontroller
      3. Deploy to the Internet
      4. What You Learned

Product information

  • Title: Distributed Services with Go
  • Author(s): Travis Jeffery
  • Release date: March 2021
  • Publisher(s): Pragmatic Bookshelf
  • ISBN: 9781680507607