0

We use on amazon Elastic Beanstalk with autoscaling. The autoscaling gives us 10 EC2 instances working behind a load balancer.

Now if i am right the load balancer adds a cookie "AWSELB" to forward requests to the right instance. Now I am wondering how can I find the EC2 instance processing my request from the AWSELB cookie or from anything else?

Thanks

Robin D.
  • 53
  • 1
  • 1
  • 3

1 Answers1

3

Instead of trying to dereference the AWSELB cookie, instead, have the EC2 instance tell you it's instance ID.

When your web server is processing a request:

  1. Get the instance ID from the EC2 instance metadata: http://169.254.169.254/latest/meta-data/instance-id
  2. Include the instance ID in a header returned to the client.
  3. On the client, inspect the response headers for the instance ID.

For example, you could return a header such as X-Instance-ID: i-12345678.

Matt Houser
  • 10,053
  • 1
  • 28
  • 28