本篇讲述如何验证技术架构可行性
压测工具使用
ab工具
ab -c 20000 -n 10000000 -p msg.txt http://localhost:8081/post?xx=075500000000\&token=99029212\&Version=1.0
<span style="font-family: Arial, Helvetica, sans-serif;">Concurrency Level: 10000</span>
Time taken for tests: 151.732369 seconds Complete requests: 500000 Failed requests: 0 Write errors: 0 Total transferred: 0 bytes Total POSTed: 100014614 HTML transferred: 0 bytes Requests per second: 3295.28 [#/sec] (mean) Time per request: 3034.647 [ms] (mean) Time per request: 0.303 [ms] (mean, across all concurrent requests) Transfer rate: 0.00 [Kbytes/sec] received 643.70 kb/s sent 643.70 kb/s total
Connection Times (ms) min mean[+/-sd] median max Connect: 0 1646 3061.0 776 47149 Processing: 0 1224 1767.1 1087 67949 Waiting: 0 0 0.0 0 0 Total: 0 2870 3473.2 2039 83262 Percentage of the requests served within a certain time (ms) 50% 2039 66% 2267 75% 2746 80% 3729 90% 5061 95% 6796 98% 10853 99% 21644 100% 83262 (longest request)
jmeter工具
jmx脚本,为我自己编写。jmeter很耗内存,需要大点的内存。jemeter写报表日志,对io有很大影响,因此压测时,应该使用少量性能损耗低的报表。并发大量用户线程对主机内存,线程切换等有影响
集合点:即模拟N个用户,在同一时刻发出请求,在毫秒内发出大量的请求,以测试系统的负载能力。
无集合点:8000用户线程,2000次请求/每线程
有集合点:4000用户线程 。syntimes是4000集合点
siege工具
urls文件
http://120.24.208.132:9081/simple/services/s1 POST <msg.txt
Http地址为请求压测的地址 Post 为请求类型 msg.txt为请求报文
msg.txt
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tel="http://youdomain.com"><soapenv:Header/><soapenv:Body><tel:exchange><tel:in0>xxxx</tel:in0></tel:exchange></soapenv:Body></soapenv:Envelope>
压测命令
./siege -c 1 -r 200 -f
urls
-c 并发用户 数 -r每个用户发送的请求数 urls为上面的文件
linux性能分析基本命令
netstat命令
netstat -n|awk '/^tcp/{++S[$NF]} END {for(a in S) print a,S[a]}'
linux内核参数修改
vi /etc/sysctl.conf vi /etc/security/limits.conf * soft nofile 32768 * hard nofile 65536