All Products
Search
Document Center

Microservices Engine:Configure graceful start and shutdown in YAML

Last Updated:Oct 12, 2024

For online applications, operations such as release, scale-out, scale-in, and restart are necessary. Microservices Engine (MSE) provides the graceful start and shutdown features to protect applications when you perform the preceding operations. The graceful start and shutdown features provide capabilitues such as service prefetching, delayed service registration, and proactive notification. This topic describes how to configure the graceful start and shutdown features in YAML.

Step 1: Grant permissions to an ACK cluster

Find the RAM role whose name contains KubernetesWorkerRole. The RAM role is assumed by Container Service for Kubernetes (ACK) clusters. Then, grant the RAM role the permission to call the ModifyLosslessRule operation of MSE. For more information, see the Grant permissions to the worker RAM role section in the "[Product Changes] Permissions of the worker RAM role of ACK managed clusters are revoked" topic.

When you create a custom policy, you must modify the policy content. On the Create Policy page, click the JSON tab and add the following content to the code editor:

{
  "Action": [
    "mse:ModifyLosslessRule"
  ],
  "Resource": "*",
  "Effect": "Allow"
}

Step 2: Configure a graceful start and shutdown rule

  1. Enable MSE Microservices Governance for a microservice application in the ACK cluster. For more information, see Enable Microservices Governance for microservice applications in an ACK cluster.

  2. On the Workloads page of the application, configure the parameters. For more information about the parameters, see Graceful start and Graceful shutdown.

    • The parameters are configured in spec > template > metadata > labels.

    • The following table describes the parameters.

      Parameter

      Description

      Default value

      mse.lossless.enable

      Specifies whether to enable the graceful start feature.

      • true

      • false

      false

      mse.lossless.warmupTime

      The prefetching duration. Unit: seconds.

      120

      mse.lossless.delayTime

      The latency of service registration. Unit: seconds. If you specify a value of x for this parameter, the application or service is registered with Microservices Registry x seconds after the application is started.

      0

      mse.lossless.notice

      Specifies whether to proactively send notifications to the consumer when the provider is shut down.

      false

    • Sample code:

      mse.lossless.enable: 'true'
      mse.lossless.delayTime: '30'
      mse.lossless.warmupTime: '60'
      mse.lossless.notice: 'false'

Verify the result

  1. Log on to the MSE console, and select a region in the top navigation bar.

  2. In the left-side navigation pane, choose Microservices Governance > Application Governance.

  3. On the Application list page, click the resource card of the destination application.

  4. In the left-side navigation pane, click Traffic management. On the Graceful Start/Shutdown tab of the page that appears, check that the configurations of the graceful start rule are the same as the configurations in YAML. When you start or shut down the application, you can check that the events and queries per second (QPS) trend chart match the configurations in YAML on the Graceful Start/Shutdown tab of the Traffic management page.

Note
  • After you configure a graceful start and shutdown rule in YAML, the application is immediately restarted. After the application is restarted, the configured rule takes effect.

  • If you do not configure the parameters of a graceful start and shutdown rule in YAML, the default values of the parameters are automatically used.

  • If you modify a graceful start and shutdown rule for an application by using YAML on the Workloads page of the application and also modify the rule in the MSE console, the modification performed by using YAML takes precedence. If you modify a graceful start and shutdown rule in the MSE console, the rule configured by using YAML overwrites the existing rule in the console after the application is restarted.