Overview

When services start or stop, their locations must be registered, updated, and removed from the Service Registry. There are two approaches to this: Self-registration, where the service registers itself, and 3rd Party Registration, where registration is handled by a third party. This page covers both.

Problem

Service instances must be registered in the Service Registry when they start, and deregistered when they stop. Otherwise the registry may contain stale entries pointing to instances that are no longer available — causing failed requests. How should registration be managed?

Solution

With Self-registration, when a service instance starts, it is responsible for registering its own location in the Service Registry. When it stops, it deregisters itself. The service also periodically sends heartbeats to the registry to renew its registration and signal that it is still healthy.

3rd Party Registration

As an alternative, 3rd Party Registration delegates the responsibility for registering, updating, and removing service instance locations to a third-party component — such as a deployment platform. In practice, deployment platforms like Docker and Kubernetes use the 3rd Party Registration approach: the platform detects when container instances start and stop and manages their registry entries automatically, removing this responsibility from the application developer.

Trade-offs

Self-registration benefits

  • Simple to implement — the service itself has the best knowledge of when it is ready
  • No dependency on an external registration component

Self-registration drawbacks

  • Couples the service to the Service Registry — changes to the registry API require changes in every service
  • Each service in every language/framework must implement the registration logic

When to Use

Apply Self-registration when:

  • You are not using a deployment platform that provides 3rd Party Registration
  • You want each service to control exactly when it considers itself ready

Prefer 3rd Party Registration when:

  • Using Docker, Kubernetes, or similar platforms — they handle registration automatically, removing the responsibility from developers and eliminating the coupling between services and the registry