All Products
Search
Document Center

Alibaba Cloud Service Mesh:Use the sidecars that are automatically recommended based on access log analysis

Last Updated:Jan 23, 2024

By default, the information about all services on the data plane is stored in the configuration of each sidecar because the call dependencies between services in a service mesh cannot be determined. You can use the sidecar configuration feature to enable the sidecars of workloads to focus only on the services that the workloads need to call. This topic describes how to use the sidecars that are automatically recommended based on access log analysis.

Prerequisites

Background information

By default, if the control plane or data plane is modified, the control plane needs to push the new configuration to all sidecars on the data plane. Service Mesh (ASM) can obtain the call dependencies between services on the data plane by analyzing the access logs generated by sidecars on the data plane. ASM can then automatically recommend a sidecar for each workload on the data plane. After a sidecar is automatically recommended for a workload:

  • Only the information about the services on which the workload depends is stored in the configuration of the sidecar.

  • If a service on which the workload does not depend is modified, or a resource, such as a virtual service, related to the service is modified, the control plane does not push the new configuration to the sidecar.

Usage notes

  • If you select Use Default for Log Service Project when you enable access log collection for an ASM instance, ASM uses the Log Service project of the first cluster that you added to the ASM instance to recommend sidecars.

  • The sidecar recommendation feature of ASM recommends sidecars based on the service dependencies of each workload. This simplifies the sidecar configuration of the data plane to the maximum extent. However, you must separately configure the feature for each workload on the data plane. In addition, because sidecars are recommended based on access logs, if no service call records exist for a workload in the access logs, the sidecar recommended for the workload may be inaccurate. In this case, you must manually check the recommended sidecar.

Step 1: Generate access logs

In the address bar of your browser, enter http://{IP address of the ingress gateway service}/productpage. Refresh the page of the Bookinfo application multiple times until the page displays black stars and red stars in turns.

Step 2: Recommend a sidecar for a workload

  1. Log on to the ASM console.

  2. In the left-side navigation pane, choose Service Mesh > Mesh Management.

  3. On the Mesh Management page, click the name of the ASM instance. In the left-side navigation pane, choose Mesh Optimization Center > Inbound and Outbound Traffic Configuration (Sidecar Object).

  4. On the Inbound and Outbound Traffic Configuration (Sidecar Object) page, find the workload for which you want to recommend a sidecar and click Recommend in the Actions column.

    If Recommendation complete is displayed in the Recommendation status column of the workload, a sidecar is recommended for the workload.

  5. On the Inbound and Outbound Traffic Configuration (Sidecar Object) page, find the workload for which you want to view the recommended sidecar and click View in the Actions column.

  6. In the Recommended Sidecar panel, verify that the value of the hosts parameter in the YAML file of the sidecar contains all the services that the workload needs to call. Then, click OK.

    If a service that the workload needs to call is not contained in the value of the hosts parameter in the YAML file of the sidecar, add the service name to the YAML file before you create the sidecar.

Step 3: (Optional) Recommend a sidecar for a workload again

The call dependencies between services in an ASM instance may change as business applications are upgraded. If the call dependencies change, the sidecars that ASM recommends for workloads become invalid. In this case, we recommend that you collect logs again and recommend sidecars for the workloads again.

  1. Log on to the ASM console.

  2. In the left-side navigation pane, choose Service Mesh > Mesh Management.

  3. On the Mesh Management page, click the name of the ASM instance. In the left-side navigation pane, choose Mesh Optimization Center > Inbound and Outbound Traffic Configuration (Sidecar Object).

  4. On the Inbound and Outbound Traffic Configuration (Sidecar Object) page, find the workload for which you want to recommend a sidecar again and click Recollecting Access Logs in the Actions column.

  5. In the Recollecting Access Logs message, click OK.

    The sidecar that is applied is deleted, and Recollecting access logs is displayed in the Recommendation status column of the workload.

  6. Re-generate access logs for analysis. For more information, see Step 1: Generate access logs.

  7. Recommend a sidecar for the workload again. For more information, see Step 2: Recommend a sidecar for a workload.