您如何使用Azure API管理策略来负载均衡对后端服务的调用? [英] How can you use Azure API Management policy to load balance calls to a backend service?

查看:107
本文介绍了您如何使用Azure API管理策略来负载均衡对后端服务的调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用策略来平衡对一对后端服务的呼叫负载? (在这种情况下,是在不同区域的一对Logic App)

How can you use policy to load balance calls to a pair of backend services? (in this case a pair of Logic Apps in different regions)

我已阅读 API管理策略并可以在

I've read through the API Management policies and can see something around the control flow but I can't work out how to (a) test the back-end service is available, and then (b) change the call to the backup service if the primary is unavailable

<backend>  
     <forward-request/>  
</backend> 

推荐答案

实现此目标的另一种方法可能是您可以使用

One more way to achieve this could be that you can use the retry policy with set backend service or send-request

类似

<backend>
    <retry condition="@(context.Response.StatusCode == 400 || context.Response.StatusCode >= 500)" count="10" interval="10" max-interval="100" delta="10" first-fast-retry="false">
        <choose>
            <when condition="@(context.Response != null && (context.Response.StatusCode == 400 || context.Response.StatusCode >= 500)">
                <set-backend-service base-url="http://echoapibackup.cloudapp.net/api" />
            </when>
            <otherwise>
                <set-backend-service base-url="http://echoapi.cloudapp.net/api" />
            </otherwise>
        </choose>
        <forward-request />
    </retry>
</backend>

如果您的主后端返回错误,则会继续在您的备份后端上重试.

This will in case your primary backend returns an error, will keep retrying on your backup backend.

这篇关于您如何使用Azure API管理策略来负载均衡对后端服务的调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