Skip to content

Discovery Service configuration

Configure the Discovery Service and its components

Discovery Registry (Eureka)

Supported status

The Discovery Registry offers the extensive configuration available within the Spring Boot Eureka application.

Spring Boot: Service registration and discovery

Supported status values:

STARTING        Component is initializing
UP              Component is active
DOWN            Component is no longer active
OUT_OF_SERVICE  Component is active, but should not be queried
UNKNOWN         Client is unable to determine status

The Discovery Registry is driven by a startup script startDiscovery.sh in the application image. This lets you provide two environment values to help drive the configuration of the Discovery Registry.

JAVA_OPTS

Allows any valid Java options to be provided to the JVM and underlying application. They can include JVM configuration, such as memory allocations, and Discovery Registry (Spring Boot) system properties.

CUSTOM_CONFIG

By convention a basic configuration application.yml is in the application on the classpath. Otherwise, the default is application.yaml embedded in the image: a single-node configuration will be used.

The embedded application.yaml is shown below. It covers the basic configuration available. All values in it have defaults and can be overridden with system properties at runtime.

eureka:
  instance:
    hostname: localhost
    appname: kxinsights-eureka-cluster
  client:
    serviceUrl:
      defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka
    register-with-eureka: true
    fetch-registry: true
  server:
      enable-self-preservation: false

server:
  port: 8761

Configuration parameters

parameter default description
eureka.server.enableSelfPreservation true This describes the mechanism that stops evicting the instances when the heartbeats are below the expected threshold due to conditions such as a poor network partition, where the instances may still be up, but just can't be reached.
eureka.server.evictionIntervalTimerInMs 60000 The timer which checks for stale processes
eureka.server.renewalPercentThreshold 0.85 Based on this property, the server calculates the expected heartbeats per minute from all the registered clients – the default value is 0.85
eureka.server.responseCacheUpdateIntervalMs 30000 How often the server will update it's local cache of services
eureka.instance.hostname localhost Hostname of the running instance
eureka.instance.appname Name of the application name within a cluster. Used to group instances of an application
eureka.instance.preferIpAddress false In some cases, it's useful for Eureka to advertise IP address rather than hostnames
eureka.instance.leaseRenewalIntervalInSeconds 30 How often the instance will heartbeat
eureka.instance.leaseExpirationDurationInSeconds 90 How long before the instance should be evicted based on no heartbeats
eureka.client.registerWithEureka true Whether the Registry itself should register
eureka.client.fetchRegistry true Whether the Registry to keep a local cache
eureka.client.serviceUrl.defaultZone http://<host>:<port>/eureka Used for defining the distributed nodes within the Registry cluster
server.port 8761 Port the Discovery Registry will run on

You can set these parameters with JAVA_OPTS or through application.yaml.

JAVA_OPTS

Example: modify the application name and running port.

docker run -it --rm \
    --name=registry \
    -p 9000:9000 \
    -e JAVA_OPTS="-Deureka.instance.appname=CUSTOM_APP -Dserver.port=9000" \
    registry.dl.kx.com/kxi-eureka-discovery:1.0.0
Use JVM notation

Specify parameters using JVM notation. For example

eureka.instance.preferIpAddress

in JVM notation is

-Deureka.instance.preferIpAddress=false

application.yaml

Provide a custom application.yaml at runtime: mount the directory containing the file into the Docker container and set the environment variable CUSTOM_CONFIG.

docker run -it --rm \
    --name=registry \
    -p 8761:8761 \
    -v $(pwd):/data/config \
    -e "CUSTOM_CONFIG=/data/config/application.yaml" \
    registry.dl.kx.com/kxi-eureka-discovery:1.0.0

Discovery API Proxy

The proxy is configured through the JSON configuration.

"discovery": {
  "adaptor": "discEurekaAdaptor.q",
  "registry": "kxi-eureka-registry:8761",
  "callTimeoutSecs": 30,
  "heartbeatSecs": 30,
  "leaseExpirySecs": 90
}

The adaptor field specifies the backend registry to use.

Currently only discEurekaAdaptor.q is supported for the Eureka registry.

The remaining fields configure the Eureka adaptor.

registry         location of the Eureka registry service
callTimeoutSecs  registry call timeout: longer requests will be timed out
heartbeatSecs    frequency at which the client will heartbeat
leaseExpirySecs  period after which to time out client without heartbeats