并发控制
限制com.foo.BarService的每个方法,服务器端并发执行(或占用线程池线程数)不能超过10个:
<
dubbo:service
interface
=
"com.foo.BarService"
executes
=
"10"
/>
限制com.foo.BarService的sayHello方法,服务器端并发执行(或占用线程池线程数)不能超过10个:
<
dubbo:service
interface
=
"com.foo.BarService"
>
<
dubbo:method
name
=
"sayHello"
executes
=
"10"
/>
</
dubbo:service
>
限制com.foo.BarService的每个方法,每客户端并发执行(或占用连接的请求数)不能超过10个:
<
dubbo:service
interface
=
"com.foo.BarService"
actives
=
"10"
/>
Or:
<
dubbo:reference
interface
=
"com.foo.BarService"
actives
=
"10"
/>
限制com.foo.BarService的sayHello方法,每客户端并发执行(或占用连接的请求数)不能超过10个:
<
dubbo:service
interface
=
"com.foo.BarService"
>
<
dubbo:method
name
=
"sayHello"
actives
=
"10"
/>
</
dubbo:service
>
Or:
<
dubbo:reference
interface
=
"com.foo.BarService"
>
<
dubbo:method
name
=
"sayHello"
actives
=
"10"
/>
</
dubbo:service
>
如果<dubbo:service>和<dubbo:reference>都配了actives,<dubbo:reference>优先,参见:配置的覆盖策略。
Load Balance均衡:
配置服务的客户端的loadbalance属性为leastactive,此Loadbalance会调用并发数最小的Provider(Consumer端并发数)。
<
dubbo:reference
interface
=
"com.foo.BarService"
loadbalance
=
"leastactive"
/>
Or:
<
dubbo:service
interface
=
"com.foo.BarService"
loadbalance
=
"leastactive"
/>
连接控制
限制服务器端接受的连接不能超过10个:(以连接在Server上,所以配置在Provider上)
<
dubbo:provider
protocol
=
"dubbo"
accepts
=
"10"
/>
<
dubbo:protocol
name
=
"dubbo"
accepts
=
"10"
/>
限制客户端服务使用连接连接数:(如果是长连接,比如Dubbo协议,connections表示该服务对每个提供者建立的长连接数)
<
dubbo:reference
interface
=
"com.foo.BarService"
connections
=
"10"
/>
Or:
<
dubbo:service
interface
=
"com.foo.BarService"
connections
=
"10"
/>
如果<dubbo:service>和<dubbo:reference>都配了connections,<dubbo:reference>优先