Module 1: Service Discovery (The Phone Book)
📚 Module 1: Service Discovery (Eureka)
Focus: Moving from “One Service” to “A Team of Services.”
When your app gets too big, you split it into Microservices. But how do these services find each other? If “Service A” needs to talk to “Service B,” it needs an address (IP). We use Service Discovery (Netflix Eureka) as a phone book.
🏗️ Step 1: The “Moving Address” Problem
Imagine a large company with 100 offices.
- Every day, the marketing team moves to a different office.
- If you want to find them, you can’t just memorize “Office 101.”
- You need a way to ask: “Where is the Marketing team right now?”
🏗️ Step 2: Eureka (The “Phone Book”)
Netflix Eureka is the most popular phone book for Java microservices.
- Registration: When a service starts up, it calls the Eureka Server and says: “Hi, I’m the Payment Service, and my address is 192.168.1.50.”
- Lookup: When the Order Service needs to process a payment, it asks Eureka: “Hey, give me the address for the Payment Service.”
- Discovery: Eureka hands over the address, and the services can now talk!
🏗️ Step 3: Why use Discovery?
- Dynamic Scaling: You can start 10 versions of the same service, and Eureka will keep track of all of them.
- Resilience: If one service crashes, it stops sending its “Heartbeat” to Eureka. Eureka removes it from the phone book so nobody tries to call it.
🥅 Module 1 Review
- Microservices: Splitting a giant app into small, specialized ones.
- Eureka Server: The central phone book.
- Eureka Client: Any service that wants to be in the phone book.
- Registration: Letting the phone book know you exist.