2 gRPC meets microservices

 

This chapter covers

  • Comparing the advantages and disadvantages of microservice architecture to monolithic architecture
  • Understanding communication patterns in microservice architecture
  • Analyzing service discovery mechanisms
  • How Go and gRPC boost reliable interservice communication and development productivity

The fundamental goal of any software development team is to implement a set of features in order to form a product and create direct or indirect business value. This product can be distributed as a package that can be installed on a computer offline or can be internet based and used online. Each programming language has its own packaging methodology; for example, you can use a WAR or JAR file for Java projects or a binary executable for Go projects. We call this monolithic architecture: one or more features/modules are packaged as one product that completes related tasks within a distributable object. When scalability problems arise, alternative solutions like microservice architecture are popular, as the application is decomposed into services based on their business capabilities. This decomposition enables the deployment of each service independently, which we will see in detail in chapter 8. Interservice communication stability is imperative to providing data consistency among services. This chapter will show how important gRPC is for interservice 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 interservice communication

2.5.1 Working with protocol buffers