Go for Infrastructure
Connection reuse
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.
What you will be able to do
- Explain the race between a client's idle timeout and the server's keep-alive timer.
- Set IdleConnTimeout below the shortest idle limit on the path, then verify with a quiet-period test.
What is in the lesson
- A real situation where this goes wrong
- How it works, step by step
- A walkthrough with commands you can run
- How it fails in production, and how to tell
- Three quiz questions with explanations
Read this lessonFree. No account needed.
More in Go for Infrastructure
- 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.
- 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.