如何向基于 REST 的 Web 服务器模拟数以千计的 GET 和 PUT 请求?是否有可用的工具?如果有,有哪些可用的工具?
ab - Apache HTTP server benchmarking tool http://httpd.apache.org/docs/2.0/programs/ab.html
This is a great tool for testing REST APIs.
Example:
ab -c 100 -n 100 http://service/path/to/resource
In this example:
I know its an old question however I needed a simple AJAX based Script to Test Multiple Concurrent Connections. If any of you have similar requirements then you can also use like this one for your tests.
Please take a look the this js fiddle link or See attached (whichever suits you as both points to the same javascript code)
var interval; var queue = []; var globalElapsedTime; function getUrl() { return $.trim($("#txtAjayUrl").val()); } $("#btnLaunchRequests").on("click", function () { queue = []; $("#divTimeElapsed").html("<i>calculating</i>"); globalElapsedTime = window.performance.now(); $("#divRequestStatus").show(); $("#btnLaunchRequests").prop("disabled", true); var totalRequests = 50; var inputValue = $("#txtNumberOfConcurrentRequests").val(); totalRequests = inputValue.trim(); $("#divTotalNumberOfProcessed").html(totalRequests.toString()); if (interval != null && interval != undefined) { clearInterval(interval); } interval = window.setInterval(function () { $("#divNumberOfCurrentRequests").text(queue.length); }, 500); for (let i = 1; i <= totalRequests; i++) { console.log("Loop No. " + i); if (i == totalRequests) { $.get(getUrl(), function (data) { queue.push("1"); $("#btnLaunchRequests").prop("disabled", false); $("#divNumberOfCurrentRequests").text(queue.length); //clearInterval(interval); }).always(function () { $("#btnLaunchRequests").prop("disabled", false); globalElapsedTime = window.performance.now() - globalElapsedTime; globalElapsedTime = Math.round((globalElapsedTime / 1000) * 100) / 100; console.log("%cLast Result Processed in " + globalElapsedTime + " Seconds.", "color:green"); $("#divTimeElapsed").text(globalElapsedTime + " seconds"); }); } else { $.get(getUrl(), function (data) { queue.push("1"); }); } } });
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script> <script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script> <div class="container"> <div class="row" style="padding-top:50px;"> <div class="col-sm-12"> <h3>HTTP GET Concurrent Requests Tester</h3> </div> </div> <div class="row"> <div class="col-sm-12"> <ul> <li>Sample Ajax URL for concurrent request testing: <input type="text" id="txtAjayUrl" value="http://localhost:4500/Api/Home/GetCustomerDetails/36603/Test" style="width:100%"> <br><br> </li> <li><input type="number" value="50" id="txtNumberOfConcurrentRequests"> <input type="button" value="Launch Concurrent Requests" id="btnLaunchRequests"> <br></li> </ul> </div> </div> <div class="row" id="divRequestStatus" style=""> <div class="col-sm-12"> <table class="table table-bordered"> <thead> <tr> <th> Total Number of Requests </th> <th> Total Number of Requests Processed </th> <th> Total Time Elapsed </th> </tr> </thead> <tbody> <tr> <td> <div id="divTotalNumberOfProcessed"></div> </td> <td> <div id="divNumberOfCurrentRequests" style="font-weight: bolder;"></div> </td> <td> <div id="divTimeElapsed"></div> </td> </tr> </tbody> </table> </div> </div> </div>
试试jmeter,有第三方REST插件: http : //smartrics.blogspot.co.uk/2009/04/jmeter-to-test-robustness-of-system.html
几乎任何 HTTP 性能测试工具,无论是商业的还是开源的,都可用于对 REST 接口进行性能测试。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.