How Configuration Works

An in-depth interpretation of Dubbo configuration methods and working principles, including configuration formats, design ideas, sources, loading processes, etc.

The following is an example of Dubbo property configuration dubbo-spring-boot-samples


  # Spring boot application

  # Base packages to scan Dubbo Component:

  # Dubbo Application
  ## The default value of is ${}

  #Dubbo Protocol

  ## Dubbo Registry

  ## service default version

Next, around this example, we analyze the working principle of Dubbo configuration from three aspects: configuration format, configuration source, and loading process.

1 configuration format

All configurations currently supported by Dubbo are in .properties format, including -D, Externalized Configuration, etc. All configuration items in .properties follow a path-based configuration format.

In the Spring application, you can also put the attribute configuration in application.yml, and the tree hierarchy is more readable.

# Application-level configuration (no id)

# Instance-level configuration (specify id or name)

# Service interface configuration

# method configuration

# Method argument configuration

1.1 Application-level configuration (no id)

The format of application-level configuration is: configuration type singular prefix, no id/name.

# Application-level configuration (no id)

Similar to application, monitor, metrics, etc. are all application-level components, so only a single instance is allowed to be configured; while protocol, registry, etc. allow to configure multiple components, when only singleton configuration is required , in the format described in this section. Common examples are as follows:


1.2 Instance-level configuration (specify id or name)

The attribute configuration for an instance needs to specify an id or name, and its prefix format is: configuration type plural prefix + id/name. Applicable to protocol, registry and other components that support multiple configurations.

