多线程并发测试(apache ad)
1.配置 ThreadPoolTaskExecutor bean

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <!-- 扫描注解 -->
<context:component-scan base-package="com.qi.quartz">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
</context:component-scan> <bean id="taskExecutor" name="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<!-- 核心线程数 线程池维护线程的最少数量 -->
<property name="corePoolSize" value="10" />
<!-- 线程池维护线程所允许的空闲时间 -->
<property name="keepAliveSeconds" value="200" />
<!-- 线程池维护线程的最大数量 -->
<property name="maxPoolSize" value="20" />
<!-- 线程池所使用的缓冲队列 -->
<property name="queueCapacity" value="100" />
<!-- 线程池对拒绝任务(无线程可用)的处理策略 ThreadPoolExecutor.CallerRunsPolicy策略 ,调用者的线程会执行该任务,如果执行器已关闭,则丢弃. -->
<property name="rejectedExecutionHandler">
<bean class="java.util.concurrent.ThreadPoolExecutor$CallerRunsPolicy" />
</property>
</bean> </beans> 2.controller使用
/**
* This file created at 2018年4月13日 下午3:06:57.
*
* Copyright (c) 2004-2014 AVTrace, Inc. All rights reserved.
*/
package com.avtrace.nlc.nms.listener;
import javax.annotation.Resource;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jms.listener.SessionAwareMessageListener;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* @author 唐芝泉
* @since 1.0.0
*/
@Controller
@RequestMapping("/test")
public class test implements SessionAwareMessageListener<Message> {
Logger LOG = LoggerFactory.getLogger(test.class);
@Resource(name = "taskExecutor")
private ThreadPoolTaskExecutor taskExecutor;
@RequestMapping("/execute")
@ResponseBody
@Override
public void onMessage(Message message, Session session) throws JMSException {
taskExecutor.execute(new Runnable(){
public void run() {
try {
LOG.info("执行线程任务开始前");
Thread.currentThread().sleep(1000);
if (LOG.isDebugEnabled()) {
LOG.info("执行线程任务结束");
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});
//设置线程的存活时间
taskExecutor.setKeepAliveSeconds(60);
}
}
3、cmd f: (因为我把ad.exe放到f:\下)


<bean id="taskExecutor"
class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="corePoolSize" value="4" /> <!-- 并发线程数,想达到真正的并发效果,最好对应CPU的线程数及核心数 -->
<property name="maxPoolSize" value="1000" /> <!-- 最大线程池容量 -->
<property name="queueCapacity" value="2000" /> <!-- 超过最大线程池容量后,允许的线程队列数 -->
</bean>
这里我是设置4并发数,最大线程池容量1000
F:\>ab -n 10000 -c 1000 http://192.168.40.21:8080/cctv/test/excute
这句命令表示10000次请求,1000个并发数 ,用时:1.206ms
比正常配置 10000*1000-4*1000=9996000
工具:链接: https://pan.baidu.com/s/1lg7BB-8OKSoluWOGjz03kw 密码: dz7i
多线程并发测试(apache ad)的更多相关文章
- Java接口多线程并发测试 (一)
本文为作者原创,禁止转载,违者必究法律责任!!! 本文为作者原创,禁止转载,违者必究法律责任!!! Java接口多线程并发测试 一,首先写一个接口post 请求代码: import org.apach ...
- Selenium & Webdriver 远程测试和多线程并发测试
Selenium & Webdriver 远程测试和多线程并发测试 Selenium Webdriver自动化测试,初学者可以使用selenium ide录制脚本,然后生成java程序导入ec ...
- Java接口多线程并发测试 (二)
原文地址http://www.cnblogs.com/yezhenhan/archive/2012/01/09/2317636.html 这是一篇很不错的文章,感谢原博主的分享! JAVA多线程实现和 ...
- 利用Testng注释实现多线程并发测试
Testng 是一款非常优秀的测试框架,真正从测试角度出发,为测试所想.在测试过程中我们经常会遇到对某一个场景做并发请求,主要想了解该程序在并发时是否会有异常或者没考虑到的其他情况,这时往往不是要做性 ...
- selenium从入门到应用 - 8,selenium+testNG实现多线程的并发测试
本系列所有代码 https://github.com/zhangting85/simpleWebtest本文将介绍一个Java+TestNG+Maven+Selenium的web自动化测试脚本环境下s ...
- apache并发测试工具ab为什么测不准
apache并发测试工具ab为什么测不准 发表于2年前(2013-03-21 12:13) 阅读(1146) | 评论(1) 1人收藏此文章, 我要收藏 赞0 3月21日 深圳 OSC 源创会正在 ...
- 利用Python多线程来测试并发漏洞
需求介绍 有时候想看看Web应用在代码或者数据库层有没有加锁,比如在一些支付.兑换类的场景,通过多线程并发访问的测试方式可以得到一个结论. 步骤 1. Burp Suite安装插件 安装一个Copy ...
- webBench&ad网站并发测试工具
webBench 测试工具使用,网站上线前压力测试工具. ad测试工具
- Apache JMeter 做接口并发测试
获知来源:查找如何使用Postman进行接口并发测试时,在StackOverflow上看到,说postman只能做串行测试,而且postman并不是被设计做这种测试的:而jmeter就是为了测试而开发 ...
随机推荐
- Android入门:Service入门介绍
一.Service介绍 Service类似于Windows中的服务,没有界面,只是在后台运行:而服务不能自己运行,而是需要调用Context.startService(Intent intent);或 ...
- kickstart2019 round_A B. Parcels
思路: 利用了曼哈顿距离和切比雪夫距离之间的转化. 参考: https://blog.csdn.net/Dylan_Frank/article/details/88985444 https://www ...
- 常用模块random,time,os,sys,序列化模块
一丶random模块 取随机数的模块 #导入random模块 import random #取随机小数: r = random.random() #取大于零且小于一之间的小数 print(r) #0. ...
- 链接文字<a>保持原有的字体颜色
<style type="text/css"> #red {color: red;} #blue {color: blue;} #orange {color: oran ...
- python decorator 用法
https://www.zhihu.com/question/31265857 http://www.cnblogs.com/huxi/archive/2011/03/01/1967600.html ...
- 知乎日报客户端应用ios源码
swift开发的知乎日报客户端详细源码,里面分UI和网络两个模块. 1.涉及到了大部分的UI控件的使用(甚至包括UIRefreshView,UITableConrol等等)2.Connection完成 ...
- IOS 隐式动画(非Root Layer)
● 每一个UIView内部都默认关联着一个CALayer,我们可用称这个Layer为Root Layer(根 层) ● 所有的非Root Layer,也就是手动创建的CALayer对象,都存在着隐式动 ...
- fiddle连接终端测试配置
第一次做app,对app的数据要进行一些数据抓包和数据分析,知道客户端发送到服务器端的过程和逻辑,通过抓包了解和分析出错,前提要先连接fiddle
- tableViewcell上放定时器
tableviewcell上的定时器: 1.创建一个管理定时器的TimerManger类, TimerManger.h #import <Foundation/Foundation.h> ...
- dojo/Deferred类和dojo/promise类的使用
参考博客:https://blog.csdn.net/blog_szhao/article/details/50220181 https://dojotoolkit.org/docume ...