chapter two

2 gRPC Meets with Microservices

 

This chapter covers

  • Comparing advantages and disadvantages of Microservice Architecture to Monolithic Architecture
  • Understanding communication patterns in Microservice Architecture
  • Analyzing service discovery mechanisms
  • Addressing the reasons behind how Go and gRPC boosts reliable inter-service communication as well as development productivity

The fundamental goal of any software development team is to implement a set of features to form a product in order to create direct or indirect business value out of it. The format of this product has been evolved for decades, it has been distributed as a package that you can install in your computer offline, or it has been served as a product over the internet that you can use online. Each programming language has its own packaging methodology; for example, you can use war or jar file for Java or binary executable for Go projects. We call this Monolithic Architecture, where one or more features/modules are packaged as one product that does related tasks within a distributable object. Once the scalability problems arose, alternative solutions like Microservice Architecture became very popular where the application is decomposed into services based on their business capabilities. The stability of the inter-service communication is very important to provide the data consistency among those services. In this chapter, we will see how important gRPC is for inter-service communication.

2.1 Monolithic Architecture

2.1.1 Development

2.1.2 Deployment

2.1.3 Scaling

2.2 Scale Cube

2.2.1 X-Axis Scaling

2.2.2 Z-Axis Scaling

2.2.3 Y-Axis Scaling

2.3 Microservice Architecture

2.3.1 Handling Data Consistency

2.3.2 Saga Pattern

2.3.3 Choreography-based Saga

2.3.4 Orchestrator-based Saga

2.4 Service Discovery

2.5  Using gRPC for Inter-Service Communication

2.5.1 Working with Protocol Buffers

2.5.2 Generating Go Source Code

2.5.3 Connecting Wires Together

2.6 Summary