Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Travis Jeffery

Rating No ratings yet

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.

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 This is the hands-on guide for Go developers who want to build production-grade distributed systems from scratch—covering storage, networking, security, consensus, and deployment—by constructing a complete service called "proglog" chapter by chapter. 【Book Arc】 - **Opening (~0%–6%)**: Sets up the project and explains why Go is ideal for building JSON/HTTP services, using the standard library's encoding/json and net/http to create a simple commit log server. - **Early (~6%–19%)**: Introduces Protocol Buffers (protobuf) for structured data, covering schema design, field versioning, and code generation—then builds a log package as the core storage layer. - **Early (~19%–34%)**: Implements the commit log library with segments, memory-mapped indexes, and append/read operations, including testing and handling edge cases like out-of-range offsets. - **Middle (~38%–47%)**: Transitions to gRPC for network communication, defining service APIs in protobuf, building client and server, and adding custom error handling for robust RPC interactions. - **Late (~47%–60%)**: Focuses on security—encrypting data in-flight with TLS, authenticating clients, and authorizing access—by operating a custom Certificate Authority. - **Ending (~60%–100%)**: Covers advanced topics like service discovery, Raft consensus for replicated state machines, observability (metrics, logs, traces), CLI tools, Kubernetes deployment, and testing/benchmarking. 【Key Takeaways】 - **Go's standard library is a distributed-systems powerhouse** (Opening): encoding/json and net/http make building JSON/HTTP services straightforward, with declarative struct tags eliminating boilerplate marshaling code. - **Protobuf ensures consistent schemas across services** (Early): defining messages in .proto files with field numbers enables versioning and type checking, preventing inconsistent data models in production. - **The commit log is the heart of distributed systems** (Early): write-ahead logs (also called commit logs) provide durability and ordering, making them essential for building reliable, scalable services. - **Memory-mapped files optimize index performance** (Early): using gommap for index storage allows fast reads/writes with minimal system calls, crucial for handling high-throughput log operations. - **gRPC offers performance and scalability advantages** (Middle): built on protobuf and HTTP/2, it provides efficient serialization and long-lasting connections, reducing server costs and enabling multi-language clients. - **Security must be built in from the start** (Late): tacking on encryption, authentication, and authorization later is painful—designing them in three steps (encrypt, authenticate, authorize) is far easier. - **Custom errors improve RPC debugging** (Middle): returning structured error types with status codes and localized messages lets clients type-switch and handle failures gracefully. - **Distributed coordination requires consensus algorithms** (Ending): Raft-powered replicated state machines handle node additions/removals automatically, ensuring system reliability without manual intervention. 【Reading Tips】 - **Skim the JSON/HTTP chapter** (~6%–9%) if you're already comfortable with Go's net/http—it's foundational but straightforward; focus instead on the protobuf setup that follows. - **Deep-read the log package chapters** (~19%–34%): this is the most intricate code, covering segments, indexes, and concurrency—take time to understand the store and index implementations. - **Pay attention to the security chapter** (~47%–60%): the three-step approach (encrypt, authenticate, authorize) is a reusable pattern; the Certificate Authority setup is practical for real-world internal services. - **Use the test-driven approach**: the book includes extensive tests (e.g., TestLog, TestIndex)—run them as you code to verify each component, and use them as templates for your own projects. - **Skip ahead if you need deployment quickly**: the Kubernetes and CLI sections (~60%+) can be skimmed initially; return to them after mastering the core service logic. 【Coverage Limits】 The excerpts cover the book's opening through the security chapter (~47%), with later sections on service discovery, Raft, observability, and Kubernetes mentioned but not detailed. Deployment specifics and advanced consensus implementation are not fully covered in this guide.
Excerpt 1
ragmatic Bookshelf Raleigh, North Carolina Contents • vii 9. Discover Servers and Load Balance from the Client . . . 171 Three Load-Balancing Strategies 171...
View in text
Excerpt 2
n right followed by its name (with an additional field ID). Following the package declarations in the protobuf code, we define our Record type. Protocol buff...
View in text
Excerpt 3
func (s *segment) IsMaxed() bool { return s.store.size >= s.config.Segment.MaxStoreBytes || s.index.size >= s.config.Segment.MaxIndexBytes } IsMaxed() return...
View in text
Excerpt 4
ume(): ServeRequestsWithgRPC/internal/server/server_test.go func testConsumePastBoundary( t *testing.T, client api.LogClient, config *Config, ctx := context....
View in text
Excerpt 5
mplement authorization is with an access control list (ACL).6 An ACL is a table of rules where each row says something like “Subject A is permitted to do act...
View in text
Excerpt 6
egrate your service discovery with many platforms. You sink a lot of effort into that kind of work, and that’s likely a poor use of your time when you could...
View in text
Excerpt 7
rver Service Discovery • 136 for _, agent := range agents { err := agent.Shutdown() require.NoError(t, err) require.NoError(t, os.RemoveAll(agent.Config.Data...
View in text
Excerpt 8
n the snapshot store you configured Raft with, could be in- memory, a file, an S3 bucket—something to store the bytes in. We’re using the file snapshot store...
View in text
Tags
AI categories
GoBackendCloud Native
ISBN: 1680507605
Publisher: Pragmatic Bookshelf
Publish Year: 2021
Language: English
Pages: 206
File Format: PDF
File Size: 5.2 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…