简体   繁体   English

测试Java Web服务针对多个并发请求的行为

[英]Test the behavior of a java web service for multiple concurrent requests

How do I test the behavior of a java restful web service in case of multiple concurrent requests? 在有多个并发请求的情况下,如何测试Java Restful Web服务的行为? Is there any 3rd party tool that can be leveraged? 有没有可以利用的第三方工具?

The service accepts POST method. 该服务接受POST方法。 It expects a couple of parameters in it's request body and produces the response in the form of JSON. 它在请求主体中需要几个参数,并以JSON的形式生成响应。

The functionality of the service is to perform database read operations using the request body parameters and populate the fetched data in the JSON. 该服务的功能是使用请求主体参数执行数据库读取操作,并在JSON中填充获取的数据。

I would recommend one of the following: 我建议以下之一:

  1. SoapUI - superior tool for web service testing. SoapUI-用于Web服务测试的高级工具。 Has limited load testing capabilities . 具有有限的负载测试功能 However it does not scale (no clustered mode is available) and has quite poor reporting (all you get is average, min and max response times) 但是,它无法扩展(没有可用的群集模式)并且报告效果很差(您得到的只是平均,最小和最大响应时间)
  2. Apache JMeter - multiprotocol load testing tool, supports web services load testing as well. Apache JMeter-多协议负载测试工具,也支持Web服务负载测试。 Has better load capabilities and ways to define the load patterns and can represent load test results via HTML Reporting Dashboard . 具有更好的加载功能和定义加载模式的方式,并且可以通过HTML Reporting Dashboard表示加载测试结果。 Check out Testing SOAP/REST Web Services Using JMeter article to learn how to conduct a web service load test using JMeter. 查看使用JMeter测试SOAP / REST Web服务的文章,了解如何使用JMeter进行Web服务负载测试。

You can try Gatling to generate some load. 您可以尝试加特林来生成一些负载。

It has nice documentation and easy QuickStart . 它具有很好的文档和简单的QuickStart

For advanced usage it requires some knowledge of Scala, but it also features GUI tool for simple scenarios recording, so you can run some scripts by postman or whatever browser tool you use for debugging, record it and make that scenario automated. 对于高级用法,它需要一些Scala知识,但它还具有用于简单场景记录的GUI工具,因此您可以通过邮递员或用于调试的任何浏览器工具运行一些脚本,将其记录下来并使该场景自动化。

After running scenarios it generates nice reports using Graphite, so you can see response times and general stats. 运行场景后,它会使用Graphite生成漂亮的报告,因此您可以查看响应时间和常规统计信息。

Later you can also use Gatling for load and performance tests of your web service, it's convenient and fast as soon as you start playing with it. 以后,您还可以使用Gatling对Web服务进行负载和性能测试,一旦开始使用它,它既方便又快速。 It can easily generate up to 5k requests per second from my old Mac, or hold up to 1k connections. 它可以轻松地从我的旧Mac每秒每秒生成多达5k个请求,或保持多达1k个连接。

One of the bests tools to test web services is SOAPUI. SOAPUI是测试Web服务的最佳工具之一。

You can use it for what you want. 您可以根据需要使用它。

Link to SOAPUI 链接到SOAPUI

You can check this link to see how to use SOAPUI and concurrent tests. 您可以检查此链接以查看如何使用SOAPUI和并发测试。

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

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