6 On service discovery

 

This chapter covers

  • Why service discovery is important to cloud-based applications
  • The pros and cons of service discovery vs. the Load Balancer
  • Setting up a Spring Netflix Eureka Server
  • Registering a Spring Boot microservice with Eureka
  • Using the Spring Cloud Load Balancer library for client-side load balancing

In any distributed architecture, we need to find the hostname or IP address of where a machine is located. This concept has been around since the beginning of distributed computing and is known formally as “service discovery.” Service discovery can be something as simple as maintaining a property file with the addresses of all the remote services used by an application, or something as formalized as a Universal Description, Discovery, and Integration (UDDI) repository. Service discovery is critical to microservice, cloud-based applications for two key reasons:

  • Horizontal scaling or scale out—This pattern usually requires adjustments in the application architecture, such as adding more instances of a service inside a cloud service and more containers.
  • Resiliency—This pattern refers to the ability to absorb the impact of problems within an architecture or service without affecting the business. Microservice architectures need to be extremely sensitive to preventing a problem in a single service (or service instance) from cascading up and out to the consumers of the service.

6.1 Where’s my service?

6.2 Service discovery in the cloud

6.2.1 The architecture of service discovery

6.2.2 Service discovery in action using Spring and Netflix Eureka

6.3 Building our Spring Eureka service

6.4 Registering services with Spring Eureka

6.4.1 Eureka’s REST API

6.4.2 Eureka dashboard

6.5 Using service discovery to look up a service

6.5.1 Looking up service instances with Spring Discovery Client

6.5.2 Invoking services with a Load Balancer–aware Spring REST template

6.5.3 Invoking services with Netflix Feign client

Summary