但愿选择一款Web Service性能测试工具,能真实模拟大量用户访问网站时的请求,从而获取服务器当前的请求处理能力(请求数/秒)。 以微信服务器为例,每一个用户用独立的登陆token,作各类操做,好比刷消息、发消息、看朋友圈等。css
但愿该性能测试工具符合以下要求:html
http://gatling.io/python
Gatling是一款基于Scala 开发的高性能服务器性能测试工具,它主要用于对服务器进行负载等测试,并分析和测量服务器的各类性能指标。Gatling主要用于测量基于HTTP的服务器,好比Web应用程序,RESTful服务等,除此以外它拥有如下特色:git
测试场景示例: http://gatling.io/docs/2.1.7/advanced_tutorial.htmlgithub
object Search { val feeder = csv("search.csv").random // 1, 2 val search = exec(http("Home") .get("/")) .pause(1) .feed(feeder) // 3 .exec(http("Search") .get("/computers?f=${searchCriterion}") // 4 .check(css("a:contains('${searchComputerName}')", "href").saveAs("computerURL"))) // 5 .pause(1) .exec(http("Select") .get("${computerURL}")) // 6 .pause(1) }
统计图: web
官网很卡,真的很卡...zzz...编程
http://naver.github.io/ngrinder/
nGrinder是一个基于 Grinder 开发的一个很是易于管理和使用的性能测试系统。
它是由一个controller和链接它的多个agent组成,用户能够经过web界面管理和控制测试,以及查看测试报告,controller会把测试分发到一个或多个agent去执行。用户能够设置使用多个进程和线程来并发的执行该脚本,并且在同一线程中,来重复不断的执行测试脚本,来模拟不少并发用户。
nGrinder的测试是基于一个python的测试脚本,用户按照必定规则编写测试脚本之后,controller会将脚本以及须要的其余文件分发到agent,用Jython执行。并在执行过程当中收集运行状况、响应时间、测试目标服务器的运行状况等。并保存这些数据生成运行报告,以供之后查看。
nGrinder的一大特色就是很是容易使用,安装也很是容易,能够作到开箱即用,测试用户也能够很容易就开始测试任务。固然,若是想执行一些比较复杂场景的性能测试,就须要测试人员对python有必定认识。浏览器
测试场景示例: http://grinder.sourceforge.net/faq.html#simulating-users服务器
# # testRandomise.py # import random import string class TestRandomise: def __init__(self, filename): self._users = [] infile = open(filename, "r") for line in infile.readlines(): self._users.append(string.split((line),',')) infile.close() def getUserInfo(self): "Pick a random (user, password) from the list." return random.choice(self._users) # # Test script. Originally recorded by the TCPProxy. # from testRandomise import TestRandomise tre = TestRandomise("users.txt") class TestRunner: def __call__(self): # Get user for this run. (user, passwd) = tre.getUserInfo() # ... # Use the user details to log in. tests[2002].POST('https://host:443/securityservlet', ( NVPair('functionname', 'Login'), NVPair('pagename', 'Login'), NVPair('ms_emailAddress', user), NVPair('ms_password', passwd), ))
统计图: 微信
Locust 是一个开源负载测试工具。使用 Python 代码定义用户行为,也能够仿真百万个用户。
Locust 是很是简单易用,分布式,用户负载测试工具。Locust 主要为网站或者其余系统进行负载测试,能测试出一个系统能够并发处理多少用户。
Locust 是彻底基于时间的,所以单个机器支持几千个并发用户。相比其余许多事件驱动的应用,Locust 不使用回调,而是使用轻量级的处理方式 gevent。
测试场景示例: http://docs.locust.io/en/latest/quickstart.html#example-locustfile-py
from locust import HttpLocust, TaskSet def login(l): l.client.post("/login", {"username":"ellen_key", "password":"education"}) def index(l): l.client.get("/") def profile(l): l.client.get("/profile") class UserBehavior(TaskSet): tasks = {index:2, profile:1} def on_start(self): login(self) class WebsiteUser(HttpLocust): task_set = UserBehavior min_wait=5000 max_wait=9000
统计图:
由于没有脚本能力或CLI,因此未加入比较
Locust做者对JMeter和Tsung发的牢骚:
http://my.oschina.net/u/1433482/blog/464092#OSC_h4_3
咱们研究了现有的解决方案,都不符合要求。好比Apache JMeter和Tsung。
JMeter基于UI操做,容易上手,但基本上不具有编程能力。其次JMeter基于线程,要模拟数千用户几乎不可能。
Tsung基于Erlang,能模拟上千用户并易于扩展,但它基于XML的DSL,描述场景能力弱,且须要大量的数据处理才知道测试结果。
| 比较科目 | Gatling | nGrinder | Locust | | -------- | ----- | ---- | | 并发机制 | Akka Actor | Java线程 | Python gevent| | 单结点并发数量 | 待实验 | 待实验(官网数字:3000) | 待实验 | | 分布式支持 | N | agent-controller | master-slave | | 录制脚本 | Http Proxy | TCProxy | N | | 测试脚本DSL | scala dsl | Jython/Groovy | Python | | Session支持 | Y | Y | Y | | CLI启动测试 | gatling.sh | Y | N (须要在浏览器中点击启动测试) | | 性能测试结果统计 | Y | Y | Y | | 监控被测试服务器 | N | Y | N | | 每一个实例不一样参数 | ★★★★★ 参数文件 | ★★★☆☆ 资源文件和线程Id | ★★☆☆☆ 变通办法:每一个并发实例依次从参数文件中读取 |
很明显,首选的全能选手就是Gatling,Akka Actor的并发模型就是来自于并发语言的鼻祖Erlang。
若是想本身扩展性能测试工具,那么Locust这个小而精的工具能够考虑。
nGrinder工具是韩国版微信Line开源的,而且专门开设了中文论坛,由韩国工程师回答中国开发者。但有两个问题,一是官网太卡,其二示例都是片断不完整。
各位同窗参照上面的对比,本身各取所需吧。