connection draining
Stopping new traffic to a backend while letting its existing connections finish, before removing or restarting it.
In more detail
It avoids cutting users off mid-request during deployments, restarts and maintenance. Load balancers and orchestrators usually allow only a limited time for draining before closing any connections that remain.
Examples
In AWS: Letting a server finish the requests it already has, while sending it no new ones, before it is stopped or removed.Skipping the drain during a deploy shows up as 502 Bad Gateway errors.Related terms
- load balancer — A server that spreads incoming requests across several copies of a service so no single copy is overloaded.
- Auto Scaling group — An EC2 feature that keeps a desired number of identical instances running, replacing failed ones and adding or removing them as load changes.
- horizontal scaling — Handling more load by running more copies of a process, often on more machines, rather than making one machine bigger.
- graceful shutdown — Stopping a service in an orderly way: finish current work, close connections, then exit.
- load balancing — Spreading requests or connections across several backend servers so no single one is overloaded and failed ones can be avoided.
- SIGTERM — The signal that politely asks a process to finish its work and exit.
- readiness probe — A check that decides whether a pod should receive traffic right now; failing it removes the pod from its Service without restarting it.
- backend pool — The set of servers a load balancer can send traffic to, each marked eligible or not by health checks.
- in-flight request — A request that has been received but not yet fully answered.
- server.close() — The method that stops a Node.js server accepting new connections and calls back once every existing connection has ended.
Taught in
- Elasticity and Scale — Cloud Infrastructure & Hyperscaler Architecture
- Auto Scaling Groups — Cloud Infrastructure & Hyperscaler Architecture
- Disposability, Dev Prod Parity And Logs — DevOps & Site Reliability Engineering
- Health Probes & Graceful Shutdown: Kubernetes Lifecycles — Production Full-Stack Engineering
- Load Balancing: Algorithms, Health Checks And Layers — Linux Fundamentals & Systems Administration
- Cluster Architecture: node:cluster & Zero-Downtime — Node.js Internals & Backend Services
- Production Hardening: Graceful Shutdown & Docker — Node.js Internals & Backend Services