×
Community Blog Friday Q&A - Week 4 - Cost Control On Alibaba Cloud: Getting More For Your Dollar (Part 1)

Friday Q&A - Week 4 - Cost Control On Alibaba Cloud: Getting More For Your Dollar (Part 1)

Learn how to get more for less by taking advantage of the correct mix of storage, compute, and networking payment methods.

By Jeremy Pedersen

Welcome back for the fourth installment in our weekly Q&A blog series! This week we will be focusing on a very important question: how to get the most out of Alibaba Cloud without spending a fortune!

Cost Control: Starting From ECS

Cost control on the public cloud can be a complicated subject, regardless of cloud vendor. But don't worry! The Alibaba Cloud Academy team is here to make it a little easier.

In this blog post, we'll focus mostly on Elastic Compute Service (ECS), since this is the major cost center for the majority of Alibaba Cloud customers, but please check back next Friday for even more cost saving tips.

Essentially, ECS costs can be broken down into 3 categories:

  1. Computing (CPU & Memory)
  2. Storage (Cloud Disk)
  3. Networking (Public Internet Traffic)

In general, there are two ways to save money on ECS:

  1. Choose the right payment plan
  2. Choose the right hardware

Of the two, the biggest impact comes from choosing the right payment plan, so we'll focus on that first. We'll address choosing the right hardware in a later blog post.

Choosing The Right Payment Plan

From a billing perspective, there are four types of ECS instances:

  1. Subscription Instances
  2. Reserved Instances (RIs)
  3. Pay-As-You-Go (PAYG) Instances
  4. Preemptible Instances

To make price comparisons between the four types easier, we will compare prices for g6.large instances in Alibaba Cloud's Singapore region.

Tip: If you are flexible about where you deploy your ECS instances, you can save money by choosing a region where ECS instance costs are lower.

1. Subscription: Fixed Costs For Steady Workloads

ECS subscriptions are relatively easy to understand: you pay a fixed amount of money up-front to reserve an ECS instance for a certain amount of time.

A Subscription is permanently tied to a particular ECS virtual machine, so take time to review your ECS instance settings carefully before launching one.

There are two types of subscriptions: monthly and yearly. The yearly subscription is typically cheaper than the monthly subscription. Looking at a g6.large in the Singapore region with a 40 GB system disk, our prices are:

  1. Monthly subscription: 59.70 USD
  2. Yearly subscription: 608.94 USD

If we were to purchase a monthly subscription every month for a year, the cost would be 716.40 USD, so we see that the yearly subscription is about 15% cheaper. In general, longer-term subscriptions are cheaper on Alibaba Cloud.

When Should You Choose A Subscription?

Subscription instances are perfect for predictable, steady workloads. Systems that need to run 24/7 and have relatively predictable load are a great fit for this billing mode. This includes things like:

  1. Bastion hosts
  2. Firewalls
  3. Authentication Services (Active Directory, Kerberos)
  4. Corporate applications (since there is a fixed sized user pool with predictable usage patterns)

Disadvantages Of The Subscription Model

Because a Subscription is tied to a particular ECS virtual machine, you cannot release (delete) a Subscription ECS instance. If you want to move your workload to another Region or Zone, you'll have to apply for a refund through the support team.

If you need the flexibility to move your ECS instances around or change instance types, choose Reserved Instances or Pay-As-You-Go instead.

2. Reserved Instances (RI): A Good Middle Ground

A Reserved Instance (RI) is essentially a discount that you can apply to Pay-As-You-Go ECS instances. An RI is like a "ticket" that entitles you to use a certain type of ECS instance in a particular Region or Zone.

Unlike a Subscription, an RI is not attached to a particular ECS instance. Let's say you purchase a g6.large Reserved Instance (RI). This does not actually create any ECS virtual machines, it simply guarantees you a discount the next time a Pay-As-You-Go g6.large ECS instance is created. This matching happens automatically in the background.

Because the RI is a fairly complex concept, you may want to take a look at this article to get a clearer picture of the RI before continuing on.

