# Performance Testing gRPC Services ![rw-book-cover](https://k6.io/blog/static/c7dddfe38f216b08c235ba2127b51dd2/28767/cover.png) URL:: https://k6.io/blog/performance-testing-grpc-services/ Author:: Simon Aronsson ## Highlights > Unary[](https://k6.io/blog/performance-testing-grpc-services#unary) > Unary calls work the same way as a regular function call: a single request is sent to the server which in turn replies with a single response. > [![unary call](https://k6.io/blog/static/c48fc5ca8336d9cd8b98618c4b9d86ec/7842b/grpc-unary.png "unary call")](https://k6.io/blog/static/c48fc5ca8336d9cd8b98618c4b9d86ec/7842b/grpc-unary.png) > Server Streaming[](https://k6.io/blog/performance-testing-grpc-services#server-streaming) > In server streaming mode, the client sends a single request to the server, which in turn replies with multiple responses. > [![server streaming](https://k6.io/blog/static/fbc08c79e035da81aca99e4bc220f95e/7842b/grpc-server.png "server streaming")](https://k6.io/blog/static/fbc08c79e035da81aca99e4bc220f95e/7842b/grpc-server.png) > Client Streaming[](https://k6.io/blog/performance-testing-grpc-services#client-streaming) > The client streaming mode is the opposite of the server streaming mode. The client sends multiple requests to the server, which in turn replies with a single response. > [![client streaming](https://k6.io/blog/static/ebdd5a0dedb7bdae80e59ceba69c6b75/7842b/grpc-client.png "client streaming")](https://k6.io/blog/static/ebdd5a0dedb7bdae80e59ceba69c6b75/7842b/grpc-client.png) > Bi-directional streaming[](https://k6.io/blog/performance-testing-grpc-services#bi-directional-streaming) > In bi-directional streaming mode, both the client and the server may send multiple messages. > [![bi-directional streaming](https://k6.io/blog/static/094a57810030c8df50d05a8c87a1dee1/7842b/grpc-bidirectional.png "bi-directional streaming")](https://k6.io/blog/static/094a57810030c8df50d05a8c87a1dee1/7842b/grpc-bidirectional.png) ([View Highlight](https://read.readwise.io/read/01h58gmvtw95aq2vkh9nvf43eg)) > The messages and services used for gRPC are described in .proto files, containing [Protocol buffers](https://en.wikipedia.org/wiki/Protocol_Buffers), or protobuf, definitions. ([View Highlight](https://read.readwise.io/read/01h58gn6bjhf3bpnz6wnfmaam1)) > The definition file is then used to generate code which can be used by both senders and receivers as a contract for communicating through these messages and services. As the binary format used by gRPC lacks any self-describing properties, this is the only way for senders and receivers to know how to interpret the messages. ([View Highlight](https://read.readwise.io/read/01h58grqc8wzezx1z3fmy4c23y)) > gRPC is a light-weight open-source RPC framework. It was originally developed by Google, with 1.0 being released in August 2016. ([View Highlight](https://read.readwise.io/read/01h58gjs533t5phftt8y8vvrer)) > In comparison to JSON, which is transmitted as human-readable text, gRPC is binary, making it both faster to transmit and more compact. ([View Highlight](https://read.readwise.io/read/01h58gk368jdjp33fnjk3x8ne8)) > [A benchmark by Auth0](https://auth0.com/blog/beating-json-performance-with-protobuf/) reported up to 6 times higher performance, while other benchmarks, like [this one by Alex Pliutau](https://dev.to/plutov/benchmarking-grpc-and-rest-in-go-565) or [this one by Ruwan Fernando](https://medium.com/@EmperorRXF/evaluating-performance-of-rest-vs-grpc-1b8bdf0b22da), suggests improvements of up to 10 times. ([View Highlight](https://read.readwise.io/read/01h58gkazq5bxx9na09vye1ybv)) > gRPC supports four different types of RPCs, unary, server streaming, client streaming, and bi-directional streaming. ([View Highlight](https://read.readwise.io/read/01h58gky0vjrwx7xcmp0mgxbpg)) --- Title: Performance Testing gRPC Services Author: Simon Aronsson Tags: readwise, articles date: 2024-01-30 --- # Performance Testing gRPC Services ![rw-book-cover](https://k6.io/blog/static/c7dddfe38f216b08c235ba2127b51dd2/28767/cover.png) URL:: https://k6.io/blog/performance-testing-grpc-services/ Author:: Simon Aronsson ## AI-Generated Summary gRPC has gained a lot of attention as well as a wide adoption since it was first released. With k6 v0.29.0, we're happy to introduce a native client for gRPC communication. In this article, we'll go through the basics of gRPC in general and the k6 support in particular. ## Highlights > Unary[](https://k6.io/blog/performance-testing-grpc-services#unary) > Unary calls work the same way as a regular function call: a single request is sent to the server which in turn replies with a single response. > [![unary call](https://k6.io/blog/static/c48fc5ca8336d9cd8b98618c4b9d86ec/7842b/grpc-unary.png "unary call")](https://k6.io/blog/static/c48fc5ca8336d9cd8b98618c4b9d86ec/7842b/grpc-unary.png) > Server Streaming[](https://k6.io/blog/performance-testing-grpc-services#server-streaming) > In server streaming mode, the client sends a single request to the server, which in turn replies with multiple responses. > [![server streaming](https://k6.io/blog/static/fbc08c79e035da81aca99e4bc220f95e/7842b/grpc-server.png "server streaming")](https://k6.io/blog/static/fbc08c79e035da81aca99e4bc220f95e/7842b/grpc-server.png) > Client Streaming[](https://k6.io/blog/performance-testing-grpc-services#client-streaming) > The client streaming mode is the opposite of the server streaming mode. The client sends multiple requests to the server, which in turn replies with a single response. > [![client streaming](https://k6.io/blog/static/ebdd5a0dedb7bdae80e59ceba69c6b75/7842b/grpc-client.png "client streaming")](https://k6.io/blog/static/ebdd5a0dedb7bdae80e59ceba69c6b75/7842b/grpc-client.png) > Bi-directional streaming[](https://k6.io/blog/performance-testing-grpc-services#bi-directional-streaming) > In bi-directional streaming mode, both the client and the server may send multiple messages. > [![bi-directional streaming](https://k6.io/blog/static/094a57810030c8df50d05a8c87a1dee1/7842b/grpc-bidirectional.png "bi-directional streaming")](https://k6.io/blog/static/094a57810030c8df50d05a8c87a1dee1/7842b/grpc-bidirectional.png) ([View Highlight](https://read.readwise.io/read/01h58gmvtw95aq2vkh9nvf43eg)) > The messages and services used for gRPC are described in .proto files, containing [Protocol buffers](https://en.wikipedia.org/wiki/Protocol_Buffers), or protobuf, definitions. ([View Highlight](https://read.readwise.io/read/01h58gn6bjhf3bpnz6wnfmaam1)) > The definition file is then used to generate code which can be used by both senders and receivers as a contract for communicating through these messages and services. As the binary format used by gRPC lacks any self-describing properties, this is the only way for senders and receivers to know how to interpret the messages. ([View Highlight](https://read.readwise.io/read/01h58grqc8wzezx1z3fmy4c23y)) > gRPC is a light-weight open-source RPC framework. It was originally developed by Google, with 1.0 being released in August 2016. ([View Highlight](https://read.readwise.io/read/01h58gjs533t5phftt8y8vvrer)) > In comparison to JSON, which is transmitted as human-readable text, gRPC is binary, making it both faster to transmit and more compact. ([View Highlight](https://read.readwise.io/read/01h58gk368jdjp33fnjk3x8ne8)) > [A benchmark by Auth0](https://auth0.com/blog/beating-json-performance-with-protobuf/) reported up to 6 times higher performance, while other benchmarks, like [this one by Alex Pliutau](https://dev.to/plutov/benchmarking-grpc-and-rest-in-go-565) or [this one by Ruwan Fernando](https://medium.com/@EmperorRXF/evaluating-performance-of-rest-vs-grpc-1b8bdf0b22da), suggests improvements of up to 10 times. ([View Highlight](https://read.readwise.io/read/01h58gkazq5bxx9na09vye1ybv)) > gRPC supports four different types of RPCs, unary, server streaming, client streaming, and bi-directional streaming. ([View Highlight](https://read.readwise.io/read/01h58gky0vjrwx7xcmp0mgxbpg))