Convert Figma logo to code with AI

sofastack logosofa-rpc

SOFARPC is a high-performance, high-extensibility, production-level Java RPC framework.

3,813
1,169
3,813
38

Top Related Projects

40,335

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

11,358

The Java gRPC implementation. HTTP/2 based RPC

29,954

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

Integration with Netflix OSS components

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

10,310

Apache Thrift

Quick Overview

SOFA-RPC is a high-performance, high-extensibility Java RPC framework for building large-scale distributed systems. It provides a flexible, scalable, and efficient solution for service-to-service communication, supporting multiple protocols and load balancing strategies.

Pros

  • Supports multiple protocols (Bolt, REST, Dubbo, gRPC) for versatile integration
  • Provides efficient service discovery and load balancing mechanisms
  • Offers extensive extensibility through its plugin architecture
  • Includes built-in monitoring and tracing capabilities for better observability

Cons

  • Primarily focused on Java ecosystem, limiting cross-language support
  • Steeper learning curve compared to simpler RPC frameworks
  • Documentation and community resources are primarily in Chinese, which may be challenging for non-Chinese speakers
  • Relatively less adoption outside of China compared to other popular RPC frameworks

Code Examples

  1. Defining a service interface:
public interface HelloService {
    String sayHello(String name);
}
  1. Implementing the service:
public class HelloServiceImpl implements HelloService {
    @Override
    public String sayHello(String name) {
        return "Hello, " + name + "!";
    }
}
  1. Publishing a service:
ServerConfig serverConfig = new ServerConfig()
    .setProtocol("bolt")
    .setPort(12200);

ProviderConfig<HelloService> providerConfig = new ProviderConfig<HelloService>()
    .setInterfaceId(HelloService.class.getName())
    .setRef(new HelloServiceImpl())
    .setServer(serverConfig);

providerConfig.export();
  1. Consuming a service:
ConsumerConfig<HelloService> consumerConfig = new ConsumerConfig<HelloService>()
    .setInterfaceId(HelloService.class.getName())
    .setProtocol("bolt")
    .setDirectUrl("bolt://127.0.0.1:12200");

HelloService helloService = consumerConfig.refer();

String result = helloService.sayHello("SOFA");
System.out.println(result);

Getting Started

  1. Add SOFA-RPC dependency to your project:
<dependency>
    <groupId>com.alipay.sofa</groupId>
    <artifactId>sofa-rpc-all</artifactId>
    <version>5.8.0</version>
</dependency>
  1. Define and implement your service interface.
  2. Configure and publish your service using ProviderConfig.
  3. Configure and consume the service using ConsumerConfig.
  4. Start your application and enjoy SOFA-RPC's features!

For more detailed instructions, refer to the official SOFA-RPC documentation.

Competitor Comparisons

40,335

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

Pros of Dubbo

  • More mature and widely adopted in the industry
  • Extensive documentation and community support
  • Better integration with Spring Framework

Cons of Dubbo

  • Steeper learning curve for beginners
  • Less flexible configuration options compared to SOFA-RPC

Code Comparison

SOFA-RPC service definition:

@SofaService
public interface HelloService {
    String sayHello(String name);
}

Dubbo service definition:

@DubboService
public interface HelloService {
    String sayHello(String name);
}

Both frameworks use similar annotations for service definition, but SOFA-RPC uses @SofaService while Dubbo uses @DubboService.

SOFA-RPC offers more flexibility in terms of protocol support and allows easier switching between different protocols. Dubbo, on the other hand, provides better performance optimizations and a more comprehensive set of features out of the box.

In terms of configuration, SOFA-RPC tends to be more straightforward, especially for simpler use cases. Dubbo's configuration can be more complex but offers greater customization options for advanced scenarios.

Both frameworks support similar features like service discovery, load balancing, and fault tolerance. However, Dubbo's ecosystem is more extensive, with a wider range of plugins and integrations available.

11,358

