Tencent cloud technology community – Jane book home page continues to present cloud computing technology articles, welcome your attention!
The public cloud provides many advanced functions for free, but many small and medium users think they can’t use them. In fact, with a little research, you can enjoy a lot of convenience and save a lot of money.
This solution uses auto-scaling to reduce server costs and is suitable for almost all cluster deployed websites/apps. The setup is also very simple.
Business scenarios:
If your business meets the following criteria, take 5 minutes to configure this solution and save 20%-30% :
-
The website uses the way of cluster, and cluster more than 1 or more servers;
-
The site has long periods of downtime. The peak time of most websites is no more than 8 hours, and the remaining 16 hours can completely reduce the idle server capacity processing.
This paper takes a leisure website as an example. The peak hours of the website are from 20:00 to 24:00.
Plan outlining the
-
Fixed resources can be deployed based on load during off-peak hours, and the CVM can be deployed on a monthly basis.
-
The shortfall during peak hours uses a pay-as-you-go CVM. Capacity expansion by scheduled task at 20:00 and capacity reduction at 24:00.
Comparison of old and new schemes:
earnings
Assuming that the original plan requires two 4-core 4G CVMS, change to a 4-core 4G CVM + 4 hours of temporary CVM every day, which can save about 30% of the cost.
The small site in the example can save 1,800 yuan per year:
Specific operation
The site structure of the example is relatively simple, with only one cluster of application servers. For a complex website, there are clusters of application servers, front-end servers, and cache servers. Each cluster can perform similar operations. Each cluster has a scaling group.
Step 1. Create a custom image for the cluster
This step is very simple, based on a ready-made cluster machine. If in doubt, see Creating a custom Image >>
Note: You need to deploy the environment in the image in advance to ensure that the application in the image can be started with the operating system, so that the expanded machine can work directly without manual intervention.
Step 2. Create a startup configuration
During capacity expansion, AS uses startup configuration AS the template to create machines, so we specify regions, models, and images through startup configuration in advance.
-
Log in to the elastic scaling console, and click Start Configuration in the navigation bar.
-
Select the project and region where the Web application resides.
-
The next steps are similar to buying a machine and you can follow the instructions to create the boot configuration. Note that in the custom image, specify the image you just created.
Step 3. Create scaling groups for the machine
On the elastic scaling console, click “New” and fill in the management information of the cluster as follows:
-
Name: Choose a name as needed. For example, I’ll put “Application server cluster” here
-
Minimum scaling: Specifies the lower limit for the number of cluster servers. In this example, you can fill in 0.
-
Start number of instances: specifies the number of machines automatically created when a scaling group is created. Note Machines are not automatically created after scaling groups are created. You are advised to set this parameter to 0.
-
Maximum scaling: Specifies the maximum number of servers in a cluster. Set this parameter as required. In this example, a scaling group contains a maximum of five machines.
-
Startup Configuration: Select the startup configuration you just created.
-
Supported Network: The network environment of the session server. Generally, select Basic Network.
-
Available zone: Select the available zone in which the server expansion container resides. Select the available zone in which the session server resides.
-
Move out policy: Select the default.
-
Load balancing: Load balancing for the cluster.
Finally, click “OK” to complete the creation.
Step 4. Add existing machines to the scaling group
-
On the console, click the name of the scaling group to access the management page, and click Add Cloud Host in the lower part of the page.
-
In the dialog box that is displayed, add existing servers in the cluster to a scaling group. If this is an off-peak period, underutilized servers in the cluster can be returned to save money.
-
After the server is added, set Avoid Scaling to prevent the scaling group from selecting the server for scaling down. This machine in the cluster is always in service and the AS does not change it.
Step 5. Set the expansion and contraction policy (key!).
AS supports periodic capacity expansion or dynamic capacity expansion based on alarms. You can also receive capacity expansion notifications and view historical capacity expansion details. You have everything under control.
- Set a scheduled capacity expansion task at 20:00
Note: The CVM of Tencent Cloud takes about 1 minute to create. If the custom image is large, it may take more time. You can advance the execution start time by 5 minutes.
- Then set a scheduled capacity reduction task at 24:00
And that’s it!
The background cluster of the website changes to one fixed application server + one application server that is created periodically during peak hours.
Other cluster machines that are not part of a scaling group are underutilized most of the time and can be refunded for cost savings.
Related to recommend
How to use Tencent Cloud to build distributed application cloud server to build Python environment
This article has been published by Tencent Cloud technology community authorized by the author. Please indicate the source of the article when reprinted. For more cloud computing technology dry goods, please go to Tencent cloud technology community