Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to carry out java concurrent Simulation

Shulou Source: shulou.com Published: 2022-06-02 02:39:11 10月26日 Update

How to carry out java concurrent simulation, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

Create a new controller,TestController.java in project-1 as follows:

@ RestController@Slf4jpublic class TestController {@ GetMapping ("/ test") public String test () {return "test";}}

You need to rely on the Slf4j package, and you need to add dependencies in the pom.xml file:

Org.projectlombok lombok 1.18.6 POSTMAN tool Test

Create a new collection in the postman tool:

Add the test url to the collection, click run, and then configure:

Apache bench tool

Download address: https://www.apachelounge.com/download/

Ab-n 1000-c 50 http://localhost:8080/test

The output is as follows:

C:\ Users\ vincent > ab-n 1000-c 50 http://localhost:8080/testThis is ApacheBench, Version 2.3 Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/Licensed to The Apache Software Foundation Http://www.apache.org/Benchmarking localhost (be patient) Completed 100 requestsCompleted 200 requestsCompleted 300 requestsCompleted 400 requestsCompleted 500 requestsCompleted 600 requestsCompleted 700 requestsCompleted 800 requestsCompleted 900 requestsCompleted 1000 requestsFinished 1000 requestsServer Software:Server Hostname: localhostServer Port: 8080Document Path: / testDocument Length: 4 bytesConcurrency Level: 50Time taken for tests: 0.673 secondsComplete requests: 1000Failed requests: 0Total transferred: 136000 bytesHTML transferred: 4000 bytesRequests per second: 1486.74 [# / sec] (mean) Time per request: 33.631 [ms] (mean) Time per request: 0.673 [ms] (mean Across all concurrent requests) Transfer rate: 197.46 [Kbytes/sec] receivedConnection Times (ms) min mean [+ /-sd] median maxConnect: 0 00.30 1Processing: 1 1919.8 15 291Waiting: 0 1616.7 12 278Total: 1 20 19.8 15 292Percentage of the requests served within a certain Time (ms) 50% 15 66% 19 75% 23 80% 24 90% 33 95% 62 98% 84 99% 99% 292 (longest request)

-n 1000 indicates that the total number of tests is 100.

-c 50 indicates that the number of concurrency of this request is 50

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Tags: Tools tests content Zhongxin help clarity address for this tool downloads totals documents articles novices more knowledge results industry information information channels puzzles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi MariaDB Linux Xiaomi Apple