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

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

Learn how to get more for less by optimizing your usage of Alibaba Cloud services

By Jeremy Pedersen

Welcome back for the fifth installment in our weekly Q&A blog series! This week we will be continuing to expand on last week's topic: keeping costs low on Alibaba Cloud.

In last week's blog, we looked at ways to save money on storage, networking, and computing costs (mostly related to ECS) by choosing the correct payment plan. This week, we'll focus on usage patterns that can help reduce costs.

Savings Pattern 1 - Overprovision With Dedicated Hosts

If you have predictable workloads that have low average CPU usage but occasionally need to spike, you can save money by taking advantage of the CPU Overprovisioning capability built into ECS Dedicated Hosts.

A Dedicated Host is a single-tenant environment on Alibaba Cloud ECS. This means it is essentially a dedicated server that only your ECS instances run on: it is not shared with other users.

How does this save me money?

Let's say we purchase an r6s Dedicated Host. This type has 52 physical CPU cores, for 104 vCPUs. Further, the r6s type allows an overprovisioning ratio of 4x which means you can treat this Dedicated Host as though it has 416 CPU cores. When you launch ECS instances on top of this Dedicated Host, you can allocate up to 416 CPU cores to your ECS instances. The r6s type also has 756 GB of available memory.

Running an r6s for 1 month would cost 3,534.44 USD (Singapore region).

With overprovisioning, we could run 26 ECS instances on this dedicated host, each with 16 vCPU cores and 24 GB of RAM.

Let's try to make (almost) full use of this capacity by creating:

  1. 20 x (16 vCPU / 32 GB RAM) ECS instances

That uses up 320 vCPU cores and 512 GB of RAM, leaving us with 116 GB of RAM and 96 vCPU cores we can use, so we create:

  1. 48x (2 vCPU / 2 GB RAM) ECS instances

This uses up the rest of our vCPU allocation and leaves 20 GB of RAM unoccupied which we can potentially allocate later (Dedicated Hosts allow custom CPU:Memory ratios, unlike traditional ECS instances deployed in the shared-tenant environment).

So what's the equivalent cost of this resource allocation, if we bought ordinary ECS instances?

  1. 20 x c6.4xlarge (347.60 USD per month, per instance)
  2. 48 x ic5.large (45.67 USD per month, per instance)

The total cost is therefore 347.6 x 20 + 45.67 x 48 which gives a total monthly cost of 9,144.16 USD

This means that the Dedicated Host costs 60% less in this scenario! Of course, we assume here that not all the ECS instances need 100% of their CPU cycles all the time. With a CPU overprovisioning ratio of 4, we need CPU usage to average around 25% of the capacity allocated to each ECS. But there are lots of applications for which that is a reasonable assumption (think Active Directory or Microsoft Exchange).

Savings Pattern 2 - Use Internal VPC Endpoints

Traffic to and from the Internet comes with a cost, regardless of which Alibaba Cloud products you use.

You can avoid these costs by using Internal (VPC) endpoints to connect services together whenever possible. Many common services like OSS offer internal VPC endpoints that other services (like ECS) can use to make connections within Alibaba Cloud's private network.

As an example, in the Singapore region, the cost for outbound traffic is 0.08 USD / GB for traffic usage in the 5 GB to 10 TB range. For 100 GB of Internet traffic, the cost would be 8.00 USD.

That same 100 GB of traffic from a Singapore ECS instance to OSS over the Internal VPC network would cost nothing!.

I can't say it enough: always use internal network endpoints whenever possible!

Savings Pattern 3 - Choose The Right Storage Solution

It's a best-practice to avoid using Cloud Disks for bulk file storage. Instead, use Object Storage Service whenever possible.

Let's compare costs (in Singapore):

  1. 100 GB of ESSD PL0 Cloud Disk space for 1 month: 11.20 USD
  2. 100 GB of OSS bucket space for 1 month: 2.00 USD

This is more than a 5x price reduction!

You can realize further cost savings by using OSS Lifecycle Rules to automatically move older data into "colder" storage tiers, which have an even lower cost per GB.

