Dubbo Framework’s Built-in Concurrent Control Strategy

Dubbo framework’s built-in concurrent control or rate limiting strategy prevents malicious requests from overloading the server by limiting the number of concurrent requests from the same client to the same service, ensuring service stability and preventing excessive resource usage.

Dubbo has implemented a built-in concurrency control strategy through the Filter interceptor mechanism. It limits the number of concurrent requests from the same client to the same service, preventing malicious requests from overloading the server, ensuring service stability, and preventing excessive resource usage.

  • Control the maximum concurrent requests for certain services to ensure the availability of resources for other services. Prevent system overload and ensure system stability.
  • Allow for smoother service scaling when demand increases.
  • Ensure service reliability and stability during peak usage times.

Note

This method requires users to accurately pre-assess the number of concurrent requests the system can handle, and accurately determining system capabilities is not an easy task. Therefore, Dubbo also provides an adaptive rate limiting mode, which automatically identifies system health based on system load and provides rate limiting protection. You can view the adaptive rate limiting mode documentation here.

Rate Limiting Strategy Configuration

Limit Server-Side Concurrent Execution (Service Granularity)

Limit the concurrent execution (or occupied thread pool threads) for each method of com.foo.BarService to a maximum of 10.

XML format:

  1. <dubbo:service interface="com.foo.BarService" executes="10" />

Annotation format:

  1. @DubboService(executes=10)
  2. private DemoServiceImpl implements DemoService{}

Limit Server-Side Concurrent Execution (Method Granularity)

Limit the sayHello method of com.foo.BarService to a maximum of 10 concurrent executions (or occupied thread pool threads).

XML format:

  1. <dubbo:service interface="com.foo.BarService">
  2. <dubbo:method name="sayHello" executes="10" />
  3. </dubbo:service>

Annotation format:

  1. @DubboService(executes=10, methods = {@Method(name="sayHello",executes=10)})
  2. private DemoServiceImpl implements DemoService{}

Limit Consumer-Side Concurrent Calls (Service Granularity)

Limit the concurrent execution (or occupied connection requests) for each method of com.foo.BarService to a maximum of 10 per client.

XML format:

  1. <dubbo:service interface="com.foo.BarService" actives="10" />

Annotation format:

  1. @DubboReference(actives=10)
  2. private DemoService demoService;

Limit Consumer-Side Concurrent Calls (Method Granularity)

Limit the sayHello method of com.foo.BarService to a maximum of 10 concurrent executions (or occupied connection requests) per client.

XML format:

  1. <dubbo:service interface="com.foo.BarService">
  2. <dubbo:method name="sayHello" actives="10" />
  3. </dubbo:service>

Annotation format:

  1. @DubboReference(actives=10, methods = {@Method(name="sayHello",executes=10)})
  2. private DemoService demoService;

If both the provider @DubboService and the consumer @DubboReference are configured with actives, the consumer’s configuration value takes precedence. See: Configuration Override Strategy .

Minimum Concurrent Load Balancing

Set the loadbalance attribute of the service’s client to leastactive, this Loadbalance will call the provider with the least number of concurrent requests.

  1. <dubbo:reference interface="com.foo.BarService" loadbalance="leastactive" />

Or

  1. <dubbo:service interface="com.foo.BarService" loadbalance="leastactive" />

Feedback

Was this page helpful?

Yes No

Last modified September 30, 2024: Update & Translate Overview Docs (#3040) (d37ebceaea7)