Nomad Service Discovery SDK Client?

I have been able to run first service on Nomad without requiring Consul. Is there any way to get service endpoint from my application? I think redis would be a good example.

  1. We start redis 3 instances
  2. Our app would start and lookup from Nomad using service discovery where redis instance is
  3. If the redis instance dies then our app should be able fetch updated endpoint and continue.

So far I just found option to provide service details using ENV variables with templates - but that is static at app boot time. I’d have to kill the container and restart it I guess.

I found there is an API to query. But how do we discover reliably endpoint (IP) which to query? Our goal of using Nomad was simplicity. I think there should be easy case to setup and run public facing reliable web services.

Hi @vladaman, thanks for trying out Nomad native service discovery!

Currently there are 2 ways to discover services:

  1. Use the template block to generate configuration that is consumed by your app
  2. Use the Nomad API directly from your app

With the template block, it is possible to set change_mode to have your application receive a signal like SIGHUP, which can then trigger a config reload instead of having to restart the task. This only works of course if your app can do live config reloading.

But how do we discover reliably endpoint (IP) which to query?

The API actually does support simple load balancing, which may help here. The choose parameter when requesting instances of a service causes Nomad to use consistent hashing to select instance(s) of the requested to return. It will always return the same instance(s) unless services are added or removed, in which case there is only a 1/N chance your service is assigned a new instance. The docs aren’t clear, but the form should be


This simple load balancing is also available via the template block, by using 3 parameters in the nomadService function