GithubHelp home page GithubHelp logo

rlebran / grpc-gatling Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tamediadigital/grpc-gatling

0.0 2.0 0.0 374 KB

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

License: MIT License

Scala 100.00%

grpc-gatling's Introduction

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

grpc-gatling's People

Watchers

James Cloos avatar Romain Lebran avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.