There are three types of RI:

  1. All Upfront: Like a traditional subscription, you pay the full cost of the RI all at once
  2. Partial Upfront: You pay 50% of the RI's cost up front, then pay the other 50% using Pay-As-You-Go pricing (usually at a lower rate than standard Pay-As-You-Go)
  3. No Upfront: Exactly like Pay-As-You-Go, but usually at a lower hourly rate than standard Pay-As-You-Go (note that No Upfront is not always available)

Further, there are Zonal RIs which only apply to a specific Zone within a given Region, and Regional RIs which you can use within any Zone in a single Region. The prices for the Zonal and Regional RIs are the same.

Note that in the ECS console you may see the confusing terms Reserved and Not Reserved instead of Zonal and Regional. In the ECS console, Reserved = Zonal, and Not Reserved = Regional.

You can convert between Zonal and Regional RIs whenever you like, so don't worry too much about buying the wrong type.

Wait, So What's The Difference Between Zonal And Regional RIs?

A Zonal RI is limited to a particular instance type and a particular Zone. So an RI for a g6.xlarge in Singapore Zone C can only apply specifically to a g6.xlarge instance launched in Singapore Zone C, not in Zone A or Zone B. The advantage of the Zonal RI is that Alibaba Cloud will reserve capacity for you. This means that you will always be able to launch an instance that matches this RI, regardless of how much demand there is for this instance type from other cloud users in Singapore Zone C.

On the other hand a Regional RI allows you to launch instances in any Zone within a Region. Further, a Regional RI can match multiple instance types within a single instance family. This means that a g6.xlarge RI for Singapore could be applied to two g6.large ECS instances instead, since the CPU and memory used by two g6.large instances is equivalent to one g6.xlarge. Unlike a Zonal RI, a Regional RI does not reserve capacity for you. This means that during periods of peak demand, you might not be able to launch a Pay-As-You-Go instance that matches your RI.

In general, if you aren't sure which type to choose, choose the Regional RI.

Ok, What Else Should I Know About RIs?

RIs can be split and merged. For instance, if I bought an RI for a g6.xlarge, I could split that single RI into two g6.large RIs. This gives me more flexibility in the type and number of ECS instances I can launch.

The Reserved Instance offers 1 Year and 3 Year terms. For longer terms, you can potentially receive an even higher discount than the Subscription instance type offers.

When Should I Choose The RI?

Choose an RI when:

  1. You can make a longer commitment than the 1 Year Subscription
  2. You need more flexibility in releasing, creating, and moving instances
  3. You want a discount you can apply to multiple instances within an instance family

Disadvantages

An RI is not quite as flexible as Pay-As-You-Go: RIs always apply to a particular instance family and Region, and cannot be moved between Regions.

3. Pay-As-You-Go (PAYG): Maximum Flexibility

Alibaba Cloud Pay-As-You-Go instances are billed per-hour. At the end of each month, your usage is calculated and you pay a monthly bill.

Pay-As-You-Go instances are the most flexible type of ECS instance offered: you can release them at any time, and can freely create and release ECS instances in any region using the Pay-As-You-Go payment model. However, this flexibility comes at a cost: Pay-As-You-Go instances are more expensive than either Subscription or RI instances.

When Should I Choose Pay-As-You-Go?

Choose Pay-As-You-Go for fluctuating workloads (game hosting, video streaming) where the ability to automatically grow and shrink capacity is important. The ability to release Pay-As-You-Go instances at any time can save you money during off-peak times, and helps you avoid overpaying due to overprovisioning (buying more ECS instances than you need).

Disadvantages

Cost is the biggest disadvantage for Pay-As-You-Go. PAYG is more expensive than either RI or Subscription. However, because Pay-As-You-Go does not tie you into a particular instance family or Region, it is the most flexible billing type.

4. Preemptible Instances: Save Money On Short-Running Jobs

Preemptible instances are effectively a special type of Pay-As-You-Go instance. They can be 30-50% cheaper than traditional Pay-As-You-Go instances, but their price fluctuates throughout the day and according to supply and demand.

You can think of Preemptible instances as being an auction for unused Alibaba Cloud compute capacity: we auction off unused ECS virtual machine capacity as Preemptible Instances, at a price below the normal Pay-As-You-Go instance price.

How It Works

