Track
Go for Infrastructure lessons
40 short lessons on Go for Infrastructure. Each one starts from a real situation, shows how it works, and ends with a quiz. Free to read.
All 40 lessons
- Goroutine schedulingBeginner · 4 min
Go goroutines are lightweight user-space tasks scheduled onto OS threads by the Go runtime. They are not always in one-to-one correspondence with threads. Channels…
- GMP schedulerBeginner · 4 min
Go schedules goroutines on operating system threads using runtime execution resources.
- ChannelsBeginner · 4 min
A typed channel transfers values between goroutines and can synchronize a handoff.
- Select fairnessBeginner · 4 min
A Go select chooses one ready communication; source order is not priority.
- Context cancellationBeginner · 4 min
A Go context communicates cancellation and deadlines to code that observes it.
- WaitGroupsBeginner · 4 min
A WaitGroup lets a caller wait for a set of tasks to finish.
- Mutex and RWMutexBeginner · 4 min
A mutex coordinates access to shared state; an RWMutex permits multiple readers or one writer.
- Atomic operationsBeginner · 4 min
sync/atomic performs a read-modify-write on one value as a single indivisible operation.
- Race detectorBeginner · 4 min
Go’s race detector reports certain unsynchronized accesses in code paths exercised by a run.
- Worker poolsBeginner · 4 min
A worker pool bounds concurrency with a fixed number of goroutines reading jobs from one channel.
- Bounded concurrencyBeginner · 4 min
Bounded concurrency limits how many operations are active while a separate queue holds waiting work.
- Backpressure in GoBeginner · 4 min
Explain backpressure in Go as a bounded channel or semaphore that makes fast producers wait, so queued work cannot grow memory without limit during a traffic spike.
- HTTP server timeoutsBeginner · 4 min
Explain what each net/http server timeout limits, and set them so slow or stalled clients cannot hold connections and goroutines open indefinitely on a public API.
- net/http transportBeginner · 4 min
Explain how the Go HTTP transport pools idle connections, why a per-request client causes churn, and how to size the pool and drain bodies so connections are reused.
- Connection reuseBeginner · 5 min
Explain why a client that reuses an idle connection the server already closed gets EOF errors, and set its idle timeout below the shortest limit on the path.
- DNS resolverBeginner · 5 min
Explain how the Go resolver queries the servers in resolv.conf in order, why one dead nameserver causes steps of delay, and how to test each server on its own.
- TLS clientsIntermediate · 5 min
Explain how a Go TLS client builds the certificate chain and checks the host name, and fix chain errors by correcting the server or the trust roots, not by disabling…
- Error wrappingIntermediate · 5 min
Explain how fmt.Errorf with %w builds an error chain and how errors.Is and errors.As read it, so a sentinel error still reaches the handler that picks the status code.
- Structured loggingIntermediate · 4 min
Explain why structured log fields with stable names and types can be filtered exactly, and how to keep secrets and sensitive values out of the log stream.
- Prometheus instrumentationIntermediate · 4 min
Explain why each unique label combination adds a Prometheus time series, and choose metric types, names and labels that stay bounded as the system grows.
- OpenTelemetry tracingIntermediate · 5 min
Explain spans, trace context propagation and sampling in OpenTelemetry, so the time one request spends can be followed across services, queues and background jobs, with…
- Profiling with pprofIntermediate · 5 min
Explain what CPU, heap and goroutine profiles show, how to capture them during a problem, and how to read a top list and source lines with go tool pprof.
- Memory escapesIntermediate · 4 min
Explain how escape analysis decides whether a value lives on the stack or the heap, and how to read compiler output and benchmark allocations before changing code.
- Garbage collection tuningIntermediate · 5 min
Explain how GOGC and GOMEMLIMIT set the trade-off between heap memory and garbage collection CPU, and how to leave headroom under a container memory limit.
- Graceful shutdownAdvanced · 5 min
Explain how a Go server drains on SIGTERM, so in-flight requests finish and the shutdown deadline fits inside the platform's grace period before SIGKILL arrives.
- Goroutine scheduling: failure analysisAdvanced · 4 min
Explain how parked goroutines keep their memory after they stop running, how to count and group them, and how to find the wait point that never returns.
- GMP scheduler: operational verificationAdvanced · 5 min
Explain how GOMAXPROCS caps parallel Go code, how threads and processors relate to goroutines, and why too many threads stall under a CPU quota in a container.
- Channels: failure analysisAdvanced · 5 min
Explain how sends and receives block on channels, why a nil or unowned channel hangs, and how a select with a context case lets blocked goroutines exit.
- Select fairness: operational verificationAdvanced · 5 min
Explain how select chooses among ready channels by uniform pseudo-random selection, so source order gives no priority, and how a nested select can give one channel…
- Context cancellation: failure analysisAdvanced · 4 min
Explain how a Go context cancels work, why a deadline does not stop a goroutine on its own, and how to find the calls that ignore it.
- WaitGroups: operational verificationAdvanced · 4 min
Explain how a WaitGroup counts outstanding goroutines in a fan-out job, why Add must run before Wait, and how a copied WaitGroup makes the job finish early.
- Mutex and RWMutex: failure analysisAdvanced · 4 min
Explain how Mutex and RWMutex protect shared data, why a waiting writer can deadlock a recursive read lock, and how to find lock waits in a goroutine dump.
- Atomic operations: operational verificationAdvanced · 4 min
Explain what sync/atomic guarantees for one value, why two atomic loads do not form a snapshot, and why 64-bit fields need alignment on 32-bit targets.
- Race detector: failure analysisAdvanced · 4 min
Explain what the Go race detector reports, why a clean run covers only executed code, and how to choose race builds for tests versus production.
- Worker pools: operational verificationAdvanced · 4 min
Explain how a worker pool shares a jobs channel, why the sender should close a channel, and how a done channel stops blocked sends at shutdown.
- Bounded concurrency: failure analysisAdvanced · 4 min
Explain why a goroutine for each item needs a semaphore acquired before the go statement, and how to size a limit against a shared resource.
- Backpressure in Go: operational verificationAdvanced · 4 min
Explain how a buffered channel holds queued work, why a large buffer is a hidden queue, and how blocking, dropping and rejecting handle a full buffer.
- HTTP server timeouts: failure analysisAdvanced · 4 min
Explain which net/http Server timeout covers each phase of a request, and how a missing read timeout lets slow clients hold file descriptors for long periods.
- net/http transport: operational verificationAdvanced · 4 min
Explain what Client.Timeout covers in net/http, why the default client can hang on a silent server, and how transport limits narrow down the stalled phase.
- Connection reuse: failure analysisAdvanced · 4 min
Explain why HTTP/1.1 connections are persistent by default, and how response bodies that are not closed stop connections from returning to the idle pool, so new ones…