Scripts2026年7月3日·1 分钟阅读

rpcx — High-Performance Go RPC Framework for Microservices

rpcx is a Go RPC framework that supports multiple codecs, service discovery, and fault tolerance for building distributed microservice systems.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
rpcx Overview
直接安装命令
npx -y tokrepo@latest install 1a3aad40-767a-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

rpcx is a Go RPC framework inspired by Dubbo and Motan, designed for building distributed microservices. It provides service discovery, load balancing, fault tolerance, and multiple codec support while maintaining a simple API similar to the standard net/rpc package.

What rpcx Does

  • Provides high-performance RPC communication over TCP, HTTP, QUIC, and KCP
  • Supports multiple serialization codecs including JSON, Protobuf, MsgPack, and Thrift
  • Integrates with service registries like etcd, Consul, ZooKeeper, and mDNS
  • Offers client-side load balancing with round-robin, weighted, hash, and geographic strategies
  • Includes circuit breaker, rate limiting, and retry mechanisms for fault tolerance

Architecture Overview

rpcx follows a provider-consumer model. Servers register services with a discovery backend and listen for connections. Clients look up service addresses from the registry and send requests using a pluggable transport and codec. Middleware plugins intercept calls for logging, tracing, authentication, and metrics. The protocol uses a compact binary header for minimal overhead.

Self-Hosting & Configuration

  • Add to your Go module: go get github.com/smallnest/rpcx
  • Register services on the server with server.RegisterName
  • Configure service discovery by passing a registry plugin (etcd, Consul, etc.)
  • Set client-side options for timeout, retry count, and load balancing strategy
  • Enable TLS by providing certificate files in the server and client configuration

Key Features

  • Sub-millisecond latency in benchmarks with connection pooling and multiplexing
  • Bidirectional communication allowing servers to push notifications to clients
  • Group and version-based service routing for canary deployments
  • OpenTelemetry integration for distributed tracing and metrics
  • Gateway mode that exposes RPC services as HTTP/JSON endpoints

Comparison with Similar Tools

  • gRPC-Go — HTTP/2 and Protobuf only, broader language support, no built-in discovery
  • Go kit — toolkit approach requiring more boilerplate, more flexibility in transport
  • Kratos — Bilibili's framework, more opinionated, tighter integration with Kubernetes
  • Kitex — ByteDance's RPC framework, optimized for Thrift, strong internal ecosystem

FAQ

Q: How does rpcx compare to gRPC in performance? A: In benchmarks, rpcx matches or exceeds gRPC throughput for Go-to-Go communication due to its lighter protocol and connection multiplexing.

Q: Can I use Protobuf with rpcx? A: Yes. Set the codec to Protobuf on both client and server. rpcx supports multiple codecs simultaneously.

Q: Does rpcx support streaming? A: rpcx supports bidirectional communication. For full streaming semantics similar to gRPC streams, use the XClient broadcast or fork patterns.

Q: What service registries are supported? A: Built-in plugins for etcd, Consul, ZooKeeper, Nacos, and mDNS. Custom registries can be added by implementing the registry interface.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产