简体   繁体   English

Web Api建议重定向呼叫,负载平衡

[英]Web Api advise on redirecting calls, load balancing

I have my Web Api application distributed on three servers using Load Balancer with Round Robin rule. 我使用带有Round Robin规则的Load Balancer在三台服务器上分发了我的Web Api application Every server can proceed only one request for specified RestApi endpoint http://MyServer/api/LongRunningProcees If second request is posted to the same Rest API endpoint when first one is not finished a server return 503 Service unavailable. 每个服务器only one request对指定的RestApi端点进行only one request http:// MyServer / api / LongRunningProcees如果在第一个请求未完成时将第二个请求发布到相同的Rest API端点,则服务器将返回503服务不可用。

I am new to load balancing and I don't find any solution how to redirect the request to another server until it will be accepted. 我是负载平衡的新手,在将请求重定向到其他服务器之前,我找不到任何解决方案。 Is this Load Balancer responsibility? 这是负载均衡器的责任吗?

If you want to use Round Robin algorithm then you have to accept that some servers will be busy while others will be waiting for requests. 如果要使用Round Robin算法,则必须接受某些服务器繁忙而其他服务器正在等待请求的情况。 This algorithm simply works in this way. 该算法仅以这种方式工作。

However, there are also other algorithms. 但是,还有其他算法。 For example Least response time which selects servers based on the response time from the servers. 例如, 最小响应时间 ,它根据来自服务器的响应时间来选择服务器。 The details depends on the used Load Balancer. 详细信息取决于使用的负载均衡器。

Besides, it seems to me that a server should not return 503 error if it is busy. 此外,在我看来,如果服务器繁忙,服务器不应返回503错误。 Instead a request should be put into some kind of queue and wait until a server is available. 而是应将请求放入某种队列中,然后等待服务器可用。 If requests are processed in a similar time and an suitable balancing algorithm is used then all server should have the similar number of requests in their queues. 如果在相似的时间处理请求,并且使用了合适的平衡算法,则所有服务器在其队列中应具有相似数量的请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM