InterviewHubPRO
Section Overview
Q12

Question 12 of 65

Part 2: Networking, VPC & Traffic Routing (6 - 20)

18%
AWS Cloud Architecture•Part 2: Networking, VPC & Traffic Routing (6 - 20)

ALB target health checks and Connection Draining (Deregistration Delay).

In Simple Words: When an EC2 or container is de-registered or updated, connection draining keeps active in-flight requests alive for a configured time (e.g., 300 seconds) while stopping new requests from reaching it. This guarantees zero dropped requests during rolling deployments.

hcl
resource "aws_lb_target_group" "app_tg" {
  name                 = "app-target-group"
  port                 = 80
  protocol             = "HTTP"
  vpc_id               = aws_vpc.main.id
  deregistration_delay = 30 # Connection draining timeout in seconds

  health_check {
    path                = "/health"
    healthy_threshold   = 2
    unhealthy_threshold = 3
    timeout             = 5
    interval            = 15
  }
}