During instance scaling, application upgrades, or service restarts, your application may become temporarily unavailable. Serverless App Engine (SAE) integrates the graceful start and shutdown feature of Microservices Engine (MSE), using service prefetch and delayed registration to ensure business continuity.
Background information
Graceful start
Applications are frequently published, scaled, or restarted. Without protection, a provider service becomes callable as soon as it registers with the service registry, even if it is still performing initialization tasks such as setting up a database connection pool. The graceful start feature controls when and how a new node begins receiving traffic, making it especially useful for high-traffic microservice applications.
Graceful shutdown
When you update an online application, it must stop and restart while maintaining service continuity. In high-concurrency scenarios, directly shutting down a provider instance causes consumers to continue forwarding requests to the offline node, resulting in request errors and traffic loss. Configure graceful shutdown to prevent this during deployment, stop, rollback, scale-in, or reset operations.
Prerequisites
-
You have deployed a Java application using an image or code package. For more information, see Application Deployment.
Important-
This feature applies only to microservice applications created on or after November 8, 2023.
-
Microservices governance applies only to Java applications.
-
-
You have activated MSE Microservices Governance Professional Edition.
NoteAdditional charges apply for using MSE. For more information about MSE billing, see Billing overview of Microservices Governance.
Step 1: Go to the configuration page
-
In the SAE application list, select the destination region and namespace, and then click the target Application ID to go to the application details page.
-
In the left-side navigation pane, choose Microservices Governance > Traffic Governance. Then, click the Graceful Start and Shutdown tab.
To use this feature for the first time, click Enable Microservices Governance and then Refresh the page to access the configuration settings. The enablement process takes about 1 to 2 minutes. Wait for it to complete.
Step 2: Configure graceful start
On the Graceful Start and Shutdown page, in the Graceful Start section, turn on the switch, and then configure the following settings.
|
Configuration item |
Description |
|
Delayed Registration Duration (Second) |
Delays service registration with the registry. Default value: 0 seconds. When this parameter is set to 0, the application receives traffic immediately after registration and no readiness probe is required. When this parameter is set to a non-zero value, service registration is postponed for the specified duration. This setting affects only how new instances come online. Running instances are not affected. Use this parameter if your application performs long-running asynchronous resource loading at startup and you need to postpone when the new node starts receiving requests. |
|
Low-traffic Prefetching Duration (Seconds) |
Open the advanced options to set this value. Traffic prefetch gradually ramps up microservice call traffic to a new node, mitigating reduced processing capacity during a Java application's cold start and preventing spikes in overall response time (RT). After the specified duration, the node handles full traffic. |
Readiness probe requirement for delayed registration
If the Delayed Registration Duration (Second) is set to a value other than 0, you must configure a ReadinessProbe (readiness probe) during application deployment with the following settings:
-
Access path:
/health -
Port:
54199
After you enable microservices governance, the agent automatically listens on port 54199. You do not need to listen on this port in your application. This ensures Kubernetes marks the service as ready only after it fully registers with the registry, preventing traffic drops caused by consumers being unable to find an active provider.
Do not set the liveness probe to the same path (/health). Otherwise, the application may enter an infinite restart loop.
For detailed steps on configuring the readiness probe, see Configure health check.
Step 3: Configure graceful shutdown
After you connect to MSE, graceful shutdown is enabled by default.
You can optionally turn on the proactive notification switch. When enabled, a node going offline actively notifies consumers that it is shutting down, preventing calls to the offline node. This feature is disabled by default. Enable it if your application uses the Spring Cloud framework and consumer calls fail during shutdown.
Disable graceful start and shutdown
Disable graceful start
In the left-side navigation pane, choose Microservices Governance > Traffic Governance. Click the Graceful Start and Shutdown tab. In the Graceful Start section, turn off the switch.
Disable graceful shutdown
Graceful shutdown is enabled by default after you connect to MSE and cannot be disabled separately.
To avoid unnecessary MSE costs, you can navigate to the Basic Information page of the target application, choose in the upper right corner, and disable the feature as prompted.
After you disable the microservices governance feature, other features related to microservices governance (including graceful start and shutdown, canary release rules, and throttling and degradation) cannot be used except for the service list feature. An application restart is triggered when you disable the microservices governance feature. You must determine business risks before you disable the microservices governance feature.