You submit a "bid" for a particular type of instance. If this bid is higher than (or equal to) the current "market" price for preemptible instances of this type, a new Preemptible instance will be launched.

Once created, the instance has a protection period of 1 hour, meaning the instance will run for at least one hour, regardless of any change in the market price.

After this protection period has ended, the system will check the current "market" price against your "bid" price every five minutes. If your bid price falls below the market price, your ECS instance will be shut down.

Note that you can use automatic bidding if you would like your preemptible instances to remain running: this will automatically match your bid to the market price. The advantage is that your preemptible ECS instance will continue to run despite changes in price, but it also means you could end up paying more for your ECS instance than your initial bid.

When Should I Choose Preemptible Instances?

Use preemtible instances for interruptible background tasks, such as:

  1. Log processing and indexing
  2. Video compression
  3. File format conversion

...or any other task that is non-time-sensitive and can be interrupted and restarted with minimal impact.

Disadvantages

Preemptible instances can be reclaimed by Alibaba Cloud if the hourly price changes. This makes them unsuitable for long-running tasks.

Tying It All Together

Let's do some quick calculations to see what it would cost us to purchase a g6.large in Singapore using the four payment methods described above. We will summarize everything in a table, then explain how the calculations were done so that you can try them for yourself for other Regions or Instance Types:

ecs_pricing

The Pay-As-You-Go prices used were:

  1. Pay-As-You-Go price: 0.126 USD per hour
  2. Preemptible PAYG price (on the day I wrote the article): 0.033 USD per hour

For 1-Year Partial Upfront RIs, the price calculation was:

up-front amount + 6 months x 30 days/month x 24 hours/day x discounted RI PAYG price

For 3-Year Partial Upfront RIs, the price calculation was:

up-front amount + 18 months x 30 days/month x 24 hours/day x discounted RI PAYG price

From the table, it looks like Preemptible instances are the cheapest, but keep in mind that preemptible instance prices fluctuate constantly. In reality, a Preemptible instance run over a long period would likely have a cost somewhere between a PAYG instance and a Subscription instance, and would likely be shut down intermittently (when your bid price falls below the market price).

So What Have We Learned?

Let's sum it all up:

  1. For stable loads over a long period (1 to 3 years) choose Reserved Instances
  2. For stable loads of 1 year or less, choose Subscription Instances
  3. For interruptible batch workloads, use Preemptible Instances
  4. For development, testing, and Auto Scaling, use Pay-As-You-Go Instances

And most important of all: don't forget to mix-and-match! If you have an application which normally has a relatively steady load (say, 5,000 - 10,000 active users) but which sometimes spikes to 20,000 or 30,000 active users, you can run a mix of RI + PAYG or Subscription + PAYG for better savings. Use RI or Subscription to handle steady loads, and PAYG to scale in and out to handle peak loads. Stay flexible!

Storage Pricing

So far, we have talked only about compute pricing. What about storage?

In general, storage pricing is tied to ECS instance pricing: Subscription instances pay for Cloud Disks on a monthly or yearly basis. Pay-As-You-Go instances pay for storage on an hourly basis.

How can we save money on storage across multiple Cloud Disks? What about other types of storage like OSS Buckets, NAS, or ECS Disk Snapshots? That's where the SCU (Storage Capacity Unit) comes in!

The SCU is sort of like an RI for storage: it can be used to reduce the cost for Pay-As-You-Go storage products. Right now, that includes:

  1. Alibaba Cloud NAS (except for "Extreme NAS" or "Infrequent Access NAS")
  2. Alibaba Cloud OSS buckets (supports Standard, Infrequent Access, and Archive storage types)
  3. Alibaba Cloud ECS Disks (Enhanced SSDs, Standard SSDs, Ultra Disks, and Basic Disks, but not local (ephemeral) disks)
  4. ECS disk snapshot costs (except for local (ephemeral) disk snapshots)

Since the SCU is independent from your actual disks, you can create, destroy, and resize disks without needing to change your SCU. If you exceed the size (in GB) of the SCU, the storage that exceeds the SCU will be charged at the normal Pay-As-You-Go rate.

It's also possible to stack SCUs, which means purchasing multiple SCUs that apply over the same period of time, so you can always buy more if you exceed the capacity of your original SCU.

