ランキングに戻る

smallnest/rpcx

Gorpcx.io

Best microservices framework in Go, like alibaba Dubbo, but with more features, Scale easily. Try it. Test it. If you feel it's better, use it! 𝐉𝐚𝐯𝐚有𝐝𝐮𝐛𝐛𝐨, 𝐆𝐨𝐥𝐚𝐧𝐠有𝐫𝐩𝐜𝐱! build for cloud!

dubborpcgrpcservice-discoverymicroservicemicroservices
スター成長
スター
8.3k
フォーク
1.2k
週間成長
Issue
2
5k
2016年5月2019年9月2023年2月2026年7月
成果物Go Modulesgo get github.com/smallnest/rpcx
README
  • stable branch: v1.7.x
  • development branch: master

Official site: http://rpcx.io

License GoDoc github actions Go Report Card coveralls QQ3群

Notice: etcd

since rpcx 1.7.6, some plugins have been moved to the independent project:

Announce

Stable branch: v1.9.4

A tcpdump-like tool added: rpcxdump。 You can use it to debug communications between rpcx services and clients.

Cross-Languages

you can use other programming languages besides Go to access rpcx services.

  • rpcx-gateway: You can write clients in any programming languages to call rpcx services via rpcx-gateway
  • http invoke: you can use the same http requests to access rpcx gateway
  • Java Services/Clients: You can use rpcx-java to implement/access rpcx services via raw protocol.
  • rust rpcx: You can write rpcx services in rust by rpcx-rs

If you can write Go methods, you can also write rpc services. It is so easy to write rpc applications with rpcx.

Installation

install the basic features:

go get -v github.com/smallnest/rpcx/...

If you want to use quickcp registry, use those tags to go getgo build or go run. For example, if you want to use all features, you can:

go get -v -tags "quic kcp" github.com/smallnest/rpcx/...

