30.08.2022
9 min read

Making Cloud Economics Work For You. Part 2: Breaking Down the Cloud Costs

We continue the discussion of the major factors driving AWS costs. In this post, we focus on what adopting cloud native means in terms of compute, storage and network.

Making Cloud Economics Work For You. Part 2: Breaking Down the Cloud Costs

Article by

David Christian

If you missed Part 1 of the series, Don’t Treat Cloud Like On-Prem, you can find it here.

 

Compute

In the on-premises data center, creating virtual machines is the main way of hosting workloads. You can also host on “bare-metal,” although today that is an increasingly rare phenomenon. The main data center tools for workload hosting virtual machines (VMs) are VMWare, KVM, possibly Xen, and there are a number of others. A VM contains an entire operating system and all supporting components. Often, as a cost savings measure, multiple workloads are hosted on a single VM.

In AWS a VM is known as EC2. However, while data center technologies work in the cloud, as a rule, data center economics do not. Achieving the desired savings with compute requires cloud native compute.

Cloud-Native Compute: Serverless (Function-as-a-Service/Lambda Functions/Step Functions)

The concept of serverless applies to more than compute, but when it comes to compute, the labels above are basically different ways of saying the same thing. AWS Lambda lets you run code (e.g. a function that performs an action in response to events) without provisioning or managing servers. You can run code for virtually any type of application or backend service, with zero administration. Step Functions are a method of stringing individual functions together allowing for more complex business logic. Serverless compute, when it has no demand, essentially becomes “free to host,” except for the nominal cost of storing it.

Let’s do some quick math to illustrate the financial implications of using serverless compute.

(Note: all prices mentioned are in USD and assume the us-east-1 Region.)

Say you have a single process that gets executed once per second 24 hours per day. Let’s also assume it has a duration of 5 seconds and uses 256 kb of ram and 512 mb of ephemeral storage. The total cost for 432,000 executions of this code using AWS Lambda is around $50 per month.

At the same time, a modestly sized EC2 (m4.xlarge), made highly available (x2) will cost roughly $300 per month. AWS provides you with two basic ways of saving on EC2s: Reserved Instances (RI) and Savings Plans. Both allow you to make one- or three-year commitments on spend, which translate into savings. The chief advantage of an RI is that you can reserve capacity as well. That is, if/when you need that specific capacity, AWS guarantees it will be there. Its chief disadvantage is that it can be complex to manage. Savings Plans allow you to commit to compute spend, without the need to commit to a specific type/class of compute. You are also committed to using that compute in a specific Region. In most cases Savings Plans are the way to go.

Back to our example of two servers at $300 per month. If you are willing to commit to a 3-year savings plan, you can reduce this to $200 per month – still about 4x the cost of using Lambdas.

A final structural way of saving on EC2 compute is the use of spot instances, but your workload has to be capable of supporting VMs that can suddenly disappear with little notice, and the rest of the infrastructure must be able to absorb the loss, at least temporarily. For the workloads that can support it, a spot instance generally will cost ten cents on the dollar versus on-demand EC2 pricing. Spot instances are not a good choice for workloads that carry state on the server. However, they are a strong recommendation for non-production environments.

  • Compute Pro Tip: When EC2s are not in use, turn them off, especially in non-production environments. Using a cron’d Lambda to do this in combination with tagging an EC2 is good way to do this. Some organizations have on-shore, near-shore and off-shore teams making weekday EC2 stoppages inefficient. The weekends are still in play! Let’s say you can only turn them off for the 36 hours starting at late Friday evening until Sunday night when off-shore starts again, let’s call it 36 hours. Turning off an EC2 instance off 20% of the time isn’t nothing, even for spot.

Cloud-Native Compute: Containers

A container is a way isolating a series of processes together and invoking them on demand. Unlike a VM, it shares the operating system and specifically the kernel with “host” system. The processes should be walled off, i.e. anything inside the container should not be able to “reach out and touch” other processes under any circumstances. Therefore, running as root inside a container is highly frowned upon.

In AWS there are seemingly endless ways to host a container, including to hosting a container on a Lambda.

A common way of hosting and operating containers is using a container orchestration platform called Kubernetes (K8s). The AWS K8s service is known as EKS (Elastic Kubernetes Service). Another AWS service to host containers at scale is ECS (Elastic Container Service). An opinionated view is that ECS, overall, is simpler than EKS, while EKS is more flexible and powerful. The decision to use ECS versus EKS will often come down to a team’s expertise in managing K8s. The decision to host on ECS or EKS is not a permanent one, you can always change your mind on how to host a container.