What Are The Limitations?

Each SCU you purchase applies to a particular Region. They can be used to offset the Pay-As-You-Go costs for NAS, OSS, Cloud Disk, and Snapshot storage usage in that Region, but cannot offset Subscription storage costs (say, for Subscription Cloud Disks).

Further, SCUs can't be used to offset the costs of disks created when you create Preemptible Instances.

How Much Money Will The SCU Save Me?

This depends on the size and term of the SCU. Larger SCUs save you more money. SCUs with a longer term (say 1 year or 3 years) also offer greater savings than shorter ones.

SCUs come in different sizes from 20 GB up to 50 TB, but this can be a little misleading, because the actual amount of storage the SCU will "cover" (pay for) varies based on something called the Deduction Factor. This means that a 10 TB SCU could potentially be used to buy 20 TB worth of one type of storage, while only covering 5 TB of another type.

This happens because each service (Cloud Disk, OSS, NAS) has different underlying costs. This is especially true for Cloud Disks, which come in several different types with different levels of I/O performance and throughput.

This will be clearer once we see an example.

A Quick Example

Let's do all our examples assuming we want to buy 10 TB of ESSD PL1 Cloud Disk storage in Singapore.

The SCU prices are easy to calculate. Since ESSD PL1 disk storage has a Deduction Factor of 1, buying 10 TB of ESSD PL1-type Cloud Disk requires a 10 TB SCU:

  1. One month, 10 TB SCU cost: 3,686.40 USD
  2. One year, 10 TB SCU cost: 37,601.28 USD
  3. Three year, 10 TB SCU cost: 66,355.20 USD

Figuring out the Pay-As-You-Go prices for the same amount of disk capacity (10 TB, ESSD PL1) is a little harder. This is because Alibaba Cloud gives disk costs in GiB, not GB, so we have to do some converting.

To keep it simple, I took 10 TB (10,000 GB) and converted it into "GiB" using the Google Search unit converter tool. Searching for "10000 GB to GiB" on Google should show you that 10 TB (10,000 GB) is about 9,313 GiB.

Since the Pay-As-You-Go (PAYG) cost of ESSD PL1 Cloud Disks is 0.05 USD / 100 GiB / Hour, this gives us an hourly cost of 0.05 x 9313/100 = 4.6565 = 4.66 USD / hour.

From here, we can assume a 30-day month, and work out one month, one year, and three year PAYG costs:

  1. One month PAYG cost: 3,355.20 USD
  2. One year PAYG cost: 40,262.40 USD
  3. Three year PAYG cost: 120,787.20 USD

So how much cheaper is the SCU, compared with ordinary Pay-As-You-Go?

  1. One-month: SCU is 110% of the cost of PAYG (PAYG is cheaper)
  2. One-year: SCU is 93% of the cost of PAYG (SCU is cheaper)
  3. Three-year: SCU is 55% of the cost of PAYG (SCU is much cheaper)

So in general, purchasing an SCU is a good idea over the long term, and an especially good idea for very long term storage.

Take a look at the SCU Pricing Page for more information.

When Should I Use SCUs?

Use SCUs when:

  1. You scale capacity in or out using Pay-As-You-Go instances, and want to reduce your average storage costs
  2. You are a regular user of ECS Snapshots, OSS, and/or NAS and want to reduce storage costs for these services
  3. You frequently create, destroy, or resize disks, but don't want to pay the full Pay-As-You-Go price for these resources

Network Pricing

Alibaba Cloud charges for public (IPv4) network traffic in two ways:

  1. Pay-By-Bandwidth (you are charge X USD/hour for a specific bandwidth measured in Mbps)
  2. Pay-By Traffic (you are charged for the actual amount of data transferred, in GB)

Network traffic charges apply to any traffic to and from the public Internet. Typically this means:

  1. Server Load Balancers
  2. ECS instances
  3. Elastic IPs (EIPs)

How can you spread the cost of traffic usage across multiple interfaces without knowing in advance which interfaces will end up generating the most network traffic? How can you avoid locking yourself into a specific bandwidth, if your application experiences frequent traffic spikes?

