🟢

Sticky Sessions (Session Affinity)

  • Ensures the same client is always routed to the same backend instance
  • Supported by CLB, ALB, and NLB
  • For CLB and ALB: implemented with cookies (configurable expiration time)
  • Use case: Maintain user session data without re-authentication or losing state
  • Trade-off: May cause uneven traffic distribution between instances

Cookie Types

Application-based Cookies

  1. Custom Cookie
      • Generated by target application
      • Can include any required custom attributes
      • Name must be set per target group
      • Cannot use reserved names: AWSALB, AWSALBAPP, AWSALBTG
  1. Application Cookie
      • Generated by load balancer
      • Name: AWSALBAPP

Duration-based Cookies

  • Generated by load balancer
  • Names:
    • ALB: AWSALB
    • CLB: AWSELB

Example Flow

  • Client connects → Load balancer assigns target → Cookie is set
  • On subsequent requests, LB routes the client to the same target until cookie expires