简体   繁体   English

Apigee代理性能调整

[英]Apigee proxy performance tuning

Is there a recommended/best way to generate a report for time spent on each policy for an API proxy? 是否有建议/最佳方法来生成有关API代理的每个策略所花费时间的报告?

Currently my approach is to use JS to collect the timestamps and calculate the delay around each policy, and then report it using the stats collection policy. 当前,我的方法是使用JS收集时间戳并计算每个策略的延迟,然后使用统计信息收集策略报告该时间。

That's too invasive for performance checks and my data collection alone adds time to the overall response. 对于性能检查而言,这过于侵入性,仅我的数据收集就为整体响应增加了时间。

What would be the best no invasive way to report on the time taken for each step when analyzing the data across many requests (the ui, in the trace mode does show the time for each policy on an individual request basis) 在分析多个请求中的数据时,最好的无创方法是报告每个步骤所花费的时间(在跟踪模式下,ui会根据单个请求显示每个策略的时间)

Thanks, 谢谢,

Ricardo 里卡多

There's not a public API supported to calculate this information and return a nice, clean response of aggregated policy execution time data. 不支持公共API来计算此信息并返回汇总的策略执行时间数据的简洁明了的响应。 Best bet is to try using Analytics reports with request_processing_latency and response_processing_latency measures. 最好的选择是尝试使用具有request_processing_latencyresponse_processing_latency度量的Analytics(分析)报告。 ( http://apigee.com/docs/content/analytics-reference ). http://apigee.com/docs/content/analytics-reference )。 Then, if needed, utilize trace to identify policy execution times. 然后,如果需要,利用跟踪来识别策略执行时间。

Alternatively, you can try downloading the trace session and parsing the timestamps between policies to build your information, but trace in UI does this already.. 另外,您可以尝试下载跟踪会话并解析策略之间的时间戳以构建您的信息,但是在UI中进行跟踪已经做到了。

You consider using debug API. 您考虑使用调试API。 http://apigee.com/docs/api/debug-sessions http://apigee.com/docs/api/debug-sessions

First you'll need to start a session for example: 首先,您需要启动一个会话,例如:

curl -H "Content-type:application/octet-stream" -X POST https://api.enterprise.apigee.com/v1/organizations/{org}/environments/{env}/apis/{api_name}/revisions/{revision #}/debugsessions?"session=MySession" \\ -u $ae_username:$ae_password

Get info from session: 从会话中获取信息:

curl -X GET -H "Accept:application/json" \\ https://api.enterprise.apigee.com/v1/organizations/{org}/environments/{env}/apis/{api_name}/revisions/{revision #}/debugsessions/MySession/data \\ -u $ae_username:$ae_password

The time spent for each policy can be found using the debug trace in UI. 可以使用UI中的调试跟踪找到每个策略花费的时间。

Please see the below screenshot for the same. 请参见以下屏幕截图。

Also as Diego said you can use debugsession API call to get a debug session. 同样,正如Diego所说,您可以使用debugsession API调用来获取调试会话。

For the debug session you can also define the time limit as to how much time you want to debug session to run. 对于调试会话,您还可以定义要调试会话运行多少时间的时间限制。 With this if you are running your performance test for 1 hour you can create debug session for that much amount of time. 这样,如果您将性能测试运行1个小时,则可以在这么长的时间内创建调试会话。

     curl -v -u jhans@apigee.com               http://management:8080/v1/organizations/weatherapi/environments/prod/apis/ForeCast/revisions/6/debugsessions?session=ab\&timeout=300 -X POST

From the UI you can download the trace session which would contain an XML having the timestamp for each policy 从UI中,您可以下载跟踪会话,该会话将包含具有每个策略时间戳记的XML。

     <Point id="Condition">
      <DebugInfo>
        <Timestamp>05-02-14 04:38:14:088</Timestamp>
        <Properties>
            <Property name="ExpressionResult">true</Property>
      </Point>
     <Point id="StateChange">

The above is an example for getting timestamps for any policy in debug trace from UI. 上面是一个示例,用于从UI获取调试跟踪中任何策略的时间戳。

Ricardo, here is what I suggest. 里卡多,这是我的建议。

Disclaimer: It is very meticulous and time consuming. 免责声明:这是非常细致且耗时的。 I would recommend this approach only when you are really blocked on a performance issue and there is no other solution. 仅当您确实在性能问题上受阻且没有其他解决方案时,我才建议使用此方法。

Let us say your proxy has few policies a service callout to external service and a backend. 让我们说您的代理服务器几乎没有策略,即对外部服务的服务标注和后端。

So the total latency would be Sum of time taken by (p1, p2, p3...) + service callout target + time taken by your backend. 因此,总延迟为(p1,p2,p3 ...)花费的时间总和+服务标注目标+后端花费的时间。

  1. Very 1st step would be to stub out the external dependencies. 第一步将是消除外部依赖关系。 You can use a null target (a stub proxy on Apigee edge without any logic) to do so. 您可以使用空目标(Apigee边缘上的存根代理,无需任何逻辑)。
  2. Now disable all other policies ( enable = false on the policy schema ). 现在禁用所有其他策略(策略架构上的enable = false)。 Conduct a load test and benchmark your proxy performance against stubbed endpoints. 进行负载测试,并根据存根端点对代理性能进行基准测试。 Also at this time no policies are active. 同样,此时没有任何策略处于活动状态。
  3. Start activating the policies one by one or a few at a time, and re-run the load test each time. 一次开始一个或几个激活策略,然后每次重新运行负载测试。
  4. Finally you can run the load test against real backends (removing the stubs) 最后,您可以对真实的后端运行负载测试(删除存根)

At the end of this series of load test you will know which policy, backend is making the most significant performance impact. 在这一系列负载测试的最后,您将知道后端对哪个策略的性能影响最大。

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

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