dubbo
The java implementation of Apache Dubbo. An RPC and microservice framework.
Top Related Projects
Support for using OpenFeign in Spring Cloud apps
The Java gRPC implementation. HTTP/2 based RPC
Hystrix is a latency and fault tolerance library designed to isolate points of access to remote systems, services and 3rd party libraries, stop cascading failure and enable resilience in complex distributed systems where failure is inevitable.
A powerful flow control component enabling reliability, resilience and monitoring for microservices. (面向云原生微服务的高可用流控防护组件)
Tars is a high-performance RPC framework based on name service and Tars protocol, also integrated administration platform, and implemented hosting-service via flexible schedule.
Quick Overview
Apache Dubbo is a high-performance, lightweight, and open-source Java RPC (Remote Procedure Call) framework. It is designed to provide a simple yet effective way to build scalable and reliable distributed applications, making it a popular choice for microservices architecture.
Pros
- High Performance: Dubbo is known for its efficient and low-latency RPC communication, making it suitable for high-throughput applications.
- Scalability: Dubbo's service discovery and load balancing features allow for easy scaling of distributed systems.
- Flexibility: Dubbo supports multiple protocols (such as Dubbo, HTTP, and Thrift) and serialization formats (such as Hessian, JSON, and Protobuf), providing flexibility in integration with other systems.
- Reliability: Dubbo includes features like failover, failback, and circuit breaker to ensure reliable and fault-tolerant service invocations.
Cons
- Java-centric: Dubbo is primarily designed for Java-based applications, which may limit its adoption in polyglot environments.
- Steep Learning Curve: Dubbo has a relatively complex configuration and setup process, which can be challenging for developers new to the framework.
- Limited Documentation: While Dubbo has a growing community, the documentation and resources available may not be as comprehensive as some other popular RPC frameworks.
- Vendor Lock-in: Dubbo is an Apache project, but it was originally developed by Alibaba, which may raise concerns about vendor lock-in for some users.
Code Examples
Here are a few code examples demonstrating the usage of Dubbo:
Defining a Dubbo Service Interface
public interface GreetingService {
String sayHello(String name);
}
Implementing a Dubbo Service Provider
@Service(version = "1.0.0")
public class GreetingServiceImpl implements GreetingService {
@Override
public String sayHello(String name) {
return "Hello, " + name + "!";
}
}
Consuming a Dubbo Service
@Reference(version = "1.0.0")
private GreetingService greetingService;
public void greet(String name) {
String greeting = greetingService.sayHello(name);
System.out.println(greeting);
}
Configuring Dubbo in Spring Boot
dubbo:
application:
name: dubbo-demo-application
registry:
address: zookeeper://127.0.0.1:2181
protocol:
name: dubbo
port: 20880
Getting Started
To get started with Dubbo, follow these steps:
-
Install Dependencies: Ensure you have Java 8 or higher installed on your system.
-
Set up a Service Registry: Dubbo requires a service registry, such as Zookeeper or Nacos, to handle service discovery and coordination. Follow the instructions for your chosen registry to set it up.
-
Create a Dubbo Service Provider: Define your service interface and implement the service logic. Annotate the implementation class with
@Service
and configure the Dubbo properties. -
Create a Dubbo Service Consumer: Inject the service interface into your consumer class using the
@Reference
annotation. Dubbo will handle the RPC invocation and service discovery. -
Configure Dubbo: In your Spring Boot application, create a
dubbo.properties
orapplication.yml
file to configure Dubbo, such as the application name, registry address, and protocol settings. -
Start the Application: Run your Dubbo service provider and consumer applications. Dubbo will automatically handle the service registration, discovery, and RPC communication.
For more detailed instructions and advanced configurations, refer to the Dubbo documentation.
Competitor Comparisons
Support for using OpenFeign in Spring Cloud apps
Pros of Spring Cloud OpenFeign
- Simplicity: Spring Cloud OpenFeign provides a simple and straightforward way to create HTTP clients for interacting with RESTful services, reducing boilerplate code.
- Integration with Spring Ecosystem: As part of the Spring Cloud ecosystem, OpenFeign integrates seamlessly with other Spring projects, making it a natural choice for Spring-based applications.
- Declarative Approach: OpenFeign uses a declarative approach to defining HTTP clients, which can make the code more readable and maintainable.
Cons of Spring Cloud OpenFeign
- Limited to Spring Ecosystem: OpenFeign is primarily designed for use within the Spring ecosystem, which may limit its adoption in non-Spring-based projects.
- Dependency on Spring Cloud: OpenFeign is a part of the Spring Cloud project, which means that it may have a larger dependency footprint compared to a standalone library.
- Potential Performance Overhead: The abstraction and integration with the Spring ecosystem may introduce some performance overhead compared to a more lightweight HTTP client library.
Code Comparison
Apache Dubbo
@Service
public class GreetingServiceImpl implements GreetingService {
@Override
public String sayHello(String name) {
return "Hello, " + name + "!";
}
}
Spring Cloud OpenFeign
@FeignClient(name = "greeting-service")
public interface GreetingService {
@GetMapping("/greeting/{name}")
String sayHello(@PathVariable("name") String name);
}
In the Apache Dubbo example, the service implementation is defined using the @Service
annotation. In the Spring Cloud OpenFeign example, the service interface is defined using the @FeignClient
annotation, and the method is defined using the @GetMapping
annotation.
The Java gRPC implementation. HTTP/2 based RPC
Pros of grpc/grpc-java
- Language Agnostic: gRPC supports a wide range of programming languages, making it easier to build distributed systems with components written in different languages.
- Efficient Data Serialization: gRPC uses Protocol Buffers, a highly efficient binary serialization format, which can significantly reduce network bandwidth and improve performance.
- Streaming Support: gRPC provides first-class support for bidirectional streaming, allowing for more efficient communication patterns in certain use cases.
Cons of grpc/grpc-java
- Complexity: Setting up and configuring gRPC can be more complex compared to simpler RPC frameworks like Dubbo, especially for smaller projects.
- Learning Curve: Developers may need to invest more time in learning the gRPC ecosystem and its various concepts, such as service definitions, stubs, and interceptors.
Code Comparison
Dubbo:
@Service
public class GreetingServiceImpl implements GreetingService {
@Override
public String sayHello(String name) {
return "Hello, " + name + "!";
}
}
gRPC-Java:
@Override
public void sayHello(HelloRequest request,
StreamObserver<HelloResponse> responseObserver) {
HelloResponse response = HelloResponse.newBuilder()
.setMessage("Hello, " + request.getName() + "!")
.build();
responseObserver.onNext(response);
responseObserver.onCompleted();
}
Hystrix is a latency and fault tolerance library designed to isolate points of access to remote systems, services and 3rd party libraries, stop cascading failure and enable resilience in complex distributed systems where failure is inevitable.
Pros of Hystrix
- Hystrix provides a comprehensive set of features for implementing the Circuit Breaker pattern, which helps to improve the resilience and fault tolerance of distributed systems.
- Hystrix offers a rich set of metrics and monitoring capabilities, making it easier to understand the behavior and performance of your application.
- Hystrix supports a wide range of programming languages, including Java, Scala, and others, making it a versatile choice for various development environments.
Cons of Hystrix
- Hystrix has a relatively steep learning curve, especially for developers who are new to the concept of the Circuit Breaker pattern.
- Hystrix can add some overhead to your application, as it requires additional processing and resource usage to implement the Circuit Breaker functionality.
- Hystrix is primarily focused on the Circuit Breaker pattern and may not provide the same level of functionality as a more comprehensive service mesh or service discovery solution.
Code Comparison
Dubbo:
public class GreetingService {
public String sayHello(String name) {
return "Hello, " + name + "!";
}
}
Hystrix:
public class GreetingCommand extends HystrixCommand<String> {
private final String name;
public GreetingCommand(String name) {
super(HystrixCommandGroupKey.Factory.asKey("GreetingGroup"));
this.name = name;
}
@Override
protected String run() {
return "Hello, " + name + "!";
}
}
A powerful flow control component enabling reliability, resilience and monitoring for microservices. (面向云原生微服务的高可用流控防护组件)
Pros of Sentinel
- Sentinel provides a comprehensive set of features for service flow control, including rate limiting, circuit breaking, and load balancing.
- Sentinel has a user-friendly dashboard for monitoring and managing the system's health.
- Sentinel supports a wide range of programming languages, including Java, Go, and Node.js.
Cons of Sentinel
- Sentinel has a steeper learning curve compared to Dubbo, as it requires more configuration and setup.
- Sentinel's documentation may not be as comprehensive as Dubbo's, making it more challenging for new users to get started.
- Sentinel's performance may not be as optimized as Dubbo's, especially for high-throughput applications.
Code Comparison
Dubbo:
@Service(version = "1.0.0")
public class HelloServiceImpl implements HelloService {
@Override
public String sayHello(String name) {
return "Hello, " + name + "!";
}
}
Sentinel:
@RestController
public class HelloController {
@SentinelResource("sayHello")
@GetMapping("/hello")
public String sayHello(@RequestParam String name) {
return "Hello, " + name + "!";
}
}
Tars is a high-performance RPC framework based on name service and Tars protocol, also integrated administration platform, and implemented hosting-service via flexible schedule.
Pros of Tars
- Tars provides a more comprehensive set of features, including support for multiple programming languages (C++, Java, Node.js, PHP, Python, and Go) and a web-based management console.
- Tars has a more active community, with a larger number of contributors and more frequent updates.
- Tars is designed to be more scalable and fault-tolerant, with features like load balancing and service discovery.
Cons of Tars
- Tars has a steeper learning curve compared to Dubbo, especially for developers who are more familiar with the Java ecosystem.
- Tars has a smaller ecosystem of third-party libraries and tools compared to Dubbo, which has a larger and more established community.
- Tars may have less widespread adoption and recognition compared to Dubbo, which is a more well-known and widely-used framework.
Code Comparison
Dubbo:
public interface GreetingService {
String sayHello(String name);
}
public class GreetingServiceImpl implements GreetingService {
@Override
public String sayHello(String name) {
return "Hello, " + name + "!";
}
}
Tars:
class GreetingServantImp : public GreetingServant {
public:
virtual std::string sayHello(const std::string& name) {
return "Hello, " + name + "!";
}
};
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Apache Dubbo Project
Apache Dubbo is a high-performance, Java-based open-source RPC framework. Please visit the official site for the quick start guide and documentation, as well as the wiki for news, FAQ, and release notes.
We are now collecting Dubbo user info to help us to improve Dubbo further. Kindly support us by providing your usage information on Wanted: who's using dubbo, thanks :)
Architecture
Features
- Transparent interface based RPC
- Intelligent load balancing
- Automatic service registration and discovery
- High extensibility
- Runtime traffic routing
- Visualized service governance
Getting started
The following code snippet comes from Dubbo Samples. You may clone the sample project and step into the dubbo-samples-api
subdirectory before proceeding.
git clone https://github.com/apache/dubbo-samples.git
cd dubbo-samples/1-basic/dubbo-samples-api
There's a README file under dubbo-samples-api
directory. We recommend referencing the samples in that directory by following the below-mentioned instructions:
Maven dependency
<properties>
<dubbo.version>3.2.13-SNAPSHOT</dubbo.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
<version>${dubbo.version}</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-dependencies-zookeeper</artifactId>
<version>${dubbo.version}</version>
<type>pom</type>
</dependency>
</dependencies>
Define service interfaces
package org.apache.dubbo.samples.api;
public interface GreetingsService {
String sayHi(String name);
}
See api/GreetingsService.java on GitHub.
Implement service interface for the provider
package org.apache.dubbo.samples.provider;
import org.apache.dubbo.samples.api.GreetingsService;
public class GreetingsServiceImpl implements GreetingsService {
@Override
public String sayHi(String name) {
return "hi, " + name;
}
}
See provider/GreetingsServiceImpl.java on GitHub.
Start service provider
package org.apache.dubbo.samples.provider;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.ServiceConfig;
import org.apache.dubbo.samples.api.GreetingsService;
import java.util.concurrent.CountDownLatch;
public class Application {
private static String zookeeperHost = System.getProperty("zookeeper.address", "127.0.0.1");
public static void main(String[] args) throws Exception {
ServiceConfig<GreetingsService> service = new ServiceConfig<>();
service.setApplication(new ApplicationConfig("first-dubbo-provider"));
service.setRegistry(new RegistryConfig("zookeeper://" + zookeeperHost + ":2181"));
service.setInterface(GreetingsService.class);
service.setRef(new GreetingsServiceImpl());
service.export();
System.out.println("dubbo service started");
new CountDownLatch(1).await();
}
}
See provider/Application.java on GitHub.
Build and run the provider
mvn clean package
mvn -Djava.net.preferIPv4Stack=true -Dexec.mainClass=org.apache.dubbo.samples.provider.Application exec:java
Call remote service in the consumer
package org.apache.dubbo.samples.client;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ReferenceConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.samples.api.GreetingsService;
public class Application {
private static String zookeeperHost = System.getProperty("zookeeper.address", "127.0.0.1");
public static void main(String[] args) {
ReferenceConfig<GreetingsService> reference = new ReferenceConfig<>();
reference.setApplication(new ApplicationConfig("first-dubbo-consumer"));
reference.setRegistry(new RegistryConfig("zookeeper://" + zookeeperHost + ":2181"));
reference.setInterface(GreetingsService.class);
GreetingsService service = reference.get();
String message = service.sayHi("dubbo");
System.out.println(message);
}
}
See client/Application.java on GitHub.
Build and run the consumer
mvn clean package
mvn -Djava.net.preferIPv4Stack=true -Dexec.mainClass=org.apache.dubbo.samples.client.Application exec:java
The consumer will print out hi, dubbo
on the screen.
Next steps
- Your first Dubbo application - A 101 tutorial to reveal more details, with the same code above.
- Dubbo user manual - How to use Dubbo and all its features.
- Dubbo developer guide - How to involve in Dubbo development.
- Dubbo admin manual - How to admin and manage Dubbo services.
Building
If you want to try out the cutting-edge features, you can build with the following commands. (Java 1.8 is needed to build the master branch)
mvn clean install
Recommended Test Environment
To avoid intermittent test failures (i.e., flaky tests), it is recommended to have a machine or virtual machine with the following specifications:
- Minimum of 2CPUs.
- Minimum of 2Gb of RAM.
How does the Dubbo Community collaborate?
The Dubbo Community primarily communicates on GitHub through issues, discussions, and pull requests.
- Issues: We use issues to track bugs and tasks. Any work-related item is associated with an issue.
- Discussions: We use discussions for questions, early proposals, and announcements. Any idea-related item is associated with a discussion.
- Pull Requests: We use pull requests to merge a set of changes from contributors into Dubbo.
We have also implemented a project board to monitor all the items.
Any essential changes should be discussed on the mailing list before they happen.
Seeking for help
If you have questions such as:
- What is Dubbo?
- How do I use Dubbo?
- Why did an unexpected result occur?
Please start a discussion at https://github.com/apache/dubbo/discussions.
However, if you encounter the following situations:
- You're certain there's a bug that Dubbo needs to fix,
- You believe a feature could be enhanced,
- You have a detailed proposal for improving Dubbo,
Please open an issue at https://github.com/apache/dubbo/issues.
To ask effective questions, we recommend reading How To Ask Questions The Smart Way first.
Contribution
- Browse the "help wanted" tasks in the Dubbo project board.
- Participate in discussions on the mailing list. See the subscription guide.
- Respond to queries in the discussions.
- Resolve bugs reported in issues and send us a pull request.
- Review existing pull requests.
- Enhance the website. We typically need:
- Blog posts
- Translations for documentation
- Use cases showcasing Dubbo integration in enterprise systems.
- Improve the dubbo-admin.
- Contribute to the projects listed in the ecosystem.
- Any other forms of contribution not listed above are also welcome.
- If you're interested in contributing, please send an email to dev@dubbo.apache.org to let us know!
For further details, please refer our guide about how to contribute Dubbo.
Reporting bugs
Please follow the template for reporting any issues.
Reporting a security vulnerability
Please report security vulnerabilities to us privately.
Contact
-
Mailing list:
- dev list: for dev/user discussion. subscribe, unsubscribe, archive, guide
-
Bugs: Issues
-
Gitter: Gitter channel
-
Twitter: @ApacheDubbo
Dubbo ecosystem
- Dubbo Ecosystem Entry - A GitHub group
dubbo
to gather all Dubbo relevant projects not appropriate in apache group yet - Dubbo Website - Apache Dubbo official website
- Dubbo Samples - samples for Apache Dubbo
- Dubbo Admin - The reference implementation for Dubbo admin
- Dubbo Awesome - Dubbo's slides and video links in Meetup
Language
License
Apache Dubbo software is licensed under the Apache License Version 2.0. See the LICENSE file for details.
Top Related Projects
Support for using OpenFeign in Spring Cloud apps
The Java gRPC implementation. HTTP/2 based RPC
Hystrix is a latency and fault tolerance library designed to isolate points of access to remote systems, services and 3rd party libraries, stop cascading failure and enable resilience in complex distributed systems where failure is inevitable.
A powerful flow control component enabling reliability, resilience and monitoring for microservices. (面向云原生微服务的高可用流控防护组件)
Tars is a high-performance RPC framework based on name service and Tars protocol, also integrated administration platform, and implemented hosting-service via flexible schedule.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot