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

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

问题描述

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

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

我希望

  • 我可以编写一个带有非阻塞/异步存根的 gRPC 客户端类,用于对服务器进行非阻塞调用,
  • 创建上述客户端的Jar
  • 将 Jar 导入 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 采样器,实现 自定义 Java 采样器.这是非常实用的,因为在工作方面它将与实现自定义客户端 + BeanShell 采样器脚本相似/相同,但是 Java 采样器通常比 BeanShell 采样器更有效,并且此类解决方案的可维护性会更好(您不会有 2 个 co-要维护的依赖组件).

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 有 properties 在线程之间共享,这,其中,可以包含对象.因此,您可以通过这种方式共享线程之间的连接.或者你可以实现 配置元素,它可以包含一个连接池,所有线程共享.

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天全站免登陆