Search code examples
restload-balancingserver-configuration

Tracking requests paths to servers behind a load balancer


Suppose we have two servers A and B behind some load balancer that distributes requests between these servers somehow. What is the best practice of tracking which server processed a request? Suppose we have REST API with one endpoint GET /ping. Is it a good idea to include the host information into headers for example?


Solution

  • What we do usually, is that we configure the LB to include a header only if the client requested it. When you forge your /ping query, also add a header only known by you , like "X-Debug-Me: true". When this header is present, then either your LB or your server can insert its real hostname into whatever header you want.

    Baptiste