java高并发(五)并发模拟

在project-1中新建controller,TestController.java内容如下:

@RestController
@Slf4j
public class TestController {

    @GetMapping("/test")
    public String test() {
        return "test";
    }

}

需要依赖Slf4j包,需要在pom.xml文件中添加依赖:

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.6</version>
        </dependency>

POSTMAN工具测试

在postman工具中新建collection:

并将测试url添加到这个collection中,点击run,然后配置:

1bd0d261684ea1b60f2a6382cd4e30dc452.jpg

Apache bench工具

下载地址:https://www.apachelounge.com/download/

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

输出结果如下:

C:\Users\vincent>ab -n 1000 -c 50 http://localhost:8080/test
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
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 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:
Server Hostname:        localhost
Server Port:            8080

Document Path:          /test
Document Length:        4 bytes

Concurrency Level:      50
Time taken for tests:   0.673 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      136000 bytes
HTML transferred:       4000 bytes
Requests 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] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.3      0       1
Processing:     1   19  19.8     15     291
Waiting:        0   16  16.7     12     278
Total:          1   20  19.8     15     292

Percentage 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
 100%    292 (longest request)

-n 1000表示本次测试的总数为100个

-c 50表示本次请求的并发数是50

转载于:https://my.oschina.net/duanvincent/blog/3077439

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值