How it works

Updated at:

SOFARegistry is a service registry. This topic describes the architecture and core processes of SOFARegistry.

SOFARegistry components

SOFARegistry is a service registry that consists of four components, each with a specific role.

  • Client: Provides the APIs that applications use to connect to the service registry. A client can be a publisher or a subscriber.

  • SessionServer: Establishes connections with clients and acts as an intermediary layer that forwards published data to the DataServer for storage.

  • DataServer: Stores the data published by clients. It supports multi-replica storage to ensure high availability (HA) and can handle many clients.

  • MetaServer: Maintains a consistent list of cluster members to ensure HA and consistency.

    Note

    The purposes of these three roles are as follows:

    • SessionServer and DataServer are separate components. This design overcomes bottlenecks in both connection count and storage capacity.

    • MetaServer simplifies operations and maintenance (O&M). Because the service registry is stateful, a dedicated component is required to manage metadata. Using MetaServer for this task eliminates the need for a third-party component. MetaServer is aware of the status of sessions and data, which means the SessionServer and DataServer components do not require self-perception capabilities. This results in a clearer architecture.

SOFARegistry architecture

SOFARegistry 架构图

SOFARegistry interaction diagram

交互图

Service registration process

单次服务注册

The service registration process involves the following steps:

  1. The publishing client sends the data to be published, `dataPub`, to a SessionServer.

  2. When SessionServer accepts data from dataPub, it performs the following operations:

    1. First, it writes the data to memory. This data is used for periodic consistency checks with the DataServer.

    2. Then, it sends the `dataPub` data to a DataServer.

  3. DataServer receives the dataPub data and performs the following operations:

    1. DataServer writes data to memory by aggregating all data from SessionServer that is pending publication under a single dataInfoId.

    2. It synchronizes data to replicas. The DataServer saves multiple replicas for each shard (three by default) based on consistent hashing and sharding.

    3. It sends a data change event to all SessionServers. The event contains:

      • ID: <dataInfoId>

      • Version information: <version>

  4. The SessionServer receives the change event notification. It compares the version of the `dataInfoId` in its memory with the version from the notification. If its local version is older, the SessionServer requests the latest data for that `dataInfoId` from the DataServer.

  5. The SessionServer retrieves the publishable data for the `dataInfoId` and pushes it to the corresponding subscribing clients. The subscribing clients then receive the latest list of `dataPub` data.

Service subscription process

单次服务订阅

The service subscription process involves the following steps:

  1. The subscribing client sends a subscription request, `subReq`, to a SessionServer. The `subReq` includes a `dataInfoId`, which specifies the data to subscribe to.

  2. After receiving the subscription request subReq, SessionServer performs the following operations:

    1. First, it writes the `subReq` to memory. The SessionServer stores all received `subReq` data in memory, which allows it to push data changes to subscribers.

    2. Then, it tries to retrieve the publishable data for the `dataInfoId` from its cache. The next action depends on whether the data is in the cache:

      • If not, it requests the data from a DataServer.

      • If so, it returns the data directly.

  3. The SessionServer retrieves the publishable data for the `dataInfoId` from the DataServer.

  4. The SessionServer sends the retrieved data to the subscribing client.