Azure api management Azure API管理中模拟的操作性能
我有一个Azure API管理API,它只包含模拟操作。大多数,如所附图像的底部,运行时间为十分之一毫秒。然而,一个是test/plain并返回application/json的,通常运行时间为数十秒(图像顶部)。我发现这是使用开发者控制台或从逻辑应用程序调用。我的案例有1.7K,返回的JSON很大,为26K 不过,这么长的响应时间似乎太长了。有什么解释吗 mock返回的我的表示示例Azure api management Azure API管理中模拟的操作性能,azure-api-management,Azure Api Management,我有一个Azure API管理API,它只包含模拟操作。大多数,如所附图像的底部,运行时间为十分之一毫秒。然而,一个是test/plain并返回application/json的,通常运行时间为数十秒(图像顶部)。我发现这是使用开发者控制台或从逻辑应用程序调用。我的案例有1.7K,返回的JSON很大,为26K 不过,这么长的响应时间似乎太长了。有什么解释吗 mock返回的我的表示示例 { "FunctionalGroup": { "TransactionSet": { "
{
"FunctionalGroup": {
"TransactionSet": {
"@controlNumber": "270001",
"Area": [
{
"Segment": [
{
"@id": "BEG",
"Element": [
{
"@pos": "1",
"#text": "00"
},
{
"@pos": "2",
"#text": "SA"
},
{
"@pos": "3",
"#text": "86816853"
},
{
"@pos": "5",
"@date": "2015-04-09",
"#text": "20150409"
}
]
},
{
"@id": "REF",
"Element": [
{
"@pos": "1",
"#text": "DP"
},
{
"@pos": "2",
"#text": "16"
},
{
"@pos": "3",
"#text": "DEPARTMENTA"
}
]
}
],
"SegmentLoop": [
{
"@id": "N9",
"@name": "N9",
"Segment": [
{
"@id": "N9",
"Element": [
{
"@pos": "1",
"#text": "ST"
},
{
"@pos": "2",
"#text": "001"
}
]
},
{
"@id": "DTM",
"Element": [
{
"@pos": "1",
"#text": "010"
},
{
"@pos": "2",
"@date": "2015-04-12",
"#text": "20150412"
},
{
"@pos": "3",
"@time": "00:00:00",
"#text": "0000"
}
]
},
{
"@id": "DTM",
"Element": [
{
"@pos": "1",
"#text": "002"
},
{
"@pos": "2",
"@date": "2015-04-12",
"#text": "20150412"
},
{
"@pos": "3",
"@time": "12:34:34",
"#text": "123456"
}
]
},
{
"@id": "DTM",
"Element": [
{
"@pos": "1",
"#text": "001"
},
{
"@pos": "2",
"@date": "2015-04-30",
"#text": "20150430"
},
{
"@pos": "3",
"@time": "12:34:34.789",
"#text": "123456789"
}
]
}
]
},
{
"@id": "N1",
"@name": "N1",
"Segment": [
{
"@id": "N1",
"Element": [
{
"@pos": "1",
"#text": "ST"
},
{
"@pos": "2",
"#text": "COMPANY INC."
},
{
"@pos": "3",
"#text": "92"
},
{
"@pos": "4",
"#text": "001"
}
]
},
{
"@id": "N3",
"Element": [
{
"@pos": "1",
"#text": "123 main street"
},
{
"@pos": "2",
"#text": "PH:(644)123-4567"
}
]
},
{
"@id": "N4",
"Element": [
{
"@pos": "1",
"#text": "Elk Grove Village"
},
{
"@pos": "2",
"#text": "IL"
},
{
"@pos": "3",
"#text": "6007"
},
{
"@pos": "4",
"#text": "US"
}
]
}
]
},
{
"@id": "N1",
"@name": "N1",
"Segment": [
{
"@id": "N1",
"Element": [
{
"@pos": "1",
"#text": "SF"
},
{
"@pos": "2",
"#text": "EDGE ENTERPRISES"
},
{
"@pos": "3",
"#text": "92"
},
{
"@pos": "4",
"#text": "99999"
}
]
},
{
"@id": "N3",
"Element": [
{
"@pos": "1",
"#text": "2645 W. Coast Highway"
}
]
},
{
"@id": "N4",
"Element": [
{
"@pos": "1",
"#text": "Silicon Valley"
},
{
"@pos": "2",
"#text": "CA"
},
{
"@pos": "3",
"#text": "56874"
},
{
"@pos": "4",
"#text": "US"
}
]
}
]
}
]
},
{
"SegmentLoop": [
{
"@id": "PO1",
"@name": "PO1",
"Segment": [
{
"@id": "PO1",
"Element": [
{
"@pos": "1",
"#text": "1"
},
{
"@pos": "2",
"#text": "96"
},
{
"@pos": "3",
"#text": "EA"
},
{
"@pos": "4",
"#text": "2.05"
},
{
"@pos": "6",
"#text": "BP"
},
{
"@pos": "7",
"#text": "HB-Natural Adult Bat"
}
]
}
],
"SegmentLoop": [
{
"@id": "PID",
"@name": "PID",
"Segment": [
{
"@id": "PID",
"Element": [
{
"@pos": "1",
"#text": "F"
},
{
"@pos": "5",
"#text": "DESCRIPTION"
}
]
}
]
}
]
}
]
},
{
"SegmentLoop": [
{
"@id": "CTT",
"@name": "CTT",
"Segment": [
{
"@id": "CTT",
"Element": [
{
"@pos": "1",
"#text": "6"
}
]
},
{
"@id": "AMT",
"Element": [
{
"@pos": "1",
"#text": "TT"
},
{
"@pos": "2",
"@number": "1000.00",
"#text": "100000"
}
]
}
]
}
]
}
]
}
}
}
我的政策对相关API op有效
<policies>
<inbound>
<!--base: Begin Global scope-->
<!-- PC-1404 -->
<set-query-parameter name="subscription-key" exists-action="delete" />
<!--base: End Global scope-->
</inbound>
<backend>
<!--base: Begin Global scope-->
<forward-request />
<!--base: End Global scope-->
</backend>
<outbound>
<mock-response status-code="200" content-type="application/json" />
</outbound>
<on-error>
<!--base: Begin Global scope-->
<!-- By placing policy statements in the on-error section you can review the error by
using the context.LastError property, inspect and customize the error response using the
set-body policy, and configure what happens if an error occurs.
There are error codes for built-in steps and for errors that may occur during the processing of
policy statements.
For more information, see https://msdn.microsoft.com/en-us/library/azure/mt629506.aspx
statements to be applied if there is an error condition go here -->
<!-- for CORS support to Office Add-In to detect subscription key errors, etc. PLEX-JIRA: PC-725 TSCH 8/16/16 -->
<set-header name="Access-Control-Allow-Origin" exists-action="override">
<value>*</value>
</set-header>
<!--base: End Global scope-->
</on-error>
*
我发现我需要将模拟呼叫移动到入站部分。这是从前端到后端(实际上我没有一个后端需要花费时间)。新的op政策是
<policies>
<inbound>
<mock-response status-code="200" content-type="application/json" />
<base />
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
</outbound>
<on-error>
<base />
</on-error>
此外,模拟op无论是第一个都需要几秒钟,我已经先尝试了多个不同的模拟op,每个模拟op都是ms的十分之一,无论它是不是第一个。我确信这是针对这个模拟OPI的。如果您在门户中运行这个请求,您会看到同样的慢速度吗?跟踪是否给出了延迟来自何处的任何提示?此外,如果将模拟响应策略移动到入站部分,性能是否会提高?Hi@Darreller是的,我在门户中看到了相同的延迟,这允许我排除逻辑应用程序。那里的跟踪确实显示了后端部分的延迟(我喜欢devportal控制台中的跟踪如何有到每个部分的链接),因此提示我将模拟策略移动到入站部分,从而解决了延迟问题。(我在这里错过了您的评论,或者在您的评论之前添加了这个作为我的回答?无论如何,我直到今天早上才检查我的堆栈溢出收件箱…)我将询问团队,为什么您可能希望将其放在入站之外的任何地方。如果没有任何原因,我们应该更新文档。谢谢,@DarrelMiller-如果不仅仅是文档,还有用户界面。UI在放置不当时会抱怨其他策略元素。我们确实明确允许在其他位置使用它。我只是不知道我们为什么这么做。