Load testing a protocol buffers based server application

1,012 views
Skip to first unread message

Ingo Jaeckel

unread,
Sep 6, 2014, 4:12:42 PM9/6/14
to gat...@googlegroups.com
Hi,

I want to loadtest a server application that uses Google protocol buffers. Of course all the .proto files (RPC calls, request/response objects) are compiled into .java files that are bundled up into a .JAR. I would like to add this JAR file as a dependency to my Gatling loadtest. I want that Gatling invokes those protobuf RPCs just as any other loadtest.

However, I am unsure if/how this would work with Gatling's current DSL. My request/response bodies are all binary. And ideally I can hide this as much as possible from the load test. I am looking for a way to use the generated protobuf Java code as much as possible for deserializing and sending requests. But I would like to use Gatling's DSL to specify which RPCs to call.

How would I add my JAR file as a dependency to the Gatling loadtest?
Assuming my generated code is on Gatling's classpath, how would I use Gatling's DSL to test my protobuf-based server?

Thanks,
Ingo

Ingo Jaeckel

unread,
Sep 10, 2014, 2:59:07 PM9/10/14
to gat...@googlegroups.com
In other words: Can I loadtest a protobuf-based server with Gatling already, or would I have to customize Gatling to do that?

Thanks,
Ingo

Stéphane Landelle

unread,
Sep 11, 2014, 4:16:17 AM9/11/14
to gat...@googlegroups.com
Customize.

As protobuf requires you to ship and use the generated serializers, so that's not something we can have built-in.

Regarding request bodies: you can probably use ByteArrayBody and feed it an Expression[Array[Byte]] that would perform your protobuf serialization.
Regarding response bodies: you can probably use the bodyBytes check, with a transform step that would perform your protobuf deserialization.

Cheers,

Stéphane

--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ingo Jaeckel

unread,
Dec 11, 2014, 4:30:45 PM12/11/14
to gat...@googlegroups.com
Hey Stéphane,

Do you mind providing some example Scala code to demonstrate the approach? I have found a code snippet on stackoverflow that contains the ByteArrayBody type you mentioned:

val request = exec(http("FirstRequest")
   
.post("/message")
   
.body(new ByteArrayBody((session: Session) => getFirstRequest(session)))
   
// ...

val response
= exec(http("SecondRequest")
   
.post("/message")
   
.body(new ByteArrayBody((session: Session) => getSecondRequest(session)))
   
// ...

Would I directly pass a bytes array into ByteArrayBody?

I don't quite understand the syntax of the value passed into the ByteArrayBody constructor. Can you elaborate what this actually does?

(session: Session) => getSecondRequest(session)

Just for the record: This was requested and rejected in this Github issue: https://github.com/gatling/gatling/issues/96.

Thanks,
Ingo

Stéphane Landelle

unread,
Dec 11, 2014, 5:31:00 PM12/11/14
to gat...@googlegroups.com
Things are pretty clear in the SOF thread :)

getFirstRequest and getSecondRequest are methods that take a Session and return an Array[Byte] (or better, a Validation[Array[Byte]).
In those, you would populate some POJO with values coming from the Session, and serialize it.

For example:

getFirstRequest(session: Session) =
  for {
    id       <- session("id").validate[Int]
    name <-  session("id").validate[String]
    email <-  session("id").validate[String]
  } yield Person.newBuilder.setId(id).set(name).set(email).toByteArray

Reply all
Reply to author
Forward
0 new messages