1. Concept library
  2. Java & Spring Boot
  3. Module 11: Microservices

Concept

Service discovery

Services find each other by name through a registry such as Eureka or Consul, or through the platform's DNS in Kubernetes, instead of hard-coded hosts. Instances come and go and clients keep working.

What a session covers

The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.

  1. Explain how services find each other by name
  2. Explain what a registry does when instances come and go
  3. Spot the registry duplicating the platform's DNS

In practice

A few lines that show Service discovery doing its job.

Java
@Bean
@LoadBalanced
RestClient.Builder restClient() { return RestClient.builder(); }

@Service
class PricingClient {
    private final RestClient client;
    PricingClient(RestClient.Builder builder) { this.client = builder.baseUrl("http://catalog-service").build(); }

    Price priceOf(String sku) {
        return client.get().uri("/prices/{sku}", sku).retrieve().body(Price.class);
    }
}

The common mistake

Watch for

Running a registry on a platform that already provides discovery. On Kubernetes a Service name is a stable DNS entry; adding Eureka on top duplicates it and adds a component that can fail.

What to know first

Your roadmap puts these before Service discovery, unless you already know them.

How it stays learned

Once a session shows you understand Service discovery, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.

  1. Day 3First recall, while it is fresh
  2. Day 7Second, a week on
  3. Day 18Last, when it has settled
Previous in the module← Spring Cloud Gateway