Skip to content

Architecture question - load balancer installed on all WEB API instances, but enabled only for one #2274

Answered by Tratcher
SorinMiron asked this question in Q&A
Discussion options

You must be logged in to vote

In theory, yes, but not with the built in load balancer, only with the IHttpForwarder.

Say you want WebApi1 to handle 50% of traffic at endpoint "/location" and forward the other 50%. At the start of that endpoint you add code to check if load balancing is enabled for this instance. If it is, decide if this request should be forwarded. If so, call IHttpForwarder, otherwise let the endpoint run as usual.

This only makes sense if the endpoint logic is significantly more expensive than the forwarding logic. Otherwise WebApi1 is doing twice as much work just to forward half of the requests. For truly balanced load you'd need a 3rd instance that only forwards to 1 or 2.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@SorinMiron
Comment options

Answer selected by SorinMiron
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants