rubbo

Crates.iorubbo
lib.rsrubbo
version0.1.0
created_at2026-01-24 13:26:37.416845+00
updated_at2026-01-24 13:26:37.416845+00
descriptionRust implementation of Apache Dubbo 3. High-performance RPC framework with Triple protocol.
homepagehttps://github.com/huiyang233/rubbo
repositoryhttps://github.com/huiyang233/rubbo
max_upload_size
id2066677
size93,126
杨辉 (huiyang233)

documentation

README

English | δΈ­ζ–‡

Rubbo πŸ¦€πŸš€

Rubbo is a high-performance, Rust-based RPC framework designed to be fully compatible with the Dubbo 3.0 ecosystem. It leverages the Triple protocol (based on gRPC/HTTP2) and supports seamless interoperability with Java Dubbo applications using Nacos for service discovery.

Features

  • Triple Protocol: Fully compatible with Dubbo 3.0 Triple protocol.
  • Service Discovery: Built-in support for Nacos registry.
  • Macro Support: Easy-to-use attribute macros for defining services and references.
  • High Performance: Built on top of tokio and hyper for asynchronous I/O.
  • Interoperability: Works out-of-the-box with Java Dubbo providers and consumers.
  • Load Balancing: Pluggable load balancing strategies (default: RoundRobin).

Supported Protocols & Serialization

Category Type Description Feature Flag
Protocol Triple Based on HTTP/2 and gRPC, fully compatible with Dubbo 3.0. -
Serialization FastJSON Default text-based JSON serialization. fastjson (Default)
Serialization FastJSON2 High-performance binary JSONB format (Dubbo 3 default). fastjson2
Serialization Hessian2 Standard binary serialization. hessian2

Getting Started

Prerequisites

  • Rust (latest stable)
  • Nacos Server (running on 127.0.0.1:8848 or configurable)

Defining a Service

Define your service interface using the #[rubbo::service] macro:

#[rubbo::service]
trait HelloService {
    async fn say_hello(&self, name: String) -> String;
}

Implementing a Provider

Implement the service and start a provider:

use rubbo::{ProviderBuilder, Registry, Protocol, Serialize};

struct HelloServiceImpl;

#[rubbo::service_impl(group = "test_group", version = "1.0.0", name = "com.example.HelloService")]
impl HelloService for HelloServiceImpl {
    async fn say_hello(&self, name: String) -> String {
        format!("Hello, {}!", name)
    }
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    tracing_subscriber::fmt::init();

    rubbo::ProviderBuilder::new()
        .service(HelloServiceImpl)
        .application("rubbo-provider-example")
        .registry(Registry::Nacos("nacos://127.0.0.1:8848".to_string()))
        .protocol(Protocol::Triple)
        .serialization(Serialize::Fastjson2)
        .port(50051)
        .start()
        .await?;
    Ok(())
}

Implementing a Consumer

Create a consumer to invoke the service:

use rubbo::{ConsumerBuilder, Registry};

#[rubbo::reference(interface_name = "com.example.HelloService", version = "1.0.0", group = "test_group")]
trait HelloService {
    async fn say_hello(&self, name: String) -> String;
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    tracing_subscriber::fmt::init();

    let consumer = ConsumerBuilder::new()
        .application("rubbo-consumer-example")
        .registry(Registry::Nacos("nacos://127.0.0.1:8848".to_string()))
        .reference::<dyn HelloService>()
        .build()
        .await?;

    let service = consumer.reference::<dyn HelloService>().await?;
    let response = service.say_hello("World".to_string()).await?;
    println!("Response: {}", response);
    Ok(())
}

Benchmark

We provide a built-in benchmark tool to measure the performance of Rubbo.

Environment

  • OS: macOS
  • Protocol: Triple (HTTP/2)
  • Registry: Nacos (Local)
  • Serialization: FastJSON
  • Machine: Local Development Machine

Running the Benchmark

  1. Start Nacos Server (Ensure it's running on port 8848)
  2. Start the Benchmark Provider:
    cargo run --release --example benchmark_provider
    
  3. Run the Benchmark Consumer:
    BENCH_CONCURRENCY=50 BENCH_REQUESTS=20000 cargo run --release --example benchmark_consumer
    

Results

Metric Value
Concurrency 50 threads
Total Requests 20,000
QPS ~26,384
Avg Latency 1.88 ms
Success Rate 100%

Note: Results may vary based on hardware and network conditions.

License

MIT

Commit count: 6

cargo fmt