Search code examples
jmeterbeanshellgrpcgrpc-java

is it possible to use jmeter to test grpc


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

I was hoping that

  • I could write a gRPC client class with a non-blocking/asynchronous stub that makes non-blocking calls to the server,
  • Create a Jar of the above client
  • Import the Jar to JMeter
  • Use the Java method in Jmeter BeanShell sampler

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

  • if above workaround work?
  • will each thread create a separate TCP connection?

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)

SOLUTION: Have a look at https://github.com/whatalokation/whatalokation-grpc-client Readme.md should be self explanatory


Solution

  • if above workaround work?

    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).

    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.

    will each thread create a separate TCP connection?

    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.