All Products
Search
Document Center

Serverless App Engine:Configure graceful shutdown of microservices

Last Updated:Mar 05, 2024

When you update an online application, you must ensure service continuity during the period in which the application is stopped and restarted. In high concurrency scenarios, if the application instance that serves as the service provider is directly shut down, the application instance that serves as the service consumer cannot obtain the real-time status of the downstream instance. The service consumer continues to forward requests to the instance that is shut down. As a result, a request error is reported and traffic loss occurs. To ensure that your application can be shut down without affecting your business when you deploy, stop, roll back, scale in, or reset the application, you can configure the graceful shutdown feature provided by Serverless App Engine (SAE).

Prerequisites

A microservices application is created. For more information, see Create applications.

Configure graceful shutdown

Warning

After you redeploy an application, the application is restarted. To prevent unpredictable errors such as business interruptions, we recommend that you deploy applications during off-peak hours.

The procedure that can be performed to update an application varies based on the number of instances in the application. This section provides an example on how to configure the required features for an application in which the number of instances is greater than or equal to 1. For information about how to update an application in which the number of instances is 0, see Update an application.

  1. Log on to the SAE console.

  2. In the left-side navigation pane, click Applications. In the top navigation bar, select a region. Then, click the name of an application.

  3. In the upper-right corner of the Basic Information page, click Deploy Application.

  4. In the Graceful Start and Shutdown of Microservices section of the Deploy Application page, click the Graceful Shutdown of Microservices tab. On the tab that appears, turn on Enable Graceful Shutdown for Microservices and click Configuration Wizard of Graceful Shutdown

  5. In the Parameter Configuration for Graceful Shutdown step, configure the parameters and click Configuration Preview. The following table describes the parameters.

    微服务无损下线

    Parameter

    Description

    Enable Graceful Shutdown Governance

    Default value: true. Valid values:

    • true: enables the graceful shutdown governance feature.

    • false:disables the graceful shutdown governance feature.

    Port Occupied by SAE Graceful Shutdown

    Default value: 54199. If the default port conflicts with the application port, specify a new port.

    Waiting Time for Process to Shut Down After Receiving Contextclosedevent Event From Spring

    Default value: 5000. Unit: ms. This value indicates that the process waits for 5,000 milliseconds to shut down after it receives the shutdown event.

    If you configure this parameter and want the setting to take effect, you must set the Enable Automatic Wait parameter to false.

    Enable Automatic Wait

    Default value: true. Valid values:

    • true: enables the automatic wait feature. The process may be shut down when traffic stops.

    • false: disables the automatic wait feature. The process waits for a period of time that is specified by the Waiting Time for Process to Shut Down After Receiving Contextclosedevent Event From Spring parameter to shut down.

  6. In the Configuration Preview step, check the configurations and click Confirm.

    The settings that you configured are automatically synchronized to Environment Variable Settings and Application Lifecycle Management. For more information, see Configure environment variables and Configure application lifecycle management.

  7. After you configure the settings, click Confirm.

Disable graceful shutdown

You can perform the following operations to disable graceful shutdown for your application:

On the Basic Information page, click Deploy Application or Modify Application Configuration. In the Graceful Start and Shutdown of Microservices section, turn off Enable Graceful Shutdown for Microservices and click Confirm.