Send protobuf data in JMeter

By | August 16, 2015

Assuming that you have an application (e.g. API) which accepts some data serialized in protobuf and you would like to do testing with sample data in JMeter. Here you are on the right page. As we know, because data serialized in protobuf is in binary form, you can’t use this data through in JMeter easily unlike plain text formats such as JSON, XML. That’s why using protobuf data in JMeter requires additional work. At least, that’s what I have experienced.

Let me first explain the sample scenario and how I used protobuf data in JMeter. I have an API Service, built in ASP.NET Web API and a client application. This client application communicates with the API in different formats, mainly JSON and Protobuf. And, I would like to test the endpoints of the API which accepts data in protobuf using JMeter.

I started to capture the requests by Fiddler.


Then, I saved the request body of the endpoints which accept protobuf data to generate sample test data.


I saved request body as Sample_request.proto. This is how I generated sample test data. Sure, you can follow other ways. For example, you create a simple console application which generates test data, serializes in protobuf and saves to disk for later use. The key point is here you should be able to generate your test data in protobuf somehow to use in JMeter.

Then, we start playing with JMeter and create our test cases. I created an HTTP request to call my API. As you see from the following screenshot, I added Sample_request.proto, which I generated before and saved to disk. Pay attention to the area with red circle.


In addition, because I try to send this data in protobuf format, I need to declare the content type in the headers. That’s why I instruct JMeter to add required content type to request headers before sending. See the following screenshot.


If your application accepts only protobuf by default, you might skip this step.

Now, I am done with configuration. I generated test sample data serialized in protobuf and saved to disk by Fiddler. Then, I created a test case in JMeter and added a sample HTTP request with the sample test file added to file list and modified to request headers to specify content type to communicate with API properly.

Finally, I tested this test case and it works fine. Great! See the following screenshot to check how JMeter sends the request to API.


I hope it helps you to test your application which accepts non-plain formats such as protobuf. If you know different way to accomplish the same case, I would like to hear for sure.

2 thoughts on “Send protobuf data in JMeter

  1. Tuesday

    Nice overview of the toolkit, been using the tool for around a year now, Its one of the best all in one tools around in my opi.nonnOice you know how to create custom queries the information you can pull from it is endless

  2. rocking80


    I found this does not work in JMeter 3.3.
    The HTTP request UI is different with the one in your blog. So I add the protobuf file in “Files Upload” tab and set MIME type as “application/x-protobuf” (I don’t know how to set the “Parameter name” value). And the response reports: “{“error”:”too many data to read, block capacity is 4194304 bytes, 0 byte(s) used”}”.

    Could you please help me out? Many thanks.


Leave a Reply

Your email address will not be published.