Unlike a Lambda function, which essentially “disappears” until specifically invoked, the host system must be on 24x7. While the minimum cost to run K8s is not zero, it is not consequential for an enterprise workload, and you can also scale up as necessary. This cloud-native approach is far more efficient than running numerous EC2s.

Containers have one big advantage over Lambda: an existing workload can often be containerized with little to no recoding effort. This is especially true for Linux-based workloads. For Windows the story is a bit more complex: you may need to upgrade your code to a library known as .NET core.

For a workload designed for on-premises economics (CapEx), spinning up large numbers of virtual machines is OK, as it does not significantly incrementally increase the overall operational cost of the workload. The underlying hardware has already been paid for. For cloud economics, spinning up a large number of virtual machines under an OpEx model will become prohibitively expensive, especially over time. That bill keeps rolling along, kachink, kachink.

Storage

With the on-premises CapEx model, you may purchase a hard drive intended for your Storage Area Network (SAN). Whether you fill that drive up with data or not matters only insofar as you are concerned about purchasing the next drive.

In the cloud, the OpeEx model means you will be paying for data storage whether you use that data or not. In the cloud you will want to tier your data intelligently so that data you access. You have a range of choices here to. EBS volumes are attached to EC2. FSx (Windows CIFS/SMB) and EFS (Linux/UNIX NFS) are network storage as service, with the advantage not burdening you with managing the compute that facilitates the storage.

The least expensive way to store data is us using S3. S3 is an object store that mimics file system organization. There are ranges of cost with S3, but the choice between one “mode” and any other depends on the size of the object and the frequency that object will be accessed. While you can mount S3 on an EC2, the performance will be prohibitively poor. Yet, S3 can be tiered out on a frequently accessed basis, perhaps you are using S3 to host a website? Or perhaps you rarely access the data, and it is only being stored for compliance purposes, for which you should use S3 Glacier. Below is a rough cost for a 1 TB of data on a number of AWS storage services:

  • EBS (magnetic) without snapshots: $50 per month
  • EBS (GP2) without snapshots: $82 per month
  • High IOPS EBS (io2) without snapshots: $3500 per month
  • Single AZ FSx without snapshots: $84 per month
  • One Zone EFS without snapshots: $44 per month
  • S3 Standard: $24 per month
  • S3 Glacier Deep Archive: $1 per month

The cost of deleting 1 TB of unused data is $0 and on S3 the savings are immediate.

Tiering your S3 data efficiently generally gains importance when you get to petabyte scale. Thinking through EBS use case is something that can be done right away. For example, if you have separated the log and application data away from the OS volume, using magnetic storage for OS volumes can be extremely cost-efficient.

Network

Typically, network services are those you will spend the least on. The decision to spend money on a private connection or encrypted VPN is usually security driven. Nevertheless, you should keep in mind:

  • Data ingress into AWS is free, however you will pay to process and store that data.
  • Moving data between availability zones cost $45 per TB. The same price applies to moving data across a NAT. Supporting two NAT Gateways will cost additional $158 per month. If the data is moving across an application load balancer, that will also cost something. The actual cost is complex to estimate and highly dependent on your workload.

Transferring data from one AWS region to another costs $20 per TB. Obvious things like moving data from an S3 bucket in one region to an S3 bucket in a second region apply, but this also can apply to services like RDS, DynamoDB and VPC peering across regions.

  • Network Pro Tip: When you are moving data from a service like EC2 to another AWS service, like S3, use a VPC API endpoint. There is no data charge for that. If you don’t, the $45 per TB charge will apply. Your security team will also appreciate it.
  • Network Pro Tip 2: If you are moving large amount of data from the on-premises to AWS, the network cost is zero, but you could experience significant latency, and consuming the bandwidth other uses may have can come into play. Consider a service like Snowball or Snowmobile.
  • Network Pro Tip 3: If you are moving cacheable data across the Internet, for websites and RESTful APIs, consider using CloudFront. It will improve performance and reduce costs on compute, network, and storage.

Conclusion

AWS provides the tools that enable OpEx focused, cloud-native deployments of enterprise workloads at a fraction of the cost of your on-premises data center, but it takes reconfiguration, or even more likely, those workloads will need to be refactored before the savings can be realized. A good cloud practice is to focus on compute, storage, and network in that order. The heaviest lift and therefore greatest cost savings will be in the shifting of compute spend.