是否可以使用jmeter测试grpc [英] is it possible to use jmeter to test grpc

查看:1363
本文介绍了是否可以使用jmeter测试grpc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想知道是否有人尝试使用jmeter测试gRPC应用程序.

Was wondering if anybody has tried to use jmeter to test gRPC application.

我希望

  • 我可以编写一个具有非阻塞/异步存根的gRPC客户端类,该存根对服务器进行非阻塞调用
  • 为上述客户端创建一个罐子
  • 将罐子导入JMeter
  • 在Jmeter BeanShell采样器中使用Java方法

在投入时间尝试上述方法之前,我想看看是否有人尝试过类似的方法并且

before investing time in trying the above I wanted to see if any body has tried something similar and

  • 如果上述解决方法可行?
  • 每个线程都会创建一个单独的TCP连接吗?

我们已经尝试使用python客户端和locust.io进行负载测试,但是python gRPC不兼容gevent,甚至不支持异步调用,例如stub.GetFeature.future,我们正在达到每个进程每秒请求的限制(异步调用似乎不是异步的,GIL瓶颈,一旦TCP流)

We have tried the load test with python client and locust.io but python gRPC is not gevent compatible and even with async call e.g. stub.GetFeature.future, we are hitting a limit on the request per second per process (async call doesn't seem to be async, GIL bottleneck, once TCP stream)

推荐答案

如果上述解决方法可行?

if above workaround work?

您的解决方案将起作用.但是,如果您长期需要它,我建议您不要使用客户端类并使用BeanShell采样器,而要实现

Your solution will work. But if you need it long term, I would recommend, rather than having client class and using BeanShell sampler, implementing custom Java Sampler. It's very practical, since work-wise it will be similar/same as implementing custom client + BeanShell sampler script, but Java sampler is typically more efficient than BeanShell sampler, and maintainability of such solution will be better (you won't have 2 co-dependent components to maintain).

一个更有趣的选择是创建自己的 JMeter插件(我在此处提供的链接较旧,并且不够准确,但这是一个很好的起点).这是一笔相当大的投资,但是如果您发现更简单的解决方案通常可以使用,但是有一些主要限制,或者您需要更高级别的可配置性和控制能力,那么最终还是值得的.

A more fancy option is to create your own JMeter Plug-in (the link I provide here is old, and not very accurate, but it's a good starting point). This is quite an investment, but might be worth it eventually if you find that a simpler solution generally works, but has some major limitations, or you need higher level of configurability and control.

每个线程都会创建一个单独的TCP连接吗?

will each thread create a separate TCP connection?

每个线程独立运行,但是每个线程是否有自己的连接将取决于您实现它们的方式.在直接实现中(采样器创建和销毁连接),每个线程将具有一个单独的TCP连接.但是JMeter在线程之间共享了属性,其中的其余部分可以包含对象.因此,您可以通过这种方式在线程之间共享连接.或者,您可以实现配置元素,它可以保存所有线程共享的连接池.

Each thread runs independently, but whether each thread will have its own connection will depend on how you implemented them. In straight forward implementation (where sampler creates and destroys connection), each thread will have a separate TCP connection. But JMeter has properties shared among threads, which, among the rest, can contain objects. So you could share a connection between threads that way. Or you can implement configuration element, which could hold a connection pool, shared by all threads.

这篇关于是否可以使用jmeter测试grpc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