# Instance-level configuration (specify id or name)
  • If there is no instance of the id or name, the framework will create a configuration component instance based on the properties listed here.
  • If an instance with the same id or name already exists, the framework will use the attributes listed here as a supplement to the existing instance configuration. For details, please refer to [Attribute Override](../principle#32-Attribute Override).
  • Please refer to the [single and plural configuration comparison table] (../principle#17-single and plural configuration item comparison table)

Configuration example:


1.3 Service interface configuration

Method configuration

Method configuration format:

# method configuration

# Method argument configuration

Example method configuration:

Equivalent to XML configuration:

<dubbo:reference interface="org.apache.dubbo.samples.api.DemoService">
    <dubbo:method name="sayHello" timeout="7000" oninvoke="notifyService.onInvoke"
                  onreturn="notifyService.onReturn" onthrow="notifyService.onThrow">
        <dubbo:argument index="0" callback="true" />

1.4 Parameter configuration

The parameters parameter is a map object, which supports configuration in the form of xxx.parameters=[{key:value},{key:value}].


1.5 Transport layer configuration

The triple protocol uses Http2 as the underlying communication protocol, allowing users to customize [6 settings parameters] of Http2 (

The configuration format is as follows:

# Notify the peer header of the upper limit of compressed index tables

# Enable server-side push function

# Notify the peer of the maximum number of concurrent streams allowed

# Declare the window size of the sender

# Set the maximum number of bytes for the frame

# Notify the peer of the maximum number of uncompressed bytes in the header

Equivalent to yml configuration:

      header-table-size: 4096
      enable-push: false
      max-concurrent-streams: 2147483647
      initial-window-size: 1048576
      max-frame-size: 32768
      max-header-list-size: 8192

1.6 Attribute and XML configuration mapping rules

The xml tag name and attribute name can be combined, separated by ‘.’. One attribute per line.

  • is equivalent to <dubbo:application name="foo" />
  • dubbo.registry.address= is equivalent to <dubbo:registry address="" />

If there is more than one tag in xml configuration, then you can use ‘id’ to differentiate. If you don’t specify an id, it will apply to all tags.

  • dubbo.protocols.rmi.port=1099 is equivalent to <dubbo:protocol id="rmi" name="rmi" port="1099" />
  • dubbo.registries.china.address= is equivalent to <dubbo:registry id="china" address="" />

1.7 Single and plural comparison table for configuration items

Plural configurations are named in the same way as regular words are pluralized:

  1. When the letter y ends, remove y and change to ies
  2. At the end of the letter s, add es
  3. Others add s

| Config Type | Singular Configuration | Plural Configuration | | ———————————— | ————— ———————————————— | —- ———————————- | | application | | dubbo.applications.{id}.xxx=xxx
dubbo.applications.{name}.xxx=xxx | | protocol | | dubbo.protocols.{id}.xxx=xxx
dubbo.protocols.{name}.xxx=xxx | | module | | dubbo.modules.{id}.xxx=xxx
dubbo.modules.{name}.xxx=xxx | | registry | | dubbo.registries.{id}.xxx=xxx | | monitor | | dubbo.monitors.{id}.xxx=xxx | | config-center | | dubbo.config-centers.{id}.xxx=xxx | | metadata-report | | dubbo.metadata-reports.{id}.xxx=xxx | | ssl | | dubbo.ssls.{id}.xxx=xxx | | metrics | | dubbo.metricses.{id}.xxx=xxx | | provider | | dubbo.providers.{id}.xxx=xxx | | consumer | | dubbo.consumers.{id}.xxx=xxx | | service | dubbo.service.{interfaceName}.xxx=xxx | None | | reference | dubbo.reference.{interfaceName}.xxx=xxx | None | | method | dubbo.service.{interfaceName}.{methodName}.xxx=xxx
dubbo.reference.{interfaceName}.{methodName}.xxx=xxx | None | | argument | dubbo.service.{interfaceName}.{methodName}.{arg-index}.xxx=xxx | None |

2 Configure sources

Dubbo supports 6 configuration sources by default:

  • JVM System Properties, JVM -D parameter
  • System environment, the environment variable of the JVM process
  • Externalized Configuration, [externalized configuration] (#33-externalized configuration), read from the configuration center
  • Application Configuration, application attribute configuration, extract the attribute set starting with “dubbo” from the Spring application Environment
  • The configuration collected by programming interfaces such as API/XML/annotation can be understood as a kind of configuration source, which is a configuration collection method directly oriented to user programming
  • Read configuration file from classpath

About the attribute:

  1. If there is more than one file under the classpath, for example, two jar packages each contain, dubbo will randomly select one to load and print an error log.
  2. Dubbo can automatically load in the root directory of the classpath, but you can also use JVM parameters to specify the path:

2.1 Coverage relationship

If the same configuration item is specified through multiple configuration sources, configuration items will overlap each other. Please refer to the next section for specific coverage relationship and priority.

3 Configuration loading process

3.1 Processing flow

Dubbo configuration loading is roughly divided into two stages:

Configuration loading process

  • The first stage is before the initialization of DubboBootstrap, parse and process the XML configuration/annotation configuration/Java-config or execute the API configuration code when the Spring context starts, create a config bean and add it to the ConfigManager.
  • The second stage is the DubboBootstrap initialization process, which reads the external configuration from the configuration center, processes instance-level attribute configuration and application-level attribute configuration in turn, and finally refreshes the attributes of all configuration instances, that is, [property override](../principle#32 -property override).

3.2 Property Override

There may be two situations where property overriding occurs, and the two may occur at the same time:

  1. The same configuration item is configured in different configuration sources
  2. The same configuration source, but the same configuration item is specified at different levels

3.2.1 Different configuration sources

Override relationship

3.2.1 Same configuration source

Property override refers to overriding the properties of the config bean instance with the configured property values, similar to Spring [PropertyOverrideConfigurer]( factory/config/PropertyOverrideConfigurer.html) .

Property resource configurer that overrides bean property values in an application context definition. It pushes values from a properties file into bean definitions. Configuration lines are expected to be of the following form:

But the difference from PropertyOverrideConfigurer is that Dubbo’s property override has multiple matching formats, and the priority from high to low is:

#1. Instance-level configuration of the specified id

#2. Specify the instance-level configuration of the name

#3. Application-level configuration (singular configuration)

Attribute override processing flow:

Search in order of priority from high to low. If an attribute starting with this prefix is found, use this prefix to extract the attribute and ignore the subsequent configuration.

Properties Override Process

3.3 Externalization configuration

One of the purposes of external configuration is to achieve centralized management of configuration. There are already many mature professional configuration systems in this part of the industry, such as Apollo, Nacos, etc. What Dubbo does is mainly to ensure that it can work with these systems.

There is no difference in content and format between externalized configuration and other local configurations. It can be simply understood as the externalized storage of The configuration center is more suitable for extracting some public configurations such as registration centers and metadata center configurations for future use. centralized management.

# Centralized management of registration center address, metadata center address and other configurations can achieve a unified environment and reduce development-side perception.


  • priority By default, the externalized configuration has a higher priority than the local configuration, so the content configured here will override the local configuration value. There is a separate chapter explaining the [Override Relationship] (#21-Override Relationship) between various configuration forms.

  • scope There are two levels of external configuration: global and application. The global configuration is shared by all applications. The application-level configuration is maintained by each application and is only visible to itself. Currently supported extensions include Zookeeper, Apollo, and Nacos.

3.3.1 How to use external configuration

  1. Add config-center configuration
<dubbo:config-center address="zookeeper://"/>
  1. Add global configuration items in the corresponding configuration center (zookeeper, Nacos, etc.), take Nacos as an example as follows:


After the external configuration is enabled, global configurations such as registry, metadata-report, protocol, and qos theoretically no longer need to be configured in the application. The application development side focuses on business service configuration, and some globally shared global configurations are transferred to O&M. The personnel are uniformly configured in the remote configuration center.

The effect of this is that the application only needs to care about:

  • Service exposure, subscription configuration
  • Configuration center address When deployed to different environments, other configurations can be automatically read from the corresponding configuration center.

For example, only the following Dubbo-related configurations in each application may be sufficient, and the rest are hosted in the configuration center in the corresponding environment:

    name: demo
    address: nacos://

3.3.2 Load external configuration by itself

The so-called Dubbo’s support for the configuration center is essentially to pull .properties from the remote to the local, and then integrate it with the local configuration. In theory, as long as the Dubbo framework can get the required configuration, it can start normally. It doesn’t care whether these configurations are loaded by itself or directly inserted by the application, so Dubbo also provides the following APIs to allow users to organize themselves. The configuration is stuffed into the Dubbo framework (the configuration loading process is to be completed by the user), so that the Dubbo framework no longer directly interacts with Apollo or Zookeeper to read the configuration.

// The application loads its own configuration
Map<String, String> dubboConfigurations = new HashMap<>();
        dubboConfigurations.put("dubbo.registry.address", "zookeeper://");
        dubboConfigurations.put("dubbo.registry.simplified", "true");

//Throw the organized configuration into the Dubbo framework
        ConfigCenterConfig configCenter = new ConfigCenterConfig();

Last modified January 2, 2023: Enhance en docs (#1798) (95a9f4f6c1c)