Go for Infrastructure
Graceful shutdown
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.
What you will be able to do
- Build a shutdown sequence with a readiness drop, a deadline and a close.
- Set the shutdown deadline below the grace period and verify it on a test instance.
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
- 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.
- 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…