简体   繁体   English

如何使用多请求有效测试静态API。

[英]how to Test Restful API Efficiently with Multi Requests .

We have about 50 Restful JSON APIs Between An Android app and PHP backend. 在Android应用程序和PHP后端之间,我们大约有50个Restful JSON API。 WE have Problems Related To The Restful APIs. 我们有与Restful API相关的问题。 The problems Can be Categorized into 3 types . 问题可以分为3类。

1- API Response sometimes Very Slow 1- API响应有时非常慢

2- API Response Sometimes not Stable and Response back With Error. 2- API响应有时不稳定,响应返回错误。

3- API Does not Work After Doing Multiply Requests. 3-进行乘法请求后,API不起作用。

WE have tried Postman For Testing and it seems that Everything Works without any problem. 我们尝试了邮递员测试,似乎一切正常,没有任何问题。 but once we try The API on The Runtime through The Android Application the 3 types of problems starts to appear. 但是一旦我们尝试通过Android应用程序在运行时上使用API​​,就会开始出现3种类型的问题。 we are hosting on Azure Cloud Servers. 我们托管在Azure云服务器上。

We are not Sure what Exactly causing the issue. 我们不确定是什么导致了问题。 we are doing "Header Allow Access Control" in Each API class and we still having an issue . 我们正在每个API类中执行“标头允许访问控制”,但仍然存在问题。 any recommendations? 有什么建议吗?

Thanks , 谢谢 ,

Per your description: 根据您的描述:

WE have tried Postman For Testing and it seems that Everything Works without any problem. 我们尝试了邮递员测试,似乎一切正常,没有任何问题。

I think you need to pay more attention on the client side, and the data type during transmission. 我认为您需要在客户端以及传输过程中的数据类型上多加注意。

1, check whether the response is the standard Json object which can be parsed and serialized on client app 1,检查响应是否是可以在客户端应用上解析和序列化的标准Json对象

2, check whether the client has called the rest APIs in correct format and correct parameter settings 2,检查客户端是否以正确的格式和正确的参数设置调用了其余的API

3, check the workflow of the mulit requests 3,检查多个请求的工作流程

If your backend service is hosted on Azure Web apps, you need to set always on as on. 如果您的后端服务托管在Azure Web应用程序上,则需要始终设置为“开启”。 Because Azure will unload your site if it is idle for a period of timeout, which can cause slow response for the initial request. 因为如果Azure在一段时间内处于空闲状态,它将卸载您的网站,这可能导致对初始请求的响应变慢。

Respectively, you can log the time of getting requests and sending response on server side, and log this metric on client side. 您可以分别在服务器端记录获取请求和发送响应的时间,并在客户端记录该指标。 Compare these logs to confirm the issue. 比较这些日志以确认问题。

BTW, if the issue shows up when you have a heave traffic requests. 顺便说一句,如果您有沉重的交通请求时问题出现了。 You can try to scale up your instance. 您可以尝试扩展实例。

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

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