tags:

  • quic: support quic transport
  • kcp: support kcp transport
  • rdma: support the experimental RDMA transport (built on gordma's rdmanet.Conn; requires libibverbs on Linux)

Which companies are using rpcx?

Features

rpcx is a RPC framework like Alibaba Dubbo and Weibo Motan.

rpcx is created for targets:

  1. Simple: easy to learn, easy to develop, easy to integrate and easy to deploy
  2. Performance: high performance (>= grpc-go)
  3. Cross-platform: support raw slice of bytes, JSON, Protobuf and MessagePack. Theoretically it can be used with java, php, python, c/c++, node.js, c# and other platforms
  4. Service discovery and service governance: support zookeeper, etcd and consul.

It contains below features

  • Support raw Go functions. There's no need to define proto files.
  • Pluggable. Features can be extended such as service discovery, tracing.
  • Support TCP, HTTP, QUIC and KCP
  • Support multiple codecs such as JSON, Protobuf, MessagePack and raw bytes.
  • Service discovery. Support peer2peer, configured peers, zookeeper, etcd, consul and mDNS.
  • Fault tolerance:Failover, Failfast, Failtry.
  • Load banlancing:support Random, RoundRobin, Consistent hashing, Weighted, network quality and Geography.
  • Support Compression.
  • Support passing metadata.
  • Support Authorization.
  • Support heartbeat and one-way request.
  • Other features: metrics, log, timeout, alias, circuit breaker.
  • Support bidirectional communication.
  • Support access via HTTP so you can write clients in any programming languages.
  • Support API gateway.
  • Support backup request, forking and broadcast.

rpcx uses a binary protocol and platform-independent, which means you can develop services in other languages such as Java, python, nodejs, and you can use other prorgramming languages to invoke services developed in Go.

There is a UI manager: rpcx-ui.

Performance

Test results show rpcx has better performance than other rpc framework except standard rpc lib.

The benchmark code is at rpcx-benchmark.

Listen to others, but test by yourself.

Test Environment

  • CPU: Intel(R) Xeon(R) CPU E5-2630 v3 @ 2.40GHz, 32 cores
  • Memory: 32G
  • Go: 1.9.0
  • OS: CentOS 7 / 3.10.0-229.el7.x86_64

Use

  • protobuf
  • the client and the server on the same server
  • 581 bytes payload
  • 500/2000/5000 concurrent clients
  • mock processing time: 0ms, 10ms and 30ms

Test Result

mock 0ms process time

ThroughputsMean LatencyP99 Latency

mock 10ms process time

ThroughputsMean LatencyP99 Latency

mock 30ms process time

ThroughputsMean LatencyP99 Latency

Examples

You can find all examples at rpcxio/rpcx-examples.

The below is a simple example.

Server

    // define example.Arith
    ……

    s := server.NewServer()
	s.RegisterName("Arith", new(example.Arith), "")
	s.Serve("tcp", addr)

Registering only selected methods

Register/RegisterName expose every suitable exported method of a struct as RPC. To expose only some of them, use RegisterWithMethods / RegisterNameWithMethods with a whitelist of method names:

    // Arith has exported methods Mul, Add and Sub, but only Mul/Add
    // should be callable remotely.
    s := server.NewServer()
	err := s.RegisterWithMethods(new(example.Arith), []string{"Mul", "Add"}, "")
	// err := s.RegisterNameWithMethods("Arith", new(example.Arith), []string{"Mul", "Add"}, "")
	s.Serve("tcp", addr)

Rules of the whitelist:

  • Whitelist only: methods not listed are not registered, so a newly added method stays private unless you opt it in.
  • Errors on bad names: a name that does not exist on the receiver, or that exists but is not a suitable RPC method, makes registration fail (the two cases give different error messages). Nothing is partially registered.
  • Empty whitelist errors: pass a non-empty list, or use Register / RegisterName to register all methods.

Client

    // prepare requests
    ……

    d, err := client.NewPeer2PeerDiscovery("tcp@"+addr, "")
	xclient := client.NewXClient("Arith", client.Failtry, client.RandomSelect, d, client.DefaultOption)
	defer xclient.Close()
	err = xclient.Call(context.Background(), "Mul", args, reply, nil)

Contributors

Contribute

see contributors.

Welcome to contribute:

  • submit issues or requirements
  • send PRs
  • write projects to use rpcx
  • write tutorials or articles to introduce rpcx

License

Apache License, Version 2.0

関連リポジトリ
doocs/advanced-java

😮 Core Interview Questions & Answers For Experienced Java(Backend) Developers | 互联网 Java 工程师进阶知识完全扫盲:涵盖高并发、分布式、高可用、微服务、海量数据处理等领域知识

JavaMavenCreative Commons Attribution Share Alike 4.0 Internationaljavadistributed-systems
java.doocs.org
79k19.2k
apache/dubbo

The java implementation of Apache Dubbo. An RPC and microservice framework.

JavaMavenApache License 2.0dubbodistributed-systems
dubbo.apache.org
41.5k26.4k
alibaba/nacos

an easy-to-use dynamic service discovery, configuration and service management platform for building AI cloud native applications.

JavaMavenApache License 2.0nacosdubbo
nacos.io
33.2k13.3k
alibaba/spring-cloud-alibaba

Spring Cloud Alibaba provides a one-stop solution for application development for the distributed solutions of Alibaba middleware.

JavaMavenApache License 2.0spring-cloudjava
sca.aliyun.com
29.1k8.5k
doocs/source-code-hunter

😱 从源码层面,剖析挖掘互联网行业主流技术的底层实现原理,为广大开发者 “提升技术深度” 提供便利。目前开放 Spring 全家桶,Mybatis、Netty、Dubbo 框架,及 Redis、Tomcat 中间件等

JavaMavenCreative Commons Attribution Share Alike 4.0 Internationalsourcecode-analysisspring
schunter.doocs.org
23.1k4.2k
yudaocode/SpringBoot-Labs

一个涵盖六个专栏:Spring Boot 2.X、Spring Cloud、Spring Cloud Alibaba、Dubbo、分布式消息队列、分布式事务的仓库。希望胖友小手一抖,右上角来个 Star,感恩 1024

JavaMavenspring-bootspring-cloud
20.1k6.2k
YunaiV/yudao-cloud

ruoyi-vue-pro 全新 Cloud 版本,优化重构所有功能。基于 Spring Cloud Alibaba + MyBatis Plus + Vue & Element 实现的后台管理系统 + 用户小程序,支持 RBAC 动态权限、多租户、数据权限、工作流、三方登录、支付、短信、商城、CRM、ERP、MES、IM、AI 大模型、IoT 物联网等功能。你的 ⭐️ Star ⭐️,是作者生发的动力!

JavaMavenMIT Licensedubbospringcloud
cloud.iocoder.cn
19.3k4.8k
shuzheng/zheng

基于Spring+SpringMVC+Mybatis分布式敏捷开发系统架构,提供整套公共微服务服务模块:集中权限管理(单点登录)、内容管理、支付中心、用户管理(支持第三方登录)、微信平台、存储系统、配置中心、日志分析、任务和通知等,支持服务治理、监控和追踪,努力为中小型企业打造全方位J2EE企业级开发解决方案。

JavaMavenMIT Licensespringspringmvc
16.7k7.2k
JeffLi1993/springboot-learning-example

spring boot 实践学习案例,是 spring boot 初学者及核心技术巩固的最佳实践。

JavaMavenApache License 2.0springbootredis
16.6k7.1k
dyc87112/SpringBoot-Learning

《Spring Boot基础教程》,2.x版本持续连载中!点击下方链接直达教程目录!

JavaMavenspring-bootspring-cloud
blog.didispace.com/spring-boot-learning-2x/
15.7k4.8k
aalansehaiyang/technology-talk

【大厂面试专栏】一份Java程序员需要的技术指南,这里有面试题、系统架构、职场锦囊、主流中间件等,让你成为更牛的自己!

javaspring
offercome.cn
14.7k3.8k
Exrick/xmall

基于SOA架构的分布式电商购物商城 前后端分离 前台商城:Vue全家桶 后台管理系统:Dubbo/SSM/Elasticsearch/Redis/MySQL/ActiveMQ/Shiro/Zookeeper等

JavaMavenGNU General Public License v3.0soadubbo
xmall.exrick.cn
7.2k2.5k