Backend Development 14 min read

How to Assemble a Service Registry: Requirements, Interfaces, and Technical Choices

This article explains how to assemble a production‑grade service registry by analyzing requirements, defining registration/discovery interfaces, comparing push and health‑check mechanisms, selecting long‑connection technologies, and choosing data‑storage and high‑availability strategies, all illustrated with JSON examples and design guidelines.

Wukong Talks Architecture
Wukong Talks Architecture
Wukong Talks Architecture
How to Assemble a Service Registry: Requirements, Interfaces, and Technical Choices

The author, Wukong, introduces the concept of assembling a service registry instead of building one from scratch, emphasizing reuse of existing components and practical learning.

Requirement Analysis

The registry must support three core capabilities: registration, discovery, and high availability. Three roles are defined: Provider (service provider), Consumer (service consumer), and Registry (the central store of service metadata).

Interface Definition

Three essential APIs are described: register (add a service), unregister (remove a service), and subscribe (consumer subscribes to services). The article discusses required fields, serialization format (JSON), and transport protocols.

Example JSON payloads are provided for service registration, subscription, and discovery:

{
  "application":"provider_test", // application name
  "protocol":"http", // protocol
  "addr":"127.0.0.1:8080", // provider address
  "meta":{
    "cluster":"small",
    "idc":"shanghai",
    "tag":"read"
  }
}
{
    "subscribes":[
        {
            "provider":"test_provider1", // subscribed application
            "protocol":"http",
            "meta":{
                "cluster":"small",
                "idc":"shanghai",
                "tag":"read"
            }
        },
        {
            "provider":"test_provider2",
            "protocol":"http",
            "meta":{
                "cluster":"small",
                "tag":"read"
            }
        }
    ]
}
{
    "version":"23des4f",
    "endpoints":[
        {
            "application":"provider_test",
            "protocol":"http",
            "addr":"127.0.0.1:8080",
            "meta":{
                "cluster":"small",
                "idc":"shanghai",
                "tag":"read"
            }
        },
        {
            "application":"provider_test",
            "protocol":"http",
            "addr":"127.0.0.2:8080",
            "meta":{
                "cluster":"small",
                "idc":"shanghai",
                "tag":"read"
            }
        }
    ]
}

Change Push & Service Health Check

The article compares four push mechanisms—periodic polling, long polling, UDP push, and TCP long‑connection push—evaluating implementation difficulty, real‑time performance, and resource consumption. It recommends discarding simple polling for larger systems.

Health‑check strategies are examined; the author favors registry‑initiated probing and provider‑registry session keep‑alive, noting that long‑connection solutions can address both push and health‑check needs.

Long‑Connection Technology Selection

Four networking libraries are compared (gRPC, Rsocket, Netty, Mina). gRPC is preferred for its strong community, multi‑language support, and stream‑based error handling.

Data Storage

Two storage models are discussed: using external components (MySQL, Redis) versus internal storage within the registry. Consistency models (Raft CP vs. AP) are explained, highlighting the trade‑off between strong consistency and availability.

High Availability

High‑availability considerations permeate the design, requiring failure‑aware architecture, data replication, and caching of service lists to tolerate node failures.

Summary

Assembling a production‑ready service registry involves step‑by‑step decisions from requirement analysis to technology selection, resulting in a clear blueprint that can be implemented with code.

backend architectureHigh Availabilityservice discoverySerializationLong ConnectionService Registryhealth check
Wukong Talks Architecture
Written by

Wukong Talks Architecture

Explaining distributed systems and architecture through stories. Author of the "JVM Performance Tuning in Practice" column, open-source author of "Spring Cloud in Practice PassJava", and independently developed a PMP practice quiz mini-program.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.