Simple Service Discovery

Published on:

When app a, b and c need to know about each other . . .

One approach is a deployment system with config files where you enter the location of each of the apps. This works ok unless things change a lot or you have lots of apps that need to know about each other.

The slam dunk is to not configure anything. When you deploy your app it tells the service discovery system about itself, and the service discovery system takes care of letting other apps know what they need to know.

How does this work in practice?

We deploy app a. It tells the service discovery system it's at The service discovery system sees that app a's info has changed. It updates the config files of the other apps and tells them their config files have changed. The service discovery system could update environment variables as well.

With this approach your applications don't know anything about the service discovery system. They just need a way to be notified about config changes. Or you could just restart the app whenever there's a change.

This approach can be used for anything else apps need to know about each other, feature flags, etc.

Consul along with consul-template and envconsul allow you to do all this fairly simply.