Cost optimization best practices
This topic describes the cost structure and benefits of Elastic Compute Service (ECS). It also provides recommended cost management solutions to help you save costs, stay within budget as your business grows, and maximize your return on investment.
Cost structure
The cost of traditional enterprise IT infrastructure is measured by its Total Cost of Ownership (TCO), which includes all expenses from product procurement through ongoing use and maintenance. When evaluating IT infrastructure, you are effectively assessing the TCO per unit. Calculating TCO requires using real-world variables from your business deployment environment. For example, you must consider factors such as rack rental fees, electricity costs, server brands and prices, and whether redundant hardware is used to mitigate single points of failure. This leads to the formula: TCO = Server costs + Network costs + Data center expenses + Other overheads (such as personnel, public bandwidth, and additional taxes).
In this breakdown, server procurement and network construction represent capital expenditures (CAPEX). Your company purchases these assets and depreciates them over a set period. The remaining data center expenses—such as rent and electricity—and other overheads are primarily operational expenditures (OPEX), which accrue continuously as resources are consumed. From a business perspective, CAPEX requires a large, one-time investment and carries high uncertainty. Once committed, there is little room for adjustment, and changes in demand may render the initial investment wasteful. In contrast, OPEX is more stable and offers greater flexibility to adapt to business changes. Converting CAPEX to OPEX is therefore a better approach for managing uncertain demand.
Elastic Compute Service (ECS) is a cloud computing service from Alibaba Cloud that provides compute resources. Replacing your traditional IT infrastructure with ECS helps reduce CAPEX and increase the proportion of OPEX, improving your company’s cash flow and risk management capabilities. When using ECS, costs fall into two main categories:
Ownership costs: These include fees for using various resources and resource plans, such as:
Instance type fees
Disk capacity fees
Image fees
Public bandwidth fees
Snapshot fees
O&M costs: These are personnel-related expenses incurred while using ECS, including the following:
System administration and maintenance
Security monitoring and protection
Troubleshooting and repair
Software updates and configuration
Cost advantages of the cloud
Building your own data center involves direct costs for hardware, networking, power, and personnel. It also includes scaling costs—such as upgrades and expansions—and risk management costs, such as backups and high availability (HA). As a data center grows, the cost per resource and system complexity increase, while fault tolerance decreases. Poor planning for business changes can lead to unnecessary spending.
In contrast, using cloud resources eliminates upfront investments in hardware, physical infrastructure, and personnel. The cost per resource becomes more predictable, and resources are available on demand with rapid delivery. Beyond resource cost advantages, the cloud also offers multiple billing methods to further optimize expenses.
Cost optimization suggestions
Aggregate costs
In Expenses and Costs, review your bills to understand your spending. Track costs across multiple dimensions to identify optimization opportunities.
Use the Billing Overview feature on the Bills page to view spending trends and product consumption distribution, giving you an overall picture of your expenses.
Use resource groups and tags to categorize resources by business unit, department, or project, enabling accurate cost allocation.
Use the Billing Details feature on the Bills page to view detailed resource consumption. Combined with resource groups and tags, this lets you aggregate costs with finer granularity.
For example, create tags such as department:research, department:finance, and department:IT, and attach them to your ECS instances. When reviewing billing details, you can filter by these tags to see resource usage by department, helping you aggregate costs and identify optimization targets.
Optimize resources
After identifying high-cost resources, monitor them from multiple angles to determine the root cause and apply targeted optimization measures.
Monitor resource usage.
Monitor resource utilization to assess whether the current configuration is oversized. For example, check CPU, memory, disk, and bandwidth usage.
Monitor idle resources to prevent waste. Examples include instances that were upgraded but not restarted, reserved instances not matched to any running instance, unattached disks, and unassociated elastic IP addresses (EIPs).
Monitor how long resources are used. If you rely on pay-as-you-go resources—such as instances and disks—for extended periods, consider switching to more cost-effective options like subscription or resource plans.
Monitor the lifecycle of resources to track expiration dates for subscription-based assets and renew them promptly. Examples include subscription instances, reserved instances, and Storage Capacity Units.
Choose the right instance types.
Instance types significantly affect ECS costs. Select the most cost-effective instance types for your workload and adjust quantities as needed. Aim for high resource utilization while meeting business requirements to reduce expenses.
For example, in a short video processing scenario, you currently use 10 d1ne.14xlarge instances. After monitoring, you find memory usage is reasonable but CPU is underutilized. You can:
Slightly reduce the CPU-to-memory ratio to better align with business needs and increase CPU utilization. The d1ne.14xlarge instance has a 1:4 ratio, while the d2s instance offers a 1:4.4 ratio. Replace the 10 d1ne.14xlarge instances with 13 d2s.10xlarge instances. By switching from 14xlarge to 10xlarge, you can reduce costs by approximately 18%.
For more information about selecting instance types, see Best practices for instance type selection.
Combine multiple billing methods.
Different workloads have varying resource usage patterns. Choose the appropriate billing method for each and combine them flexibly for optimal results.
For stable workloads, use subscription or reserved instances.
For stateful and dynamic workloads, use pay-as-you-go.
For stateless and fault-tolerant workloads, use spot instances.
Reuse ECS instance resources with Dedicated Hosts (DDHs).
For scenarios where absolute CPU stability is not critical—such as staging environments—use over-provisioned DDHs. This lets you deploy more ECS instances of the same type and lowers the cost per deployment.
ECS instances deployed on a DDH do not consume resources when stopped. You can also stop some instances during off-peak hours in your production environment and repurpose the freed-up capacity for predictable, cyclical tasks such as offline computing and automated testing.
Upgrades and replacements
Continuous ECS enhancements, along with hardware upgrades such as newer processors, improve performance and reduce costs. Generally, newer instance types offer better price-performance than older generations.
For example, the following table compares the performance and pricing of upgrading from g5.2xlarge to g6.2xlarge:
Performance | Price |
|
|
To adopt the latest instance types promptly:
Design robust applications that run reliably across different instance types.
Monitor new instance type releases on the Alibaba Cloud official website and evaluate whether a switch is beneficial.
Example of upgrades and replacements
By following the replacement plans below, you can improve performance and reduce instance costs by at least 15% while maintaining the same CPU and memory configurations:
Current instance family | Top recommendation | Alternative recommendation |
sn1, sn2 |
|
|
c4 | hfc6, c6 | hfc5, c5 |
ce4 | r6 | r5, se1ne |
cm4 | hfc6 | hfc5, g5 |
n1, n2, e3 |
|
|
|
|
|
Develop a cost-saving mindset
A key advantage of cloud resources is on-demand access, which avoids the high upfront investment required for self-built data centers. To fully leverage this benefit, integrate cost optimization into your daily operations. Sustained effort is essential to achieve optimal results. The following are common practices you can adapt to create a plan tailored to your needs.
Hold regular cost reviews. Periodically assess budget execution with stakeholders—including finance and developer teams—evaluate optimization outcomes, and refine your strategies.
Enforce consistent tagging. Use tags to classify resources by business unit, environment, and owner to simplify daily cost tracking.
Categorize resources and tailor their usage. For example, use pay-as-you-go instances for short-term staging environments and release them immediately after project completion.
Avoid idle resources. Regularly audit usage and establish clear procedures for identifying and handling unused resources.
Renew subscription resources promptly. Secure budget approval in advance to avoid the extra costs of re-purchasing and redeploying resources after expiration and release.
Implement automated O&M
Alibaba Cloud offers a comprehensive suite of O&M products to enhance operational efficiency and reduce manual effort. Examples include the following:
Auto Scaling: Maintains a cluster of instances across different billing methods, zones, and instance types, ideal for workloads with fluctuating demand.
Auto Provisioning: Deploys a cluster of instances across multiple billing methods, zones, and instance types with a single click, suitable for scenarios requiring rapid delivery of stable computing power while leveraging spot instances to lower costs.
CloudOps Orchestration Service: Defines O&M operations as templates to efficiently execute tasks, ideal for event-driven, scheduled, batch, or cross-region O&M scenarios.
Resource Orchestration Service: Deploys and manages a stack of interdependent cloud resources with a single click, suitable for delivering complete systems or cloning environments.