More than ever before, present day businesses want their IT systems to constantly evolve and be capable of responding positively to the changing goals and priorities. As they say, change is the only constant. In this context, microservices have become the proverbial Holy Grail for solution architects to design and build modern software. By Nikhil Mohan.
Inter-service communication is one of the most critical design elements in a microservices-based solution that needs careful consideration. RESTful API carrying data in JSON is widely adopted as the most common communication pattern for connecting microservices together.
However, this approach is suboptimal in the following scenarios:
- REST is resource-oriented. This can be a limiting factor while dealing with API flexibility
- JSON payloads are human-friendly, but they are bulky and not machine-friendly. Therefore, JSON payload parsing is compute-intensive
- Data transfer in HTTP 1.1 is text-based and involves no compression of request headers. This results in high bandwidth utilization
gRPC is an open source framework developed by Google and currently managed under the aegis of Cloud Native Computing Foundation (CNCF). gRPC does all the heavy lifting work for inter-service communication leaving developers with only the task of defining a contract for remote procedure calls in a language-neutral format. Moreover, gRPC is action-oriented, thereby helping developers to design flexible APIs.
- gRPC uses HTTP/2 under the hood. HTTP/2 helps gRPC to overcome some of the limitations with REST over HTTP 1.1
- HTTP/2 is based on binary data transfer making it highly bandwidth-efficient
- HTTP/2 does header compression, again helping network bandwidth utilization
- Language independent. Very ideal for a polyglot microservices architecture
- Supports streaming communication pattern
- Easy to plug in features such as authentication, load balancing, logging, and monitoring
Architects like to view modern systems as a collection of numerous cloud native components. Being cloud native is fundamental to the solution, irrespective of whether the target solution is planned for cloud or not. Follow the link to the full article to see example design for movie finder application using gRPC. How interesting!
[Read More]