Saving Costs Through Scheduled Startup and Shutdown on COC
Scenarios
If your services have obvious daily peak and off-peak hours, such as gaming, e-commerce, online education, media entertainment, and data analysis, you can use the COC scheduled startup and shutdown function to reduce resource waste caused by idle ECS instances during non-peak hours. Automated O&M orchestration and scheduled policies enable on-demand startup and shutdown of resources and unattended operation, greatly improving O&M efficiency and reducing cloud resource operations costs.
Solutions
This section describes how to use the scheduled O&M function of COC to automatically start and stop ECS instances at a scheduled time.
You are advised to group instances and bind a unified tag to the instances that need to be started or stopped at a specified time every day. For example, you can group instances by whether to start or stop them every day. After instances are grouped by tag, you can select the corresponding tag to perform unified operations on all instances under the tag when executing scheduled tasks in batches. This greatly improves the management and execution efficiency.
In this case, you can use the scheduled startup and shutdown function of COC to periodically manage instances with specific tags.
The ECS support multiple billing modes. The ECS with different billing modes have different shutdown policies. For details, see How Can I Stop an ECS from Being Billed?
Prerequisites
- You have registered a Huawei account, enabled Huawei Cloud services, and logged in.
- You have created a shift in the shift schedule management module.
Step 1: Add a Resource Tag
- Log in to COC.
- In the navigation pane, choose Resources > Application and Resource Management.
- Select target ECS instances, click
in the tag column, and then click Tag Management.
If the tag column is not displayed in the resource list, click
on the right of the filter box and select Label.
Figure 3 Managing tags
- Click Add Tag to add a tag.
Figure 4 Adding a tag
- Key: Enter machine.
- Value: Enter Stop.
- Click OK. The tag is added.
After adding a tag, you can filter resources by tag key or value.
- In the navigation pane, choose Resource O&M > Automated O&M.
- In the Routine O&M area, click Scheduled O&M.
- Click Create Task.
- On the displayed page, set the basic information. Set Task to StopECS and retain the default values for other parameters.
Figure 5 Setting basic information
- Set the scheduled task rule by referring to Table 1. For details about the parameters, see Creating Scheduled Tasks.
Figure 6 Setting a scheduled shutdown rule
Table 1 Scheduled shutdown rule description Parameter
Example Value
Description
Time Zone
GMT+08:00
Select the time zone where the scheduled task is executed from the drop-down list.
Scheduled Type
Periodic execution
Execute the task based on the specified rule until the rule expires.
Execution Time
Cron
0 0 23 * * ?
Set it using a time expression. For details, see Using Cron Expressions.
0 0 23 * * ? indicates that the shutdown task is executed at 23:00 every day.
Rule Ended
-
Configure the end time of the rule. The scheduled task is executed periodically based on the user-defined execution period until the rule end time.
- If Task Type is set to Jobs, set the task by referring to Table 2.
Figure 7 Selecting a job
Figure 8 Selecting ECS instances
Table 2 Job task configuration description Parameter
Example Value
Description
Jobs
Stop_ECS under Public Jobs
Select a job from the drop-down list. You can select a custom job or public job.
IAM Agency
ServiceAgencyForCOC
To prevent scheduled task execution failures due to insufficient agency permissions, the IAM agency is set to ServiceAgencyForCOC by default, and you need to apply for the action permission of iam:agencies:pass.
Target Instance Mode
Consistent for all steps
All tasks are executed on the selected instances using the same batch policy.
Job Execution Procedure
-
Use default steps of public jobs.
Target Instance
Target ECS
Click Add, filter instances by tag, and select the target ECS instances.
Batch Policy
Auto-batch
The selected instances on which you want to perform operations are automatically divided into multiple batches based on the preset rule.
- Set Manual Review.
Table 3 Parameters for manual review Parameter
Example Value
Description
Manual Review
On
After this function is enabled, the task needs to be reviewed. For details, see Reviewing Scheduled O&M Tasks.
Reviewer
Shift
Select a shift scenario and corresponding roles from the drop-down lists. For details about how to configure a shift, see Shift Schedule Management.
Notification Mode
Default
Same as that selected in the reviewer subscription function. For details about how to set the default notification mode, see Configuring the Notification Mode for a Subscriber.
- In the navigation pane, choose Resource O&M > Automated O&M.
- In the Routine O&M area, click Scheduled O&M.
- Click Create Task.
- On the displayed page, set the basic information. Set Task to StartECS and retain the default values for other parameters.
Figure 9 Setting basic information
- Set the scheduled task rule by referring to Table 4. For details about the parameters, see Creating Scheduled Tasks.
Figure 10 Setting a scheduled startup rule
Table 4 Scheduled startup rule description Parameter
Example Value
Description
Time Zone
GMT+08:00
Select the time zone where the scheduled task is executed from the drop-down list.
Scheduled Type
Periodic execution
Execute the task based on the specified rule until the rule expires.
Execution Time
Cron
0 0 8 * * ?
Set it using a time expression. For details, see Using Cron Expressions.
0 0 8 * * ? indicates that the startup task is executed at 08:00 every day.
Rule Ended
-
Configure the end time of the rule. The scheduled task is executed periodically based on the user-defined execution period until the rule end time.
- If Task Type is set to Jobs, set the task by referring to Table 5.
Figure 11 Selecting a job
Figure 12 Selecting ECS instances
Table 5 Job task configuration description Parameter
Example Value
Description
Jobs
Start_ECS under Public Jobs
Select a job from the drop-down list. You can select a custom job or public job.
IAM Agency
ServiceAgencyForCOC
To prevent scheduled task execution failures due to insufficient agency permissions, the IAM agency is set to ServiceAgencyForCOC by default, and you need to apply for the action permission of iam:agencies:pass.
Target Instance Mode
Consistent for all steps
All tasks are executed on the selected instances using the same batch policy.
Job Execution Procedure
-
Use default steps of public jobs.
Target Instance
Target ECS
Click Add, filter instances by tag, and select the target ECS instances.
Batch Policy
Auto-batch
The selected instances on which you want to perform operations are automatically divided into multiple batches based on the preset rule.
- Set Manual Review.
Table 6 Parameters for manual review Parameter
Example Value
Description
Manual Review
On
After this function is enabled, the task needs to be reviewed. For details, see Reviewing Scheduled O&M Tasks.
Reviewer
Shift
Select a shift scenario and corresponding roles from the drop-down lists. For details about how to configure a shift, see Shift Schedule Management.
Notification Mode
Default
Same as that selected in the reviewer subscription function. For details about how to set the default notification mode, see Configuring the Notification Mode for a Subscriber.
Step 3: Verify the Execution Result
- In the scheduled O&M task list, view the scheduled task created in Step 2: Create a Scheduled Task.
Figure 13 Viewing the scheduled task
- After the scheduled task is approved, check that the task is effective.
- Until the scheduled time is reached, check that the instances are stopped.
Figure 14 Scheduled shutdown
- Until the scheduled time is reached, check that the instances automatically start.
The scheduled startup and shutdown tasks will be automatically executed based on the scheduled policy.
Figure 15 Scheduled startup
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot