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.
Limit the concurrent execution (or occupied thread pool threads) for each method of com.foo.BarService
to a maximum of 10.
XML format:
<dubbo:service interface="com.foo.BarService" executes="10" />
Annotation format:
@DubboService(executes=10)
private DemoServiceImpl implements DemoService{}
Limit the sayHello
method of com.foo.BarService
to a maximum of 10 concurrent executions (or occupied thread pool threads).
XML format:
<dubbo:service interface="com.foo.BarService">
<dubbo:method name="sayHello" executes="10" />
</dubbo:service>
Annotation format:
@DubboService(executes=10, methods = {@Method(name="sayHello",executes=10)})
private DemoServiceImpl implements DemoService{}
Limit the concurrent execution (or occupied connection requests) for each method of com.foo.BarService
to a maximum of 10 per client.
XML format:
<dubbo:service interface="com.foo.BarService" actives="10" />
Annotation format:
@DubboReference(actives=10)
private DemoService demoService;
Limit the sayHello
method of com.foo.BarService
to a maximum of 10 concurrent executions (or occupied connection requests) per client.
XML format:
<dubbo:service interface="com.foo.BarService">
<dubbo:method name="sayHello" actives="10" />
</dubbo:service>
Annotation format:
@DubboReference(actives=10, methods = {@Method(name="sayHello",executes=10)})
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 .
Set the loadbalance
attribute of the service’s client to leastactive
, this Loadbalance will call the provider with the least number of concurrent requests.
<dubbo:reference interface="com.foo.BarService" loadbalance="leastactive" />
Or
<dubbo:service interface="com.foo.BarService" loadbalance="leastactive" />