How it works
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.
NoteThe 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 interaction diagram

Service registration process

The service registration process involves the following steps:
The publishing client sends the data to be published, `dataPub`, to a SessionServer.
When SessionServer accepts data from dataPub, it performs the following operations:
First, it writes the data to memory. This data is used for periodic consistency checks with the DataServer.
Then, it sends the `dataPub` data to a DataServer.
DataServer receives the dataPub data and performs the following operations:
DataServer writes data to memory by aggregating all data from SessionServer that is pending publication under a single dataInfoId.
It synchronizes data to replicas. The DataServer saves multiple replicas for each shard (three by default) based on consistent hashing and sharding.
It sends a data change event to all SessionServers. The event contains:
ID:
<dataInfoId>Version information:
<version>
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.
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:
The subscribing client sends a subscription request, `subReq`, to a SessionServer. The `subReq` includes a `dataInfoId`, which specifies the data to subscribe to.
After receiving the subscription request subReq, SessionServer performs the following operations:
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.
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.
The SessionServer retrieves the publishable data for the `dataInfoId` from the DataServer.
The SessionServer sends the retrieved data to the subscribing client.