背景希望选择一款Web Service性能测试工具,能真实模拟大量用户访问网站时的请求,从而获取服务器当前的请求处理能力(请求数/秒)。 以微信服务器为例,每个用户用独立的登录token,做各种操作,比如刷消息、发消息、看朋友圈等。 希望该性能测试工具符合如下要求:
性能测试工具选手:GatlingGatling是一款基于Scala 开发的高性能服务器性能测试工具,它主要用于对服务器进行负载等测试,并分析和测量服务器的各种性能指标。Gatling主要用于测量基于HTTP的服务器,比如Web应用程序,RESTful服务等,除此之外它拥有以下特点:
测试场景示例: http://gatling.io/docs/2.1.7/advanced_tutorial.html 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) } 统计图:
nGrinder官网很卡,真的很卡...zzz...
http://naver.github.io/ngrinder/ 测试场景示例: 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
Locust 是一个开源负载测试工具。使用 Python 代码定义用户行为,也可以仿真百万个用户。 测试场景示例: 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发的牢骚:
比较比较科目x工具矩阵
结论
很明显,首选的全能选手就是Gatling,Akka Actor的并发模型就是来自于并发语言的鼻祖Erlang。 转载请保留固定链接: https://linuxeye.com/Linux/2747.html |