Me.
Me.

Reputation: 1

Microservices: how to deal with service self-registration?

I've recently been working on a side-project where I use the microservice architecture. One of the main problems with this architecture is that multiple core microservices can be launched any time and they need to be available as soon as they're runnning.

So I found a nice quick article on this website http://microservices.io/patterns/self-registration.html but this only brings up the question, how do microservices register themselves on the service registry?

TL;DR

I guess the underlying question really what is the proper way of implementing service registration?

Thanks !

Upvotes: 0

Views: 506

Answers (1)

Robin Green
Robin Green

Reputation: 33063

That would depend on what system you were using for service registration. For service self-registration I would suggest Consul might be a good option. You would do the following:

  1. Set up a Consul cluster with a consul client on each of your machines running a microservice, as covered in the Consul documentation.
  2. In each microservice, open a HTTP connection to the Consul client running on localhost on the standard Consul HTTP client port (8500).
  3. The microservice would self-register with the local Consul using the HTTP connection.
  4. The microservice would discover the location of other services using either the same HTTP access to Consul, or using its built-in DNS server. Obviously there might be a bootstrapping problem here if you have service A that depends on service B and service B also depends on service A - in which case, you would need to implement some wait-and-retry logic.

Upvotes: 1

Related Questions