Arkadiusz Kałkus
Arkadiusz Kałkus

Reputation: 18353

How can I force to connect to different server behind a load balancer?

I'm going to request some IIS web server through (for instance) WebClient for some website. IIS has two (or more) instances and load balancer decides which will be used for handling the request. Usually if the connection is established the particular server is assigned to response further requests. Is there any way to force load balancer to connect with different server? Is there any method of any class in .NET to do it or at least to determine which web server is responding?

I'm asking because I need to connect to all of the servers behind the load balancer and check downloaded content.

Upvotes: 2

Views: 4006

Answers (2)

AnthonyVO
AnthonyVO

Reputation: 3973

There are two ways.

  1. You can temporarily pause one of the servers using the Load Balancer. That works well for delivery testing or development environments. As a rule I would say that should be required when doing any delivery tests otherwise you never really know if you got both servers correct.
  2. You can use a Web Proxy to hit your web server from another location. Depending upon the Load Balancer setup your odds are 50/50 that you will get the same server or the other.

One example of a Web Proxy is: https://nordvpn.com/web-proxy/

To help in debugging I try to make a point of putting something unique on each server so that I know which one I am hitting. This might be a small clue in a page footer or something similar.

Upvotes: 0

Marcus Müller
Marcus Müller

Reputation: 36327

No, since the load balancer has to decide before your code even had a chance of being executed on the web server.

It would be pretty hazardous if an outsider could influence the choice of the load balancer; DoS attacks would be much easier.

Upvotes: 1

Related Questions