Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to carry out java concurrent Simulation

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report