6 On Service Discovery
This chapter covers
- Explaining why service discovery is important to any cloud-based application development
- Understanding the pros and cons of service discovery vs the more traditional load-balancer approach
- Setting up a Spring Netflix Eureka Server
- Registering a Spring Boot-based microservice with Eureka
- Using Spring Cloud and Netflix’s Ribbon library to use 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 repository.
Service discovery is critical to microservice, cloud-based applications for two key reasons. First, it offers the application team the ability to quickly horizontally scale up and down the number of service instances running in an environment. The service consumers are abstracted away from the physical location of the service via service discovery. Because the service consumers don’t know the physical location of the actual service instances, new service instances can be added or removed from the pool of available services.