Dubbo service Performance measurement (with JMeter)

Reprint please indicate the source!

preface

In order to test the performance impact of the monitoring component on Dubbo RPC calls during the recent monitoring integration of the Dubbo service with Prometheus, performance tests were performed before and after the addition. Although a unified Dubbo service testing platform was built for the group, it was not used for performance testing.

When it comes to performance testing, you can choose from WRK, JMeter, and so on. However, most of the tools are used to test HTTP interfaces. There is no native support for Dubbo ://, the proprietary protocol of the Dubbo framework. The first idea is to write your own client through a Dubbo generalization call and count the test results, but this is not elegant and it is possible to duplicate the wheel and waste time. After some Google, I got the answer I wanted.

Jmeters-plugins-for-apache-dubbo is a new JMeter plug-in from Dubbo, which allows JMeter to test Dubbo services.

This article assumes that you have done a simple performance test with JMeter and that you have JMeter installed

The body of the

Step 1: Install Dubbo plug-in

  1. Cloning projects: git clone https://github.com/thubbo/jmeter-plugins-for-apache-dubbo.git

  2. Package the project and build the JMeter plug-in: MVN Clean Install

    Alternatively, you can skip the previous two steps and download jmeters-plugins-dubo-2.3.3-jar-with-dependencies. Jar

  3. Add the plug-in to ${JMETER_HOME}\lib\ext (restart JMeter after installation)

Step 2: Write the JMeter script

1. Create Dubbo Sample

Right-click Thread Groups in the Test Plan area and choose Add > Sampler > Dubbo Sample

In the Dubbo Sample dialog box, configure the registry address, service interface name (Java Interface class name), method name, parameter type, and parameter value.

The configuration procedure is as follows:

  • Configure registries, usually using ZooKeeper. (After the configuration is complete, click the Get Provider List button above to Get the List of registered services)

    • ifProtocolChoose tozookeeper,AddressEnter the ZooKeeper address.
    • If the production environment contains multiple ZooKeeper nodes, enter multiple ZooKeeper addresses and separate them with commas (,).
    • If the test is performed on a single server, theProtocolchoosenone.AddressFill in the Dubbo service address.
  • Adjust the service invocation configuration as required, such as Group, Version, and call Timeout time (default: 1 second).

  • Configure the full Java interface class name and method name for the Dubbo service.

  • Configure the parameter type and value for each parameter.

    • Parameter types: Basic types (Boolean, int, etc.) write the type name directly, other types write the full Java class name (note that the full class name).
    • Parameter values: Write parameter values for basic types and strings, and fill in JSON values for complex types.

To facilitate local debugging of test scripts, you can add structure listeners by right-clicking Thread Groups and choosing Add > Listeners > View Result Tree to add a view result tree listener.

Step 3: Test execution

Right click on ** thread Groups and click Verify ** to perform a single request to test the connectivity of the tool and service.

In the ** view result tree TAB, you can see that the response data ** returns as expected, indicating that the Dubbo call can be executed normally.

Step 4: Add assertions

Sometimes you will see the execution result as a success when in fact the Dubbo service call failed, or the business process failed, and the return result contains an error code. Take the two images below.

The RPC call failed. Procedure

Service processing failed. Procedure

Solutions:

For such problems, you can add assertions to check whether the service succeeded. The result of the generalization call is returned as JSON, and you can add assertions to check the returned JSON data to more accurately verify that the service execution was successful.

To do this, right-click the Dubbo Sample in the JMeter Test Plan area and choose Add > Assert > JSR233 Assertion.

Here I present my Groovy test script code:

String respStr = null;

Map<String, Object> resp = null;

try {

respStr = SampleResult.getResponseDataAsString();

resp = (Map<String, Object>) com.alibaba.fastjson.JSON.parse(respStr);

} catch (Throwable ex) {

// pass

log.error("error", ex);

}

if (resp == null) {

AssertionResult.setFailure(true);

AssertionResult.setFailureMessage("RESPONSE IS NOT JSON: " + respStr);

} else {

// Simple check: When the dubbo generalization call fails, JSON containing the code and detailMessage fields is returned.

if (resp.get("code") != null && resp.get("detailMessage")) {

AssertionResult.setFailure(true);

AssertionResult.setFailureMessage("rpc exception, code=" + resp.get("code") + " detailMessage=" + resp.get("detailMessage"));

} else if(!"SUCCESS".equals((String)resp.get("code"))) {

// TODO verifies the success of the request based on your actual business.

AssertionResult.setFailure(true);

AssertionResult.setFailureMessage("Request failed, code=" + resp.get("code"));

} else {

AssertionResult.setFailure(false);

}

}

Copy the code

Let’s look at the result of the validation after the assertion is added.

As you can see, the assertion serves as a business validation and prompts for an error message.

As for how to write the rest of the script, you will have to set up the scenario you want to simulate, which is how to use JMeter, so I won’t go into it here.

More Frequently Asked Questions

For more frequently asked questions about the plug-in, refer to the FAQ in the Github Wiki for the plug-in.

reference

  • jmeter-plugins-for-apache-dubbo