The Java gRPC implementation. HTTP/2 based RPC

Pros of grpc-java

  • Widely adopted and supported by a large community
  • Excellent performance and efficiency for large-scale distributed systems
  • Strong support for streaming and bidirectional communication

Cons of grpc-java

  • Steeper learning curve, especially for developers new to gRPC
  • Requires more boilerplate code compared to simpler RPC frameworks

Code Comparison

grpc-java:

@Override
public void sayHello(HelloRequest req, StreamObserver<HelloReply> responseObserver) {
    HelloReply reply = HelloReply.newBuilder().setMessage("Hello " + req.getName()).build();
    responseObserver.onNext(reply);
    responseObserver.onCompleted();
}

sofa-rpc:

public String sayHello(String name) {
    return "Hello " + name;
}

Key Differences

  • grpc-java uses protocol buffers for serialization, while sofa-rpc supports multiple serialization protocols
  • grpc-java has built-in support for streaming, whereas sofa-rpc focuses on simpler RPC patterns
  • sofa-rpc is more lightweight and easier to integrate into existing Java applications
  • grpc-java offers stronger cross-platform compatibility due to its language-agnostic nature

Both frameworks have their strengths, with grpc-java excelling in performance and scalability for complex distributed systems, while sofa-rpc provides a simpler, more lightweight solution for Java-centric applications.

29,954

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

Pros of Nacos

  • More comprehensive service management: Nacos offers service discovery, configuration management, and dynamic DNS services in one platform
  • Better support for cloud-native environments: Designed for microservices and cloud-native architectures
  • Active development and community support: Regular updates and contributions from the Alibaba community

Cons of Nacos

  • Steeper learning curve: More complex setup and configuration compared to SOFA-RPC
  • Potentially overkill for simpler projects: May introduce unnecessary complexity for small-scale applications

Code Comparison

SOFA-RPC (Java):

ServerConfig serverConfig = new ServerConfig()
    .setProtocol("bolt")
    .setPort(12200);
ProviderConfig<HelloService> providerConfig = new ProviderConfig<HelloService>()
    .setInterfaceId(HelloService.class.getName())
    .setRef(new HelloServiceImpl())
    .setServer(serverConfig);
providerConfig.export();

Nacos (Java):

NamingService naming = NacosFactory.createNamingService(properties);
naming.registerInstance("service-name", "192.168.0.1", 8080);
naming.selectInstances("service-name", true);

Both repositories provide service registration and discovery capabilities, but Nacos offers a more comprehensive solution for service management in cloud-native environments. SOFA-RPC focuses primarily on RPC communication, while Nacos extends its functionality to include configuration management and dynamic DNS services. The code examples demonstrate the different approaches to service registration and discovery in each project.

Integration with Netflix OSS components

Pros of Spring Cloud Netflix

  • Extensive ecosystem with a wide range of components for microservices
  • Seamless integration with Spring Boot and other Spring projects
  • Large community support and extensive documentation

Cons of Spring Cloud Netflix

  • Heavier footprint compared to SOFA-RPC
  • Steeper learning curve for developers new to the Spring ecosystem
  • Some components (e.g., Hystrix) are reaching end-of-life

Code Comparison

Spring Cloud Netflix (Eureka Client):

@SpringBootApplication
@EnableEurekaClient
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

SOFA-RPC:

ServerConfig serverConfig = new ServerConfig()
    .setProtocol("bolt")
    .setPort(12200);
ProviderConfig<HelloService> providerConfig = new ProviderConfig<HelloService>()
    .setInterfaceId(HelloService.class.getName())
    .setRef(new HelloServiceImpl())
    .setServer(serverConfig);
providerConfig.export();

Spring Cloud Netflix offers a more annotation-driven approach, while SOFA-RPC provides a programmatic configuration. Spring Cloud Netflix integrates tightly with the Spring ecosystem, whereas SOFA-RPC offers a lightweight and flexible solution for RPC communication.

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

