Standard Client Configuration
Most SGIVU services use this standard Eureka client configuration:Instance Configuration
Instance ID Pattern
Unique identifier for this service instance in Eureka. Uses a combination of hostname, application name, and random value to ensure uniqueness across deployments.
Why this pattern?
Why this pattern?
The instance ID pattern provides several benefits:
${spring.cloud.client.hostname}: Identifies the host/container${spring.application.name}: Identifies the service type${random.value}: Ensures uniqueness when multiple instances run on the same host
Hostname Override (Discovery Server Only)
The Discovery Server uses a specific hostname configuration:Override the hostname for Docker Desktop environments. Only used by the Discovery Server itself.
Client Configuration
Service URL
URL of the Eureka server where services register and discover each other. Supports the
EUREKA_URL environment variable for deployment flexibility.Container Default
http://sgivu-discovery:8761/eurekaUsed when services run in Docker networkEnvironment Override
${EUREKA_URL}Set via environment variable for different deploymentsEnvironment Variable
TheEUREKA_URL environment variable allows dynamic configuration:
Example: Kubernetes deployment
Example: Kubernetes deployment
Example: AWS ECS deployment
Example: AWS ECS deployment
Discovery Server Configuration
The Eureka Discovery Server itself has a special configuration:Server-Specific Settings
Controls whether the Discovery Server registers itself with Eureka. Set to
false for standalone Eureka servers.Controls whether the server fetches the registry from other Eureka servers. Set to
false for standalone deployments.Service Registration Examples
Auth Service
Gateway Service
Microservices (User, Client, Vehicle, Purchase-Sale)
All domain microservices follow the same pattern:Service Discovery in Action
Service Startup
When a service starts, it reads the
EUREKA_URL (or uses the default) and connects to the Discovery Server.Registration
The service registers itself with Eureka using its
instance-id and spring.application.name.Discovery
Other services query Eureka to find available instances by service name (e.g.,
sgivu-user).Troubleshooting
Service not appearing in Eureka
Service not appearing in Eureka
Check:
- Service is running and logs show successful Eureka registration
EUREKA_URLis correctly set and reachable from the service- Network connectivity between service and Discovery Server
- Firewall rules allow traffic on port 8761
- DNS resolution failure for
sgivu-discoveryhostname - Network isolation between containers
- Discovery Server not running
Service showing as DOWN in Eureka
Service showing as DOWN in Eureka
Check:
- Service health endpoint is responding:
GET /actuator/health - Heartbeat interval hasn’t timed out
- Service logs for exceptions
- Application failed to start properly
- Health check endpoint returning unhealthy status
- Network instability causing missed heartbeats
Multiple instances with same instance-id
Multiple instances with same instance-id
This shouldn’t happen with the standard configuration using
${random.value}. If it does:- Verify
${random.value}is being resolved - Check for manual overrides of
eureka.instance.instance-id - Ensure services aren’t being cloned with cached Spring context
Related Configuration
Spring Configuration
Application name and server port settings
Observability
Health checks and monitoring integration
Service Architecture
How Eureka fits into the overall architecture
Environment Variables
EUREKA_URL and other discovery-related variables