Use Unix sockets for gRPC in weed server mode (#8858)
* Use Unix sockets for gRPC between co-located services in weed server Extends the Unix socket gRPC optimization (added for mini mode in #8856) to `weed server`. Registers Unix socket paths for each service's gRPC port before startup, so co-located services (master, volume, filer, S3) communicate via Unix sockets instead of TCP loopback. Only services actually started in this process get registered. The gRPC port is resolved early (port + 10000 if unset) so the socket path is known before any service dials another. * Refactor gRPC Unix socket registration into a data-driven loop
This commit is contained in:
@@ -330,6 +330,28 @@ func runServer(cmd *Command, args []string) bool {
|
||||
}
|
||||
filerOptions.defaultLevelDbDirectory = masterOptions.metaFolder
|
||||
|
||||
// Register Unix socket paths for gRPC services running in this process
|
||||
// so local inter-service communication uses Unix sockets instead of TCP.
|
||||
// Resolve gRPC ports early (same calculation each service does internally).
|
||||
for _, svc := range []struct {
|
||||
starting *bool
|
||||
portGrpc *int
|
||||
port *int
|
||||
name string
|
||||
}{
|
||||
{isStartingMasterServer, masterOptions.portGrpc, masterOptions.port, "master"},
|
||||
{isStartingVolumeServer, serverOptions.v.portGrpc, serverOptions.v.port, "volume"},
|
||||
{isStartingFiler, filerOptions.portGrpc, filerOptions.port, "filer"},
|
||||
{isStartingS3, s3Options.portGrpc, s3Options.port, "s3"},
|
||||
} {
|
||||
if *svc.starting {
|
||||
if *svc.portGrpc == 0 {
|
||||
*svc.portGrpc = 10000 + *svc.port
|
||||
}
|
||||
pb.RegisterLocalGrpcSocket(*svc.portGrpc, fmt.Sprintf("/tmp/seaweedfs-%s-grpc-%d.sock", svc.name, *svc.portGrpc))
|
||||
}
|
||||
}
|
||||
|
||||
serverWhiteList := util.StringSplit(*serverWhiteListOption, ",")
|
||||
|
||||
if *isStartingFiler {
|
||||
|
||||
Reference in New Issue
Block a user