压测逻辑实现
  压测工具采用Groovy来进行编写。对每个应用来说,只需要实现runner接口可以实现对应用的打压。
  interface Runner {
  def init(Test app)
  def run(Test app, String log)
  def destroy(Test app)
  }
  以Thrift服务为例:
class TestServiceRunner implements Runner {
RPCService.Client _client
TTransport _transport;
@Override
def init(Test app) {
def conf = app.config // 读取应用配置
_transport = new TFramedTransport(new TSocket(conf.get("thrift_service_host") as String, conf.get("thrift_service_port") as int))
TProtocol protocol = new TBinaryProtocol(_transport)
_client = new RPCService.Client(protocol)
_transport.open()
}
@Override
def run(Test app, String log) {
TestRequest req = Vcr.deSerialize(log, TestRequest.class) // 将拷贝流量反序列化
_client.echo(req) // 发送请求
}
@Override
def destroy(Test app) {
_transport.close() // 关闭服务
}
}
  创建应用
  实现以上接口后,可以对应用进行打压了。
  用户可以通过Web界面创建应用,除了必填配置以外,用户可以按照应用灵活配置。

  性能指标
  用户可以通过直观的图表来查看应用的各种性能指标。

  结束语
  压测工具上线以来,已经接入了20多个应用,完成数百次打压实验,现在应用的接入时间仅需要15~30分钟。保证了美团服务的稳定和节省了开发同学的时间,使大家告别了以往繁琐冗长的打压测试。
  欢迎对这方面有兴趣的同学一起讨论。