Production-ready Go
summary
Go's net/http defaults are dangerous: the package-level HTTP client lacks a timeout (though Transport sometimes times out) and ListenAndServe omits server timeouts, so untrusted slow clients can exhaust file descriptors; a local demo shows 1.2M requests in 60s at 20k/s and 195µs avg but a ulimit=20 test with a 10bps slow client fills descriptors. Fixes are minimal: set ReadTimeout/WriteTimeout/IdleTimeout on http.Server, handle SIGINT and SIGTERM via signal.Notify, and propagate cancellation with request.Context().Done().
AI-written summary · about
chapters (16)
- 0:00Intro
- 2:15Seriously bad code
- 2:28Productionready Go
- 2:58Things I wont be talking about
- 3:20Easy
- 4:40Mistakes
- 5:58Client timeouts
- 6:27HTTP timeouts
- 10:22HTTP server demo
- 15:18HTTP server tips
- 18:18Operating system signals
- 19:21OS signals overview
- 21:43Sigmapipe overview
- 26:40Cancellation overview
- 27:48Cancellation in Go
- 32:37Recap
related talks
47mUsing Go in DevOps
06mHow Not to DDOS Servers
37mBest Practices for Cloud-Native Go Services
29mBest Practices for Production Environments
33mThe Gotchas of Zero-Downtime Traffic /w Kubernetes
01h 00mOptimizing your HttpClient usage
43mUsage of Go in VK's Infrastructure Tasks
21mMaking Docker GO: Why One of the Fastest Growing Open Source Projects
