← Back to list

Eureka Server and Eureka Client in Spring Boot Microservices

Microservices architecture introduces many independent services communicating with each other. But one major challenge appears immediately:

Vinojini Paramasivam · 2026-05-07 14:09 · 0 claps · 3.3 min read
#microservices #spring-cloud #eureka #java #distributed-systems
Open on Medium ↗
Wiki topics: 🏛️ · Architecture

Eureka Server and Eureka Client in Spring Boot Microservices

Microservices architecture introduces many independent services communicating with each other. But one major challenge appears immediately:

How do services find and communicate with each other when IP addresses and ports keep changing?

This is where Eureka comes in.

What is Eureka?

Spring Boot and Eureka are widely used together in microservice architecture for Service Discovery.

Eureka is part of the Netflix OSS ecosystem and is integrated into Spring Boot through Spring Cloud Netflix.

It acts as a Service Registry where all microservices register themselves.

What is Netflix OSS?

Netflix created many tools to manage its massive distributed microservice systems.

These tools are called Netflix OSS.

OSS = Open Source Software

Some important Netflix OSS tools:

Core Netflix OSS Tools Used in Microservices Architecture

Core Netflix OSS Tools Used in Microservices Architecture

Later, Spring Cloud integrated many of these tools into Spring Boot.

That integration is called:

Spring Cloud Netflix

Main Concepts in Eureka

Eureka mainly has two parts:

  1. Eureka Server → Registry Center
  2. Eureka Client → Registered Microservice

Eureka Server

The Eureka Server is the central registry.

It stores information about all running microservices.

The server keeps:

  • Service name
  • IP address
  • Port
  • Health status

It is usually a separate Spring Boot application.

Responsibilities of Eureka Server

  • Stores all registered services
  • Receives heartbeats
  • Removes dead services
  • Provides service discovery information

Eureka Client

Any microservice that registers with Eureka is called a Eureka Client.

Example:

  • ORDER-SERVICE
  • PAYMENT-SERVICE
  • USER-SERVICE

All of these can become Eureka Clients.

Responsibilities of Eureka Client

  • Registers itself with Eureka
  • Sends heartbeat signals
  • Discovers other services

Service Registration

When a microservice starts:

  1. It automatically registers with Eureka
  2. It sends:
  • Service name
  • IP address
  • Port
  • Health status

Example:

spring:
  application:
    name: ORDER-SERVICE

Now Eureka knows: “ORDER-SERVICE is running on this IP and port.”

Heartbeat Mechanism

Every Eureka Client periodically sends a heartbeat to the Eureka Server.

Default interval: Every 30 seconds

The heartbeat basically says: “I am alive.”

If the heartbeat stops, Eureka removes that service from the registry.

This prevents dead or crashed services from being used.

Why is Eureka Needed?

In microservices:

  • IP addresses can change
  • Ports can change
  • Services scale dynamically

Without Eureka, services would need hardcoded URLs.

Example without Eureka:

http://localhost:8082/orders

Problem:

  • What if the port changes?
  • What if multiple instances exist?

With Eureka:

http://ORDER-SERVICE/orders

Now services communicate using service names instead of fixed URLs.

Multiple Instances of Same Service

One service can have multiple running instances.

Example:

ORDER-SERVICE
→ 8081
→ 8082
→ 8083

Eureka stores all instances.

A load balancer can automatically choose one instance.

This helps with:

  • Scalability
  • High availability
  • Fault tolerance

Eureka Only Handles Service Discovery

Important point:

Eureka only helps services find each other.

It does NOT:

  • Route external requests
  • Handle authentication
  • Perform rate limiting

For those tasks, we use an API Gateway.

API Gateway vs Eureka — A Common Beginner Confusion in Microservices

API Gateway vs Eureka — A Common Beginner Confusion in Microservices

Common API Gateway tools:

  • Spring Cloud Gateway
  • Zuul

Important Annotations

1. @EnableEurekaServer

Used in the Eureka Server application.

When added:

  • The application becomes an Eureka Registry
  • Other services can register with it
  • It stores service information
  • It receives heartbeats
  • It provides service discovery

Example:

@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApplication {
    public static void main(String[] args) {
        SpringApplication.run(EurekaServerApplication.class, args);
    }
}

2. @EnableDiscoveryClient

Used in microservice/client applications.

It tells Spring Boot: “This service should register with a discovery server.”

It works with multiple discovery systems:

  • Eureka
  • Consul
  • Zookeeper

When added:

  • Service registers with Eureka
  • Sends heartbeats
  • Can discover other services

Example:

@SpringBootApplication
@EnableDiscoveryClient
public class OrderServiceApplication {
}

3. @EnableEurekaClient

Very similar to @EnableDiscoveryClient.

Difference:

AnnotationScope@EnableDiscoveryClientGeneric@EnableEurekaClientEureka-specific

In modern Spring Boot + Spring Cloud versions:

If the Eureka dependency is added, client configuration is usually auto-configured.

So these annotations are often optional now.

Simple Eureka Flow

Step 1 — Start Eureka Server

The registry server starts first.

Step 2 — Start Microservices

Example:

  • ORDER-SERVICE
  • PAYMENT-SERVICE

They register themselves with Eureka.

Step 3 — Services Discover Each Other

ORDER-SERVICE asks Eureka: “Where is PAYMENT-SERVICE?”

Eureka responds with the available instances.

Step 4 — Communication Happens

ORDER-SERVICE communicates using the service name instead of hardcoded IP addresses.

Advantages of Eureka

✅ Dynamic Service Discovery ✅ No Hardcoded URLs ✅ Better Scalability ✅ Load Balancing Support ✅ Easier Microservice Communication ✅ Fault Tolerance

Final Thoughts

Eureka is one of the foundational concepts in Spring Boot microservices.

It solves a very important problem: “How do microservices find each other dynamically?”

Once you understand Eureka clearly, the next concepts become much easier:

  • API Gateway
  • Load Balancing
  • Feign Client
  • Distributed Tracing
  • Circuit Breakers
  • Kubernetes Service Discovery

Microservices become powerful when services can communicate dynamically — and Eureka is the first big step toward that.


메타데이터
post_id
27c187efb437
slug
eureka-server-and-eureka-client-in-spring-boot-microservices-27c187efb437
url
https://medium.com/@vinojinip76/eureka-server-and-eureka-client-in-spring-boot-microservices-27c187efb437
canonical_url
https://medium.com/@vinojinip76/eureka-server-and-eureka-client-in-spring-boot-microservices-27c187efb437
author_url
https://medium.com/@vinojinip76
status
ok
fetched_at
2026-07-10 19:15:58