Dubbo provides the ability to dynamically adjust service timeout, allowing adjustments without restarting the application, which is very effective for temporarily resolving issues of invocation failure due to unstable upstream and downstream service dependencies.
The mall project provides user information management services through org.apache.dubbo.samples.UserService
. Access http://localhost:8080/
, enter any username and password, and click Login
to log into the system.
In some scenarios, the speed of the User service may slow down, such as when the database storing user data is overloaded, resulting in slow queries, which can cause UserService
access timeouts and login failures.
In the demo system, you can simulate a sudden UserService
access timeout exception through the Timeout Login
in the image below.
To address sudden login timeout issues, we can simply increase the waiting time for UserService
service calls.
org.apache.dubbo.samples.UserService
, and the new timeout such as 2000
.After saving, click Timeout Login
again, and after a brief wait, the system can log in normally.
Rule key: org.apache.dubbo.samples.UserService
Rule body
configVersion: v3.0
enabled: true
configs:
- side: provider
parameters:
timeout: 2000
From the perspective of the UserService
provider, the overall timeout is adjusted to 2s.
parameters:
timeout: 2000
The side: provider
configuration will send the rule to the service provider instance, and all UserService
instances will re-publish based on the new timeout value, notifying all consumers via the registry.
To avoid affecting other tasks, delete or disable the timeout rule just configured through Admin.