Let's look at how this saves money:

First, let's assume we keep 1 TB of data in the "Standard LRS" storage tier (OSS's default "hot" storage tier) for 12 months. The total cost would be 1024 GB x 0.02 USD/GB/Month x 12 Months for a cost of 245.76 USD.

What would that cost us if we use Lifecycle Rules to transition between storage classes? It depends a lot on how we configure our Lifecycle Rules, but let's assume we end up with something like this:

First 4 months

  1. 1024 GB in Standard LRS Storage (81.92 USD)
  2. 0 GB in Infrequent Access (IA) Storage (0 USD)
  3. 0 GB in Archive Storage (0 USD)

Total: 81.92 USD

Next 4 months

  1. 512 GB in Standard LRS Storage (40.96 USD)
  2. 512 GB in Infrequent Access (IA) Storage (30.72 USD)
  3. 0 GB in Archive Storage (0 USD)

Total: 71.68 USD

Last 4 months

  1. 256 GB in Standard LRS Storage (20.48 USD)
  2. 256 GB in Infrequent Access (IA) Storage (15.36 USD)
  3. 256 GB in Archive Storage (4.608 USD)

Total: 40.448 USD

Over the whole year, this results in a cost of 194.048 USD. This is about 20% cheaper than leaving all this data in the Standard LRS storage tier.

My advice? Use Lifecycle Rules with your OSS buckets whenever possible.

Savings Pattern 4 - Go Serverless

In general, serverless products will cost you less. For most customers, the biggest part of their cloud spend is Virtual Machine services like ECS, because these need to run 24x7.

For many types of applications, it's really only necessary to run code in response to events, like an API call. For instance, if you had a website that generated memes, you really only need to run your meme generation code when a user submits a new image and caption to your service. This doesn't require you to run a server 24x7. Instead, you can use a service like Alibaba Cloud's Function Compute to do this very cheaply.

Actually, I've covered making memes with Function Compute in a previous blog post!

Comparing ECS and Function Compute

Let's say you have deployed a simple web app that gets 1000 requests a day. Serving each request generates about 512 KB of network traffic.

If you run this workload on a g6e.large instance, it will cost you about 65.22 USD for the month for the instance itself, and the requests will result in about 15 GB of network traffic per month. At the per-Gigabyte price of 0.081 USD that's about 1.22 USD for a total cost of 66.44 USD

If we use Function Compute instead, we have 3 costs we need to worry about:

  1. Function invocation fees (we pay 0.02 USD for each 1 million function calls)
  2. Resource usage (memory used x running time)
  3. Network traffic (0.117 USD per GB)

Over our 1 month span we will only make about 30,000 function calls. This is well within the free tier (the first 1 million calls each month are free), so our function call cost is 0 USD!

If we assume that each request takes about 2 seconds to process and each request uses 1 "compute unit" (1 GB of memory), the cost is 0.000016384 x 1 GB x 2 seconds / request x 1000 requests / day x 30 days/month, which gives us a cost of about 0.98 USD.

Our network costs are the highest cost we incur here, 0.117 USD/GB x 15 GB for a cost of 2.74 USD.

This means that for this example application, Function Compute is more than 20x cheaper than ECS!. This type of savings is not unusual when you switch to a serverless workflow, so it is something to consider strongly if you have applications that are event-driven and are easy to port.

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.

1 1 0
Share on

JDP

71 posts | 157 followers

You may also like

Comments

Dikky Ryan Pratama May 8, 2023 at 4:04 pm

I wanted to take a moment to express my gratitude for the wonderful article you recently published on Alibaba Cloud Blog. Your writing was engaging and insightful, and I found myself fully immersed in the content from start to finish.The way you presented the information was both informative and easy to understand, which made it an enjoyable read for me. Your hard work and dedication to providing high-quality content are truly appreciated.Thank you once again for sharing your knowledge and expertise on this subject. I look forward to reading more of your work in the future.

JDP

71 posts | 157 followers

Related Products