This task demonstrates the traffic control capabilities of Dubbo based on a simple online shopping mall microservice system.
The architecture diagram of the online mall is as follows:
The system consists of 5 microservice applications:
Frontend Shopping Mall Home
, which serves as the web interface interacting with users, calling User
, Detail
, Order
, etc., to provide user login, product display, and order management services.User Service
, responsible for user data management and identity verification.Order Service
, providing order creation and query services, relying on the Detail
service to validate product stock information.Detail Service
, displaying detailed product information and calling the Comment
service to show user comments on products.Comment Service
, managing user comments on products.For convenience, we will deploy the entire system on a Kubernetes cluster. Execute the following command to complete the mall project deployment. The source code example is in dubbo-samples/task.
kubectl apply -f https://raw.githubusercontent.com/apache/dubbo-samples/master/10-task/dubbo-samples-shop/deploy/All.yml
The complete deployment architecture diagram is as follows:
The Order Service
has two versions, v1
and v2
, with v2
being the newly released optimized version of the order service.
Both the Detail
and Comment
services also have two versions, v1
and v2
, demonstrating the effect of traffic diversion across multiple versions.
v1
provides services for all requests by default.v2
simulates services deployed in specific regions, so the v2
instances carry specific labels.Execute the following commands to ensure all services and Pods are running normally:
$ kubectl get services -n dubbo-demo
$ kubectl get pods -n dubbo-demo
To ensure the integrity of the system, in addition to the several microservice applications related to the mall, examples also start up Nacos registration configuration center, Dubbo Admin Console, and Skywalking full-link tracing system in the background.
$ kubectl get services -n dubbo-system
$ kubectl get pods -n dubbo-system
Execute the following commands to map the cluster ports to local ports:
kubectl port-forward -n dubbo-demo deployment/shop-frontend 8080:8080
kubectl port-forward -n dubbo-system service/dubbo-admin 38080:38080
kubectl port-forward -n dubbo-system service/skywalking-oap-dashboard 8082:8082
At this point, open your browser to access the following addresses:
http://localhost:8080
http://localhost:38080
http://localhost:8082
Next, try to add some traffic control rules to the mall through the following task items.
By dynamically adjusting the service timeout during runtime, it can effectively address issues such as unreasonable timeout settings and frequent timeouts due to system anomalies, improving system stability.
Retries after the initial service call failure can effectively increase the overall call success rate.
Access logs can effectively record all service request information processed by a machine within a certain period. Dynamically enabling access logs in runtime is very helpful for troubleshooting.
Same data center/region priority means prioritizing calls to service providers in the same data center/region when invoking services, avoiding network delays caused by cross-region calls, thereby reducing response time for calls.
By logically isolating one or more applications in a cluster, this can be used for gray environments or building multiple testing environments.
For example, route traffic based on user ID, forwarding a small portion of user requests to the newly released product version to validate the stability of the new version and gather user feedback on product experience.
By dynamically adjusting the weight of a single or a set of machines through rules, the distribution of request traffic can be altered in runtime to achieve dynamic, proportional traffic routing.
The core goal of service downgrade is to maintain functional integrity by returning downgraded results when weak dependencies are unavailable or calls fail.
By forwarding requests to a specific provider machine, this helps quickly reproduce development or online issues.