Skip to content

SamsadSajid/order-payment-microservice-poc

Repository files navigation

Motivation

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).

System V1

gRpc-Page-1

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.

Benchmarking V1

Screenshot 2020-10-15 at 8 10 08 AM

1000K requests in 329.12s, 318 MB read

System V2

gRpc-Page-2

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.

Benchmarking V2

Screenshot 2020-10-15 at 12 45 48 PM

976796 2xx responses, 7465 non 2xx responses

984k requests in 2449.86s, 312 MB read

16k errors (16k timeouts)

Conclusion

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.

About

A POC to experiment if gRPC + protobuf performs better than rest + json. And of course, it does!!!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published