Microservices are loosely coupled services with bounded contexts which gives you the ability to develop, deploy and scale your services independently. It can also be defined as an architectural pattern to build distributed systems which are independently developed and deployed. Handling the service to service communication in a Microservice architecture is challenging since they need to communicate with each other over the unreliable network.
Complexities in a Microservice Architecture
A problem with Distributed applications is that they communicate over the network – which is unreliable. Hence you need to design your microservices in such a way that they are fault tolerant and handle failures gracefully. In your microservice architecture, there might be a dozen services talking with each other. You need to ensure that one failed service does not bring down the entire architecture.
There are a number of moving components in Microservice architecture, hence it has more points of failures. Failures can be caused by a variety of reasons – errors and exceptions in code, release of new code, bad deployments, hardware failures, datacenter failure, poor architecture, lack of unit tests, communication over the unreliable network, dependent services etc.
Netflix OSS to the rescue
Netflix is one of the earliest adopters of microservices. To keep up with its growth rate, Netflix made the decision to move away from Monolithic datacenter to a cloud-based Microservices architecture for achieving high availability, scale, and speed. Based on its success story, Netflix open sourced a number of tools/technologies which powers it microservices architecture. These tools and components have been the drivers for a number of enterprises in their journey from Monolith to Microservices.
Netflix OSS is a set of libraries & framework that Netflix open sourced to solve the issues with designing distributed systems at scale.
Read more about Netflix Open Source Software Center here.
Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications. You can read more about it here.
With a few simple annotations, you can quickly enable and configure the common patterns inside your application and build large distributed systems with battle-tested Netflix components. The patterns provided include Service Discovery (Eureka), Circuit Breaker (Hystrix), Intelligent Routing (Zuul) and Client Side Load Balancing (Ribbon).
Issues with the Netflix OSS
- Netflix libraries are tightly coupled to the Java Platform and are a good fit if you are developing services in the Java platform. However, in a Polyglot Architecture you need to look for libraries beyond Netflix to handle the communication between services.
- Netflix Libraries needs to be embedded inside each microservice along with side Business functionalities. This causes application bloat since you will need to duplicate similar code across all your services.
- Having both the Business logic and Infrastructure logic increases the overall application complexity.
- Operational Complexity is also enhanced since you now need to handle the patching/upgrades to the Netflix components.
- Additional tooling is required to improve the observability of your microservices architecture.
What is a Sidecar Design pattern?
The sidecar design pattern is gaining popularity and wider adoption within the cloud-native community. Building a Microservice architecture that is highly scalable, resilient, secure and observable is challenging. The evolution of Service Mesh architecture has been a game changer. It shifts the complexity associated with the Microservice architecture to a separate infrastructure layer and provides lot of functionalities like Load Balancing, Service Discovery, Traffic Management, Circuit Breaking, Telemetry, Fault Injection and more.
Benefits of using a Sidecar Pattern –
- Reduces the complexity in the microservice code by abstracting the common infrastructure related functionalities to a different layer.
- Reduces code duplication in a Microservice architecture since you do not need to write configuration code inside each microservice.
- Provides loose coupling between the application code and the underlying platform.
How is Service Mesh implemented?
To implement the service mesh, you can deploy a proxy alongside with your services. This is also known as the Sidecar Pattern. The Sidecars abstract the complexity away from the application and handle the functionalities like Service Discovery, Traffic Management, Load Balancing, Circuit Breaking etc.
Envoy from Lyft is the most popular open source proxy designed for cloud-native applications. Envoy runs alongside every service and provides the necessary features in a platform agnostic manner. All traffic to your service flows through the Envoy proxy.
Istio is a very popular Service Mesh Framework which uses Lyft’s Envoy as the sidecar proxy by default. A Sidecar is deployed alongside each service instance and it provides an interface to handle functionalities like service discovery, load balancing, traffic management, inter service communication, monitoring etc. Service Mesh gives you the freedom of not having to worry about the service to service communication as part of your application code. Instead of bloating your microservice with similar functionalities, you can let the Service Mesh handle that complexity for you.
Istio Service Mesh is composed of 2 primary components —
- The Control Plane responsibility is to manage and configure the sidecar proxies to enforce policies and collect telemetry.
- The Data Plane responsibility is to handle the communication between the services and take care of the functionalities like Service Discovery, Load Balancing, Traffic Management, Health Check etc.
Please refer my other blog posts to learn more about the Istio Control Plane and Data Plane –