Skip to content

Sample project that demonstrate how Gatling can be used for performance testings of gRPC servers.

License

Notifications You must be signed in to change notification settings

rlebran/grpc-gatling

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sample project to test gRPC based servers using Gatling

Terms:

  1. Gatling is an open-source load testing framework based on Scala, Akka and Netty alt-text

  2. gRPC is a high performance, open-source universal RPC framework alt-text

Background

As one of Tamedia projects required highly performable HTTP/2 based server with well defined API that can be used from various clients and from various programming languages, gRPC came up as good option. Everything was going fine in terms of development, but we found as difficult to execute proper performance testing. Searching for the best way we found couple examples like [https://github.com/smallnest/RPC-TEST] or [https://github.com/ExampleDriven/spring-boot-grpc-example] that didn't work for us because they were to complecated to implement or they just didn't give us valuable results.

Once we looked at Gatling we found it as nice and powerful solution, BUT :) Gatling is mainly focused on HTTP and supports JMS.

What with gRPC?

Solution

Fortunately, Gatling gives you opportunity to build your own protocols that put us in right direction. Bjorn Beskow’s article titled: “Creating a custom Gatling protocol for AWS Lambda” just was right way and helped us to build protocol we can easily use to test any of our gRPC calls.

Now we are able to do something like:

 val grpcConfig = GRPC()

  val grpcScenario = scenario("Test GRPC server")
      .exec(grpcCall(GrpcAsyncCallAction("async", host, port, json)).check(new GrpcCustomCheck((s: GeneratedMessage) => {
        s.asInstanceOf[LogResponse].message.equals("OK")
      })))
      .exec(grpcCall(GrpcSyncCallAction("sync", host, port, json)).check(new GrpcCustomCheck((s: GeneratedMessage) => {
        s.asInstanceOf[LogResponse].message.equals("OK")
      })))

  setUp(
    grpcScenario.inject(
       atOnceUsers(10),
       rampUsers(10) over(5 seconds),
       constantUsersPerSec(20) during(15 seconds),
       heavisideUsers(1000) over(20 seconds))
  ).protocols(grpcConfig)

The ch.tamedia.gatling.actions package contains GrpcExecutableAction trait and two traits that extends this one named GrpcExecutableAsyncAction and GrpcExecutableSyncAction. These two traits are important when we want to build Sync or Async test calls. The traits are used by GrpcActionActor in pattern matching when we have to handle response from the server. Response can be Option[GeneratedMessage] or Future[GeneratedMessage] depending is it sync or async call.

This give us option just to implement specific actions such as GrpcSyncCallAction and GrpcAsyncCallAction.

In order to validate response it is necessary to write your own Checkers such as one GrpcCustomCheck

After all we are now able to get some nice Gatling result and we are able to test all of our gRPC calls.

alt-text

alt-text

alt-text

About

Sample project that demonstrate how Gatling can be used for performance testings of gRPC servers.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Scala 100.0%