Spring Cloud Netflix and Service Discovery

  • Introduction to Spring Cloud Netflix
  • Need for Service Discovery in microservices architecture
  • Implementing Service Discovery—Eureka Server:
    • Enabling Eureka Server as a Discovery Service Server
  • Implementing Service Discovery—Eureka Clients:
    • Registering clients with Eureka
    • Consuming the REST service
    • Using EurekaClient
    • Using DiscoveryClient
    • Client-side load balancing using Netflix Ribbon
    • Using the registry-aware client, Spring Cloud Netflix FeignClient

Introduction to Spring Cloud Netflix

The Spring Cloud Netflix project is one of the key sub-projects of Spring Cloud. This project provides integration between Netflix OSS and the Spring Boot application using the auto-configuration behavior of Spring Boot.

Netflix OSS provides multiple components for the distributed applications for several purposes, such as Service Discovery (Eureka), Circuit Breaker (Hystrix), Intelligent Routing (Zuul), and Client-Side Load Balancing (Ribbon).

The need for Service Discovery in the microservices architecture

Without Service Discovery

Account Service requests Customer Service to fetch records of a customer in JSON format. And both services have their own DB access—Account DB and Customer DB, respectively. Also, Customer Service has multiple running instances due to high availability and throughput, and to make it resilient. But how will Account Service call Customer Service? Which instance should be called?

To answer these questions, Service Discovery comes into the picture and solves these cloud-native problems. Let's look at the diagram with Discovery Service:

With Service Discovery

Let's see the workflow:

  • Account Service registers itself with Eureka Discovery Server
  • Customer Service also registers itself with Eureka Discovery Server
  • Account Service consults with Discover Server to find Customer Service
  • Account Service knows about the Customer Service's instance to be called

Spring Cloud supports several implementations of Service Discovery, such as Netflix Eureka and Hashicorp Consul. Spring Cloud makes it easy to utilize either of those servers while hiding their internal complexity.

results matching ""

    No results matching ""