The connection control feature allows users to manage and control the number of incoming and outgoing connections to the server, limit the number of connections, and set timeouts, ensuring the stability and performance of the Dubbo system. It also allows users to configure different levels of access control based on IP address, port, and protocol to protect the system from malicious traffic and reduce the risk of service interruptions. Additionally, it provides a way to monitor current traffic and connection status.
Limit the server-side accepted connections to no more than 10 1:
<dubbo:provider protocol="dubbo" accepts="10" />
or
<dubbo:protocol name="dubbo" accepts="10" />
Limit the client service connections to no more than 10 2:
<dubbo:reference interface="com.foo.BarService" connections="10" />
or
<dubbo:service interface="com.foo.BarService" connections="10" />
If both <dubbo:service>
and <dubbo:reference>
are configured with connections, <dubbo:reference>
takes precedence, see: Configuration Override Policy
Consumers can send requests to the provider before the provider is ready to receive requests, ensuring requests are sent at the right time and preventing consumers from being blocked by slow or unavailable providers.
Sticky connections are used for stateful services, allowing clients to always invoke the same provider unless that provider is down.
Sticky connections will automatically enable lazy connect to reduce the number of long connections.
<dubbo:reference id="xxxService" interface="com.xxx.XxxService" sticky="true" />
Dubbo supports method-level sticky connections, allowing for more granular control.
<dubbo:reference id="xxxService" interface="com.xxx.XxxService">
<dubbo:method name="sayHello" sticky="true" />
</dubbo:reference>
True connections are established only when the consumer actually uses the service, avoiding unnecessary connections to reduce latency and improve system stability.
Lazy connections are used to reduce the number of long connections. Long connections are created when a call is initiated.
<dubbo:protocol name="dubbo" lazy="true" />
This configuration only takes effect for the Dubbo protocol used with long connections.