Apache Dubbo是一款高性能、轻量级的开源Java RPC框架，它提供了三大核心能力：面向接口的远程方法调用，智能容错和负载均衡，以及服务自动注册和发现。Dubbo于2018年被阿里巴巴捐赠给Apache基金会。
Apache Dubbo is a high-performance, lightweight open source Java RPC framework. It provides three core capabilities: interface oriented remote method call, intelligent fault tolerance and load balancing, and automatic service registration and discovery. Dubbo was donated to the Apache foundation by Alibaba in 2018.
Apache Dubbo 是一款高性能、轻量级的开源 Java RPC 框架，它提供了三大核心能力：面向接口的远程方法调用，智能容错和负载均衡，以及服务自动注册和发现。Dubbo 原属于阿里巴巴的开源项目，2018 年阿里巴巴捐赠给 Apache 基金会。
Apache Dubbo is a high-performance, lightweight open source Java RPC framework. It provides three core capabilities: interface oriented remote method call, intelligent fault tolerance and load balancing, and automatic service registration and discovery. Dubbo was originally an open source project of Alibaba. In 2018, Alibaba donated it to the Apache foundation.
Dubbo 采用全 Spring 配置方式，透明化接入应用，对应用没有任何 API 侵入，只需用 Spring 加载 Dubbo 的配置即可，Dubbo 基于 Spring 的 Schema 扩展 进行加载。
Dubbo uses the full spring configuration mode to access the application transparently. There is no API intrusion to the application. You only need spring to load Dubbo’s configuration. Dubbo is loaded based on the Schema Extension of spring.
With the development of the Internet, the scale of website application is constantly expanding, and the conventional vertical application architecture can not cope with it. The distributed service architecture and mobile computing architecture are imperative. A governance system is needed to ensure the orderly evolution of the architecture.
Single application architecture
When the website traffic is very small, only one application is needed to deploy all functions together to reduce deployment nodes and costs. At this time, the data access framework (ORM) is the key to simplify the workload of adding, deleting, modifying and querying.
Vertical application architecture
当访问量逐渐增大，单一应用增加机器带来的加速度越来越小，提升效率的方法之一是将应用拆成互不相干的几个应用，以提升效率。此时，用于加速前端页面开发的 Web 框架(MVC)是关键。
When the number of visits increases gradually, the acceleration brought by the increase of single application becomes smaller and smaller. One of the ways to improve efficiency is to split the application into several unrelated applications to improve efficiency. At this point, the web framework (MVC) for accelerating the development of front-end pages is the key.
Distributed service architecture
With more and more vertical applications, the interaction between applications is inevitable. The core business is extracted as an independent service to gradually form a stable service center, so that the front-end application can respond to the changing market demand more quickly. At this time, the distributed service framework (RPC) is the key to improve business reuse and integration.
Flow computing architecture
When there are more and more services, the evaluation of capacity, the waste of small service resources and other problems gradually appear. At this time, it is necessary to add a scheduling center to manage the cluster capacity in real time based on the access pressure to improve the cluster utilization. At this time, resource scheduling and Governance Center (SOA) is the key to improve machine utilization.
在大规模服务化之前，应用可能只是通过 RMI 或 Hessian 等工具，简单的暴露和引用远程服务，通过配置服务的 URL 地址进行调用，通过 F5 等硬件进行负载均衡。
Before large-scale service, the application may simply expose and reference remote services through RMI or Hessian tools, call by configuring the URL address of the service, and load balancing through hardware such as F5.
当服务越来越多时，服务 URL 配置管理变得非常困难，F5 硬件负载均衡器的单点压力也越来越大。 此时需要一个服务注册中心，动态地注册和发现服务，使服务的位置透明。并通过在消费方获取服务提供方地址列表，实现软负载均衡和 Failover，降低对 F5 硬件负载均衡器的依赖，也能减少部分成本。
When there are more and more services, the configuration management of service URL becomes very difficult, and the single point pressure of F5 hardware load balancer is also increasing. At this time, a service registry is needed to register and discover services dynamically to make the location of services transparent. By obtaining the address list of service providers in the consumer side, the software load balancing and failure can be realized, and the dependence on F5 hardware load balancer can be reduced, and part of the cost can also be reduced.
With the further development, the dependency relationship between services becomes more complex, and it is even unclear which application should be started before which application, and the architect can not describe the architecture relationship of the application completely. At this point, we need to automatically draw the dependency diagram between applications to help architects clarify the relationship.
Then, with the increasing number of service calls, the problem of service capacity is exposed. How many machines does this service need to support? When should the machine be added? In order to solve these problems, the first step is to count the daily call volume and response time of the service as a reference index for capacity planning. Secondly, the weight of a machine should be adjusted dynamically. On line, the weight of a machine is increased all the time, and the change of response time is recorded in the process of increasing until the response time reaches the threshold value. Then, the total capacity is calculated by multiplying the number of machines by the number of visits.
Call relation description
The service container is responsible for starting, loading and running the service provider.
Service providers register their services with the registry at startup.
The service consumer subscribes to the registry when it starts.
The registry returns the service provider address list to the consumer. If there is a change, the registry will push the change data to the consumer based on the long connection.
The service consumer selects one provider to call from the provider address list based on the soft load balancing algorithm. If the call fails, another provider is selected to call.
Service consumers and providers accumulate the call times and call time in memory, and regularly send statistical data to the monitoring center once a minute.
Dubbo architecture has the following characteristics: connectivity, robustness, scalability, and upgrade to the future architecture.
The registry is responsible for the registration and search of service address, which is equivalent to directory service. Service providers and consumers only interact with the registry at startup, and the registry does not forward requests, so the pressure is small
The monitoring center is responsible for counting the call times and time of each service. The statistics are first summarized in the memory and then sent to the server of the monitoring center once every minute and displayed in a report form
The service provider registers its services with the registry and reports the call time to the monitoring center, which does not include network overhead
The service consumer obtains the service provider address list from the registry, and directly calls the provider according to the load algorithm, and reports the call time to the monitoring center, which includes network overhead
Registration Center, service provider and service consumer are all long connection, except monitoring center
The registry senses the existence of the service provider through long connection. If the service provider fails, the registry will immediately push the event to inform the consumer
The registry and monitoring center are all down, which does not affect the running providers and consumers. Consumers cache the list of providers locally
Both the registry and the monitoring center are optional, and the service consumer can directly connect to the service provider
Monitoring center downtime does not affect the use, only part of the sampling data is lost
After the database is down, the registry can still provide service list query through cache, but can not register new services
The peer-to-peer cluster in the registry will automatically switch to the other when any one of them fails
After all the registries are down, service providers and service consumers can still communicate through the local cache
The service provider is stateless, and the usage will not be affected after any one of them is down
After all the service providers are down, the service consumer application will not be able to use and will be reconnected indefinitely for the service provider to recover
The registry is a peer-to-peer cluster, which can dynamically add machine deployment instances, and all clients will automatically discover new registries
The service provider is stateless and can dynamically add machine deployment instances. The registry will push new service provider information to consumers
当服务集群规模进一步扩大，带动 IT 治理结构进一步升级，需要实现动态部署，进行流动计算，现有分布式服务架构不会带来阻力。
When the scale of service cluster is further expanded and it governance structure is further upgraded, dynamic deployment and flow calculation are needed. The existing distributed service architecture will not bring resistance.