Overview
In a distributed system, the service registry records the addresses and metadata of service instances. Service consumers query the registry by service name to get the address and initiate calls.
In Silky's RPC framework, there are three main roles: RPC Server, RPC Client, and Registry.

- RPC Server registers its service routes in the Registry at startup and sends periodic heartbeats to report its liveness.
- RPC Client subscribes to services at startup, caches the returned node list in local memory, and establishes connections with RPC Servers.
- When RPC Server nodes change, the Registry syncs the change and RPC Clients refresh their local cache.
- The RPC Client selects an RPC Server from its local cache based on the load balancing algorithm.
Silky supports Zookeeper, Nacos, and Consul as the service registry.
Service Metadata
When a service provider registers with the registry, it writes service metadata consisting of:
- hostName: The name of the service provider host (NuGet package name)
- services: Array of application service information (service ID, name, protocol, entries, metadata)
- timeStamp: Timestamp of the last metadata update
- endpoints: Array of service instance endpoints (format differs by registry)
Example metadata registered with Zookeeper:
{
"hostName": "DemoHost",
"services": [
{
"id": "Demo.Application.Contracts.System.ISystemAppService",
"serviceName": "SystemAppService",
"serviceProtocol": 0,
"serviceEntries": [
{
"id": "Demo.Application.Contracts.System.ISystemAppService.GetInfo_Get",
"webApi": "api/system/demo/info",
"httpMethod": 0
}
]
}
],
"timeStamp": 1714000000,
"endpoints": [
{ "host": "192.168.1.10", "port": 2200, "processorTime": 0.5, "isHealth": true }
]
}
Zookeeper
Installation
<PackageReference Include="Silky.RegistryCenter.Zookeeper" Version="3.9.2" />
Configuration
registrycenter:
type: Zookeeper
connectionStrings: "127.0.0.1:2181"
sessionTimeout: 40000 # session timeout (ms)
connectionTimeout: 10000 # connection timeout (ms)
operatingTimeout: 8000 # operation timeout (ms)
routePath: /silky/services/routes
Silky uses Zookeeper's publish-subscribe model — changes are pushed to all clients in real time.
Nacos
Installation
<PackageReference Include="Silky.RegistryCenter.Nacos" Version="3.9.2" />
Configuration
registrycenter:
type: Nacos
nacos:
serverAddresses:
- "http://127.0.0.1:8848"
namespace: "silky"
groupName: "DEFAULT_GROUP"
username: "nacos"
password: "nacos"
Nacos uses push notifications for real-time service discovery.
Consul
Installation
<PackageReference Include="Silky.RegistryCenter.Consul" Version="3.9.2" />
Configuration
registrycenter:
type: Consul
consul:
url: "http://127.0.0.1:8500"
token: "" # ACL token (if configured)
heartbeatInterval: 5 # heartbeat interval (seconds)
deregisterCriticalServiceAfter: "1m"
Consul uses a polling model — Silky periodically pulls the latest service list.
Selecting a Registry
| Registry | Discovery Model | High Availability | Ecosystem |
|---|---|---|---|
| Zookeeper | Push (real-time) | High (ZAB consensus) | Widely used in Java ecosystem |
| Nacos | Push (real-time) | High | Strong in Alibaba/Spring Cloud ecosystem |
| Consul | Poll (periodic) | High (Raft consensus) | Rich built-in health checks and ACL |
Choose based on your team's familiarity. All three provide equivalent functionality in Silky.
