Overview
sgivu-discovery is the service discovery server (Eureka Server) for the SGIVU ecosystem. It registers and displays microservice instances, enables service name resolution, and serves as the central source for simple load balancing between services.
Technologies
- Java: 21
- Spring Boot: 3.5.8
- Spring Cloud Netflix Eureka Server: Service registry
- Spring Cloud Config: Client for centralized configuration
- Spring Boot Devtools: Hot reload during development
Port Configuration
- Default Port: 8761
- Dashboard:
http://localhost:8761/
Prerequisites
- JDK 21
- Maven 3.9+
- Docker & docker-compose
- Recommended: Launch full stack with
infra/compose/sgivu-docker-compose/docker-compose.dev.ymlincludingsgivu-config
Endpoints
Eureka dashboard showing all registered applications and their instances
REST API listing all registered applications
Information about specific application and its instances
Detailed information about specific instance
Service health status (if Actuator is enabled)
Running the Service
Development with Docker Compose
sgivu-config (native mode) and sgivu-discovery along with other services.
Local Execution
Docker Build
Dashboard UI
Access the Eureka dashboard athttp://localhost:8761/:
Dashboard displays:
- System status and environment information
- Registered instances per application
- Instance status (UP, DOWN, OUT_OF_SERVICE)
- Renewal threshold and last renewal time
- General info about replicas (if configured)
Client Configuration
Microservices register with Eureka using this configuration:Ensure each service has a unique
spring.application.name - this is used as the service identifier in Eureka.Service Registration Flow
- Startup: Service starts and reads Eureka configuration
- Registration: Service sends registration request to Eureka server
- Heartbeat: Service sends renewals every 30 seconds (default)
- Discovery: Other services fetch registry to locate service instances
- Deregistration: Service unregisters on graceful shutdown
Load Balancing
Eureka enables client-side load balancing:High Availability
Standalone Mode (Development)
Cluster Mode (Production)
Multiple Eureka instances register with each other:For production deployments, run at least 2 Eureka instances for high availability.
Security
Network Security
- Eureka server should be accessible only within private network
- Use VPC/security groups to restrict access in cloud deployments
- Consider adding Spring Security for authentication if exposing dashboard
Client Authentication
Ensure Eureka clients:- Have correct
defaultZoneconfiguration - Use unique
spring.application.nameper service - Register with appropriate metadata for routing
Observability
Service Monitoring
Via Dashboard:- Monitor registered instances count
- Check instance status (UP/DOWN)
- Review last heartbeat times
- Verify renewal threshold
Health Checks
Distributed Tracing
Eureka server doesn’t include tracing dependencies by default. Enable Micrometer/Zipkin in other services and review registration status in Eureka dashboard.
Testing
- Simulate instance registration
- Verify visibility in
/eureka/appsendpoint - Test heartbeat and expiration behavior
- Validate service discovery by name
Instance Metadata
Clients can add custom metadata:Self-Preservation Mode
Eureka enters self-preservation when too many instances fail to send heartbeats: Behavior:- Eureka stops evicting instances
- Dashboard shows warning message
- Prevents network partition issues
Troubleshooting
No services appearing in dashboard
No services appearing in dashboard
Symptoms: Eureka dashboard shows no registered applicationsSolutions:
- Verify clients have
eureka.client.service-url.defaultZoneset tohttp://sgivu-discovery:8761/eureka/ - Check
eureka.client.register-with-eureka: truein client config - Ensure clients can reach Eureka server (network connectivity)
- Review client logs for registration errors
- Verify Docker network if using containers
Network connectivity errors
Network connectivity errors
Symptoms: Services can’t connect to Eureka serverSolutions:
- Check Docker networks configuration
- Verify
sgivu-configis accessible and returning correct Eureka URL - Ensure port 8761 is not blocked by firewall
- Test connectivity:
curl http://sgivu-discovery:8761/eureka/apps
Port already in use
Port already in use
Symptoms: Eureka fails to start with “Address already in use” errorSolutions:
- Check if another process is using port 8761:
lsof -i :8761 - Kill existing process or change Eureka port
- Verify Docker isn’t running duplicate Eureka containers
Services not discovering each other
Services not discovering each other
Symptoms: Service-to-service calls fail with “no such host” or 404Solutions:
- Verify both services are registered in Eureka dashboard
- Check
spring.application.namematches the name used in URLs - Ensure consumers have
eureka.client.fetch-registry: true - Verify
@LoadBalancedannotation on RestTemplate/WebClient - Wait 30-60 seconds after registration for cache refresh
Instances stuck in DOWN state
Instances stuck in DOWN state
Symptoms: Instances show as DOWN despite being healthySolutions:
- Check instance health endpoint is accessible
- Verify
eureka.instance.prefer-ip-addresssetting - Review heartbeat configuration (renewal interval)
- Check for network issues between instance and Eureka
- Force instance removal and re-registration
Environment Variables
| Variable | Description | Default |
|---|---|---|
PORT | Server port | 8761 |
EUREKA_URL | Eureka server URL (for clients) | http://localhost:8761/eureka/ |
SPRING_APPLICATION_NAME | Application name | sgivu-discovery |
Configuration Reference
Server Configuration
Client Configuration
Best Practices
Unique Names
Use unique
spring.application.name for each serviceHA Setup
Run multiple Eureka instances in production
Health Checks
Implement custom health indicators for accurate status
Metadata
Use metadata for routing and filtering instances
Related Services
Config Server
Centralized configuration including Eureka URLs
Gateway
Uses Eureka for routing to downstream services
All Services
All services register with Eureka