Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)

like image 278
Alok A Avatar asked Mar 25 '17 15:03

Alok A


People also ask

What can be tested using JMeter?

JMeter helps in the performance testing of both static and dynamic resources. Static resources like HTML and JavaScript, and dynamic resources such as JSP, Servlets, and AJAX.

Can JMeter be used for API performance testing?

These APIs are tested to check the functionality, performance, readability, and security of any programming interface. One of the most popular and simple tools to perform API Testing is the Apache JMeter.

How to send a gRPC request using JMeter?

This sampler JMeter lets you send an gRPC request to a server. It's as simple as a HTTP Request. This is a simpler of JMeter used to test for any gRPC server, it is not necessary to generate gRPC classes or to compile the protos binary for the service. Just a very simple for input: Host and port of gRPC service. Method of service needs testing.

How do I test a gRPC service?

It's as simple as a HTTP Request. This is a simpler of JMeter used to test for any gRPC server, it is not necessary to generate gRPC classes or to compile the protos binary for the service. Just a very simple for input: Host and port of gRPC service. Method of service needs testing. Folder path of proto files. Data request in JSON format.

How to add Java samplers to JMeter?

Build the project with maven and copy the generated jar to JMeter lib/ext folder (e.g. /usr/local/apache-jmeter-3.1/lib/ext/) so that the samplers are in the class path After that when you launch JMeter, you should be able to see the classes in the "java request" samplers.

How to enable stress testing with JMeter samplers?

Please see grpc-client java project (maven) that creates a gRPC client with JMeter samplers to enable stress testing with JMeter Build the project with maven and copy the generated jar to JMeter lib/ext folder (e.g. /usr/local/apache-jmeter-3.1/lib/ext/) so that the samplers are in the class path


Video Answer


1 Answers

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.

like image 119
ytrewq Avatar answered Sep 26 '22 04:09

ytrewq