Dubbo—traffic control

This task demonstrates Dubbo's traffic control capabilities based on a simple online mall microservice system.

The structure diagram of the online mall is as follows:

 

The system consists of 5 microservice applications:

  • The frontend mall home page, as a web interface for interacting with users, provides services such as user login, product display, and order management by calling User, Detail, Order, etc.
  • User user service, responsible for user data management, identity verification, etc.
  • Order order service, which provides services such as order creation and order query, and relies on the Detail service to verify product inventory and other information.
  • Detail product details service, which displays product details information, and calls Comment service to display user comment records on products.
  • Comment Comment service, manage user comment data on products.

Deploy the shopping mall system

For convenience, we deploy the entire system in the Kubernetes cluster, and execute the following command to complete the deployment of the mall project. The project 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:

 

Order service has two versions v1 and v2, and v2 is a new version released after order service optimization.

  • Version v1 simply creates an order without displaying order details
  • Version v2 will display the delivery address details of the order after the order is successfully created

The Detail and Comment services also have two versions, v1 and v2, respectively. We use multiple versions to demonstrate the effect of traffic diversion.

  • Version v1 serves all requests by default
  • Version v2 simulates a service deployed in a specific region, so v2 instances will have a specific label

Execute the following command to make sure that all services and pods are running normally:

$ kubectl get services -n dubbo-demo
$ kubectl get pods -n dubbo-demo

In order to ensure the integrity of the system, in addition to several microservice applications related to the mall, the example also pulls up the Nacos registration configuration center, Dubbo Admin console and Skywalking full link tracking system in the background.

$ kubectl get services -n dubbo-system
$ kubectl get pods -n dubbo-system

get access address

Execute the following command to map the cluster port to the local port:

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 the browser and access it through the following address:

  • Mall homepage http://localhost:8080
  • Dubbo Admin console http://localhost:38080
  • Skywalking console http://localhost:8082

task item

Next, try to add some traffic control rules to the mall through the following task items.

Adjust the timeout

By dynamically adjusting the service timeout period during the running period, it is possible to effectively deal with problems such as frequent service timeouts and service blocking caused by unreasonable timeout settings and system emergencies, and improve system stability.

Increase the number of retries

After the initial service call fails, retrying can effectively improve the overall call success rate.

access log

The access log can well record all the service request information processed by a certain machine within a certain period of time, and dynamically enabling the access log in the running state is very helpful for troubleshooting.

The same computer room/area is preferred

Priority in the same computer room/area means that when an application calls a service, it first calls the service provider in the same computer room/area, avoiding the network delay caused by cross-region, thereby reducing the response time of the call.

environmental isolation

By dividing a logical isolation environment for one or more applications in the cluster, it can be used in a grayscale environment or multiple sets of test environments.

parameter routing

For example, traffic is routed based on user ID, and a small number of user requests are forwarded to the latest product version to verify the stability of the new version and obtain user feedback on product experience.

weight ratio

By dynamically adjusting the weight of a single machine or a group of machines through rules, the distribution of request traffic can be changed in the running state to achieve dynamic proportional traffic routing.

service downgrade

The core goal of service downgrade is to aim at these weak dependencies. When the weak dependencies are unavailable or the call fails, the function is kept as complete as possible by returning the downgrade result.

Fixed machine diversion

It helps to quickly reproduce development or online problems by forwarding requests to a certain provider machine.

Guess you like

Origin blog.csdn.net/leesinbad/article/details/132504269