sgivu-discovery) is a Netflix Eureka server that provides service registry and discovery capabilities for the SGIVU microservices architecture.
Service Overview
Port
8761
Type
Eureka Server
Clients
All microservices
Database
None (in-memory)
Key Features
- Service registry for all SGIVU microservices
- Health monitoring and heartbeat management
- Service instance discovery
- Load balancing support
- Self-preservation mode for network partition tolerance
Configuration
Server Settings
Port 8761 is the standard Eureka server port and is used by all services by default.
Eureka Server Configuration
Configuration Breakdown
Configuration Breakdown
- hostname: The hostname used for Eureka server registration
- registerWithEureka: false: The Eureka server does not register itself
- fetchRegistry: false: The Eureka server does not fetch registry from other servers
- defaultZone: Points to itself for standalone operation
Standalone vs. Cluster Mode
The current configuration runs Eureka in standalone mode (single server).Standalone Mode (Current)
Standalone mode is suitable for development and small deployments. For production high availability, consider clustering multiple Eureka servers.
Cluster Mode (Future)
For production environments with multiple Eureka instances:Docker Networking
The
host.docker.internal hostname allows services running in Docker containers to communicate with the Eureka server.Service Registration
All microservices register with Eureka using this URL pattern:Environment-Specific Configuration
- Development
- Production
Development environment uses the same base configuration with no overrides:No special configuration needed for development.
Service Registry
Eureka maintains a registry of all services:| Service | Instance ID Pattern |
|---|---|
| sgivu-auth | hostname:sgivu-auth:random-value |
| sgivu-gateway | hostname:sgivu-gateway:random-value |
| sgivu-user | hostname:sgivu-user:random-value |
| sgivu-client | hostname:sgivu-client:random-value |
| sgivu-vehicle | hostname:sgivu-vehicle:random-value |
| sgivu-purchase-sale | hostname:sgivu-purchase-sale:random-value |
The random value in instance IDs allows multiple instances of the same service to run simultaneously.
Eureka Dashboard
The Eureka server provides a web dashboard for monitoring:- Registered service instances
- Instance status (UP, DOWN, OUT_OF_SERVICE)
- Renewal statistics
- General server information
Dashboard Features
Dashboard Features
- Instances currently registered: List of all registered services
- General Info: Server configuration and environment
- Instance Info: Detailed information about each instance
- Lease expiration: When each instance lease expires
- Renewal settings: Heartbeat intervals and timeouts
Health Monitoring
Eureka uses heartbeat mechanism for health monitoring:- Default renewal interval: 30 seconds
- Default eviction timeout: 90 seconds
- Self-preservation threshold: 85%
Service Discovery
Client services can discover other services using Eureka:Load Balancing
Eureka integrates with Spring Cloud LoadBalancer for client-side load balancing:- Round-robin distribution by default
- Automatic failover to healthy instances
- Zone-aware routing (if configured)
Required Environment Variables
The Discovery Service has minimal environment variable requirements:| Variable | Description | Default |
|---|---|---|
PORT | Eureka server port | 8761 |
All configuration is self-contained in the YAML files. No external dependencies required.
Networking Considerations
Docker Compose
In Docker Compose, services reference Eureka by service name:Kubernetes
In Kubernetes, use service DNS:High Availability Setup
For production deployments, consider running multiple Eureka instances:HA Configuration Example
HA Configuration Example
Eureka Instance 1:Eureka Instance 2:Eureka Instance 3:
Security Considerations
Securing Eureka
To add basic authentication:Troubleshooting
Services Not Registering
- Check network connectivity to port 8761
- Verify
EUREKA_URLenvironment variable - Check service logs for registration errors
- Verify Eureka server is running
Self-Preservation Mode
If you see “EMERGENCY! EUREKA MAY BE INCORRECTLY CLAIMING INSTANCES ARE UP”:- This is normal during development with frequent restarts
- Eureka enters self-preservation to prevent cascade failures
- Wait for services to stabilize or disable self-preservation in dev:
Configuration Files
sgivu-discovery.yml- Base configuration (used in all environments)sgivu-discovery-dev.yml- Empty (no overrides)sgivu-discovery-prod.yml- Empty (no overrides)
Related Services
All Services
Register with Eureka
Gateway
Uses Eureka for routing
Monitoring
Monitor service health