Overview
The Eureka Server provides service discovery and registration capabilities for all microservices in the StreamLine Logistics platform. Built on Netflix Eureka, it acts as a central registry where services register themselves and discover other services dynamically.Eureka Server runs on port 8761 and serves as the backbone of service-to-service communication in the microservices architecture.
Configuration
Application Configuration
The Eureka Server is configured viaapplication.yml:
Key Configuration Properties
| Property | Value | Description |
|---|---|---|
server.port | 8761 | Standard Eureka Server port |
spring.application.name | msvc-eureka | Service identifier |
eureka.client.register-with-eureka | false | Prevents server from registering with itself |
eureka.client.fetch-registry | false | Server doesn’t need to fetch registry |
eureka.instance.hostname | eureka-server | Hostname used in Docker environment |
The
register-with-eureka and fetch-registry properties are set to false because this is the Eureka Server itself, not a client. Client services will have these set to true.Spring Boot Application
The Eureka Server is enabled with a single annotation:@EnableEurekaServer annotation activates all Eureka Server functionality, including:
- Service registration endpoints
- Service discovery API
- Health monitoring dashboard
- Registry replication (in cluster mode)
Docker Configuration
The Eureka Server runs as a Docker container in the microservices network:All microservices define
depends_on: eureka-server to ensure the registry is available before services attempt to register.Service Registration
How Services Register
Client services (Order, Inventory, Tracking) register with Eureka by including these dependencies:application.yml:
Registration Process
- Service Startup: When a microservice starts, it sends a registration request to Eureka Server
- Heartbeats: Services send heartbeat signals every 30 seconds (default) to maintain their registration
- Renewal: Eureka expects renewals every 30 seconds; services not renewing are evicted after 90 seconds
- Metadata: Services register with metadata including hostname, port, health check URL, and custom metadata
Registered Services
The following services register with Eureka:- msvc-order (Order Service) - Port 8090
- msvc-inventory (Inventory Service) - Port 9090
- msvc-tracking (Tracking Service) - Port 8091
Service Discovery
Services discover each other using Eureka’s registry:Using OpenFeign
StreamLine Logistics uses OpenFeign for inter-service communication. Feign clients automatically resolve service names via Eureka:name = "msvc-inventory" is resolved by querying Eureka for instances of the inventory service.
Eureka Dashboard
Access the Eureka web dashboard at:- Registered service instances
- Instance status (UP, DOWN, STARTING)
- Instance metadata (hostname, IP, port)
- Lease information and last heartbeat
- General Eureka Server information
The dashboard is for development and monitoring. In production, consider securing it with Spring Security or disabling it entirely.
Dependencies
Frompom.xml:
Integration with Config Server
Eureka Server optionally integrates with the Config Server for centralized configuration:optional: prefix allows Eureka to start even if Config Server is unavailable, ensuring resilience during startup.
High Availability
For production deployments, consider:- Multiple Eureka Instances: Deploy 2-3 Eureka servers for redundancy
- Peer Replication: Configure Eureka servers to replicate registry data
- Load Balancing: Use a load balancer in front of Eureka instances
- Self-Preservation Mode: Eureka’s default protection against network partitions
Troubleshooting
Services Not Registering
- Check network connectivity to port 8761
- Verify
eureka.client.service-url.defaultZoneconfiguration - Review service logs for registration errors
- Ensure Eureka Server started before client services
Services Showing as DOWN
- Check service health endpoint (
/actuator/health) - Verify heartbeat configuration
- Review network latency between service and Eureka
- Check for self-preservation mode activation
Dashboard Not Accessible
- Verify server is running:
docker ps | grep eureka-server - Check port mapping:
8761:8761 - Ensure no firewall blocking port 8761
- Review Eureka Server logs for startup errors
Security Considerations
In production environments, secure Eureka Server with:
- Spring Security authentication
- HTTPS/TLS encryption
- Network-level access controls (security groups, firewalls)
- Actuator endpoint protection
Related Services
- API Gateway - Routes requests using Eureka service discovery
- Config Server - Provides centralized configuration to Eureka and all services