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.
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.
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.
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:
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:
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?
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).
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!
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):
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
Total: 81.92 USD
Next 4 months
Total: 71.68 USD
Last 4 months
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.
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!
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:
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.
Great! Reach out to me at
email@example.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.
JDP - April 16, 2021
JDP - April 15, 2022
JDP - March 26, 2021
JDP - July 30, 2021
JDP - April 30, 2021
JDP - July 23, 2021
A risk management solution that features real-time analysis and accurate identification and is suitable for all business scenarios.Learn More
Save egress traffic cost. Eliminate all complexity in managing storage cost.Learn More
Accelerate AI-driven business and AI model training and inference with Alibaba Cloud GPU technologyLearn More
Highly reliable and secure deployment solutions for enterprises to fully experience the unique benefits of the hybrid cloudLearn More
More Posts by JDP