Enter the Data Transfer Plan. With a Data Transfer Plan, you can pay up front for a certain amount of bandwidth, and then share it among multiple network interfaces.

Data Transfer Plans are either monthly or yearly, and can be anywhere from 50 GB to 50 TB in size. Unlike the SCU, the Data Transfer Plan is usually not limited to a particular Alibaba Cloud Region (such as Shanghai or Singapore). Instead, Data Transfer Plans are limited to a particular geographical area, such as "Mainland China", "Overseas (non-Mainland China)" or "Hong Kong".

How Much Will The Data Transfer Plan Save Me?

This depends on whether you are using Pay-By-Bandwidth or Pay-By-Traffic. Let's consider both of these cases, assuming you have a single ECS instance in Singapore, with a public IP address.

The Pay-By-Traffic-Case

Let's say you use Pay By Traffic, and you find that your average traffic is about 10 Mbps, 24 hours per day.

10 Mbps, 24 hours a day, for 30 days would be about 3,164 GB. The cost per GB in Singapore is 0.081 USD, for a total cost of 256.28 USD.

The Pay-By-Bandwidth Case

Let's assume Pay-By-Bandwidth instead. For 6 Mbps or greater, the cost "per-Mbps" is 0.021 USD/hour. We want 10 Mbps of bandwidth, which gives us a cost of 0.21 USD/hour.

Thus, our total cost for the month ends up being: 0.21 x 24 (hours/day) x 30 (days/month) = 151.20 USD.

So How Much Do We Save With A Data Transfer Plan?

Our total monthly usage was about 3,164 GB, or about 3 TB. For the "Overseas" plan, 3 TB Data Transfer Plan, the price is 189.00 USD.

3 TB = 3072 GB, so we'd still have to cover about 92 GB of traffic costs outside the traffic package. At the Pay-By-Bandwidth rate that would cost about 7.45 USD, for a total cost closer to 196.45.

This is cheaper than Pay-By-Traffic, but a little more expensive than Pay-By-Bandwidth. Let's extend our usage out to a full year, and see how the costs compare. Since the Data Transfer Plan charges by total traffic, we need to extend our 3164 GB out to a full year, for 3164 x 12 = 37968 GB, or about 37 TB. There is no 37 TB Data Transfer Plan, but we are allowed to stack Transfer Plans. So let's assume we buy 8 x 5 TB Data Transfer Plans, for a total of 40 TB of bandwidth:

  1. 1-year Pay-By-Traffic Cost: 3075.36 USD
  2. 1-year Pay-By-Bandwidth Cost: 1814.40 USD
  3. 1-year Data Transfer Plan (40 TB): 2472.00 USD

Again, we see that the Data Transfer Plan is cheaper than Pay-By-Traffic but not as cheap as Pay-By-Bandwidth. So when should we use Data Transfer Plans?

When Should I Use A Data Transfer Plan?

Much like the SCUs we discussed earlier, Data Transfer Plans are best when you need to save costs across multiple Pay-As-You-Go (Pay-By-Traffic) network interfaces. The Data Transfer Plan lets you consolidate costs across multiple interfaces. This makes it ideal for:

  1. Scenarios where you frequently create and destroy public network interfaces
  2. Scenarios where you have a lot of Pay-As-You-Go network traffic (for instance, using PAYG ECS instances with public IPs)
  3. Scenarios where your daily or hourly bandwidth usage is not predictable, but you can roughly estimate monthly or yearly usage

Where Do We Go From Here?

Looking beyond billing, there are other ways to save costs, including:

  1. Choosing the right ECS instance family for your workload
  2. Taking advantage of automation to control resource use (Auto Scaling)
  3. Moving some workloads off of ECS and onto other services like Function Compute, API Gateway, or OSS

We'll take a look at some of these in next week's blog, so stay tuned!

I've Got A Question!

Great! Reach out to me at jierui.pjr@alibabacloud.com and I'll do my best to answer in a future Friday Q&A blog.

You can also follow the Alibaba Cloud Academy LinkedIn Page. We'll re-post these blogs there each Friday.

0 3 1
Share on

JDP

71 posts | 152 followers

You may also like

Comments

JDP

71 posts | 152 followers

Related Products