dubbo服务压力测试

压测工具有很多,这里我介绍一种淘宝提供的一种压测工具,开发人员很方便的进行压测

1、引入pom

<dependency>
	<groupId>com.taobao</groupId>
	<artifactId>stresstester</artifactId>
	<version>1.0</version>
</dependency>

找不到依赖这里提供了一个jar
配置dubbo客户端配置文件这里就不写了
2、写个main方法就可以压测了

public static void main(String[] args) {
		ApplicationContext context = new ClassPathXmlApplicationContext(new String[] { "classpath:conf/spring.xml" });
		final PromotionCartServiceClient demoService = (PromotionCartServiceClient) context.getBean("PromotionCartServiceClient"); // 获取远程服
		StressTestUtils.testAndPrint(100, 1000000, new StressTask() {

			public Object doTask() throws Exception {
				List<String> promoIds = new ArrayList<String>();
				promoIds.add("0722d1aa9dcb4881bb6c7ad7cae76df6");
				ResultDTO<Boolean> deductionPriceResource = demoService.deductionPriceResource(promoIds, UUID.randomUUID().toString(), "1443", "951023562960");
			
				return null;
			}
		});
		System.exit(0);
	}

StressTestUtils.testAndPrint(100, 1000000, new StressTask() {…

100是并发数

1000000是请求次数

3、压测结果

 Concurrency Level:	100--并发数
 Time taken for tests:	41.175274 ms--测试耗时
 Complete Requests:	100--完成测试次数
 Failed Requests:	0--失败次数
 Requests per second:	3633.8547--QPS
 Time per request:	27.518986 ms--平均耗时
 Time per request:	0.27518988 ms (across all concurrent requests)--平均耗时,忽略并发影响
 Shortest request:	10.093374 ms--最短耗时
 Percentage of the requests served within a certain time (ms)
  50%	29.744219--50% 的耗时在0.005703毫秒以下
  66%	32.11875
  75%	33.670345
  80%	34.80021
  90%	38.767384
  95%	40.011738
  98%	40.90684
  99%	41.175274
 100%	41.175274 (longest request)--最长的耗时

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 9
    评论
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值