Pros of spring-cloud-alibaba

  • Comprehensive ecosystem integration with Alibaba Cloud services
  • Seamless compatibility with Spring Cloud framework
  • Robust support for microservices architecture and distributed systems

Cons of spring-cloud-alibaba

  • Steeper learning curve due to broader scope and feature set
  • Potential vendor lock-in with Alibaba Cloud services
  • Heavier resource consumption compared to lightweight RPC frameworks

Code Comparison

spring-cloud-alibaba:

@SpringBootApplication
@EnableDiscoveryClient
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

sofa-rpc:

ServerConfig serverConfig = new ServerConfig()
    .setProtocol("bolt")
    .setPort(12200);
ProviderConfig<HelloService> providerConfig = new ProviderConfig<HelloService>()
    .setInterfaceId(HelloService.class.getName())
    .setRef(new HelloServiceImpl())
    .setServer(serverConfig);
providerConfig.export();

Summary

spring-cloud-alibaba offers a comprehensive solution for building cloud-native applications with tight integration to Alibaba Cloud services and Spring Cloud compatibility. It excels in microservices architecture but may introduce complexity and potential vendor lock-in. sofa-rpc, on the other hand, provides a lightweight and flexible RPC framework with simpler configuration and lower resource overhead, making it suitable for scenarios where a focused RPC solution is preferred over a full-fledged cloud ecosystem.

10,310

Apache Thrift

Pros of Thrift

  • Multi-language support: Thrift supports a wide range of programming languages, making it versatile for cross-language development
  • Mature and well-established: As an Apache project, Thrift has a long history and a large community backing it
  • Efficient binary protocol: Thrift's compact binary protocol offers high performance serialization

Cons of Thrift

  • Steeper learning curve: Thrift requires understanding its IDL (Interface Definition Language) and code generation process
  • Less flexibility: Thrift's strict type system and generated code can be less flexible compared to SOFA-RPC's dynamic features
  • Limited built-in features: Thrift focuses primarily on serialization and RPC, while SOFA-RPC offers additional features like service discovery and load balancing

Code Comparison

Thrift IDL example:

service Calculator {
  i32 add(1:i32 num1, 2:i32 num2)
}

SOFA-RPC interface definition:

public interface CalculatorService {
    int add(int num1, int num2);
}

Both examples define a simple calculator service with an add method, but Thrift uses its IDL while SOFA-RPC uses standard Java interfaces. Thrift requires code generation from the IDL, whereas SOFA-RPC works directly with Java code.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

SOFARPC

Build Status Coverage Status License Maven Percentage of issues still open Open in CodeBlitz

Overview

SOFARPC is a high-performance, high-extensibility, production-level Java RPC framework. In Ant Financial, SOFARPC has been used for more than ten years and developing for five generations. SOFARPC is dedicated to simplify RPC calls between applications, and provide convenient, no code intrusion, stable, and efficient point-to-point remote service invocation solutions for applications. For user and developer easy to improve features, SOFARPC provides a wealth of model abstraction and extensible interfaces, including filter, routing, load balancing, and so on. At the same time, it provides a rich MicroService governance solution around the SOFARPC framework and its surrounding components.

SOFARPC Architecture

Features

  • No code intrusion, high-performance remote service call
  • Supports multiple service routing and load balancing policies
  • Supports multiple service registries
  • Supports multiple protocols
  • Supports multiple invoke type, such as synchronous, oneway, callback, generalized and more.
  • Support cluster failover, service warm-up, automatic fault tolerance
  • High extensibility for easy to improve features as needed

Related Projects

Requirements

Build-time requirement: JDK 8 or above and Maven 3.2.5 or above.

Runtime requirement: JDK 8 or above.

Documents

Contribution

How to Contributing

Contact Us

  • DingTalk Group

    DingTalk

License

SOFARPC is licensed under the Apache License 2.0, and SOFARPC uses some third-party components, you can view their open source license here NOTICE.