This codebase is a proof of concept to showcase in micro-service level, gRPC + protobuf(http/2.0)
performs better than json based rest(http/1.0)
.
There are two services. Order service is written in Typescript. And was run with pm2
. There was only one instance.
The payment service is written in Golang and was run with go run
command.
Order service accepts json
request from client. Namely, the connection between client and order service is REST
.
Payment Service accepts binary
requests in protocol buffer. The connection between order service and payment service is remote procedure call gRPC
with protocol buffer
payload.
1000K requests in 329.12s, 318 MB read
There are two services. Order service is written in Typescript. And was run with pm2
. There was only one instance.
The payment service is written in Golang and was run with go run
command. No extra package is used i.e gin Gonic, Gorilla Mux
etc.
Order service accepts json
request from client. Namely, the connection between client and order service is REST
.
Payment service accepts json
also. Namely the connection between order service and payment service is REST
.
976796 2xx responses, 7465 non 2xx responses
984k requests in 2449.86s, 312 MB read
16k errors (16k timeouts)
System V1 manage to handle 1000K
requests. No timeout
issue occurred. On the other hand System V2 has timeout
issue. It could not handle 1000K
requests and there were 976796
success response.
In System V1, order service used the gRPC + protobuf
to talk to payment service.
In System V2, order service used the rest based json
to talk to payment service.
So, gRPC + protobuf
performs better than rest
not only in reducing payload size and reducing bandwidth, it also performs better as there are very few timeout issues.
In this experiment as the payload is smaller so there was no major difference observed in payload in both system. But if it is high, I could see that in such scenario gRPC + protobuf
performs better than rest
.