To resolve the issue, edit the Elastic Load Balancer (ELB) stickiness to 10 minutes (600 seconds) or higher value.
- On the web console, go to Load Balancers > Target Groups.
- Select the name and go to Description section.
- Under Port Configuration, click Edit stickiness.
- Modify the value of Expiration Period to 600 seconds or higher.
According to an AWS article, "the load balancer uses a special cookie to track the instance for each request to each listener. When the load balancer receives a request, it first checks to see if this cookie is present in the request. If so, the request is sent to the instance specified in the cookie. If there is no cookie, the load balancer chooses an instance based on the existing load balancing algorithm. A cookie is inserted into the response for binding subsequent requests from the same user to that instance. The stickiness policy configuration defines a cookie expiration, which establishes the duration of validity for each cookie. The load balancer does not refresh the expiry time of the cookie and does not check whether the cookie is expired before using it. After a cookie expires, the session is no longer sticky. The client should remove the cookie from its cookie store upon expiry."
The load balancer will not route requests to an instance that failed. Instead, it will re-route the request to a new healthy instance depending on the existing load balancing algorithm. The AWS article also mentioned that "if a client switches to a listener with a different backend port, stickiness is lost."
For more information, read the full article here: Configure Sticky Sessions for Your Classic Load Balancer.