AWS Cost Control - Designing for Cost - go Serverless!


In most AWS environments, the compute costs - generally EC2 - are a significant proportion of the monthly bill. A couple of years ago we would have just shrugged and said ‘well of course, compute is expensive and every project needs it’. Well it doesn’t have to be as expensive any more. When designing solutions you now have three main options for deploying compute resources.

The standard way is still EC2. It works well for our traditional workloads, where you need ultra high performance - MapReduce, cluster or GPU compute for example. You also get a high level of isolation - AWS distributes load for you so one busy EC2 instance should not affect another instance. You have a high level of security isolation too - AWS handles the hypervisor security so EC2 instances can not talk to one another unless you enable it. EC2 is often the choice for Windows workloads where other compute options are either not available at all or Microsoft licensing makes deployments difficult. EC2 - it’s still a valid choice but it’s often not the most cost effective choice. If we’re awarding unicorns for cost it gets one unicorn.

Next there are containers. Here we are talking about the AWS service ECS, Docker or unikernels such as CoreOS. If you are not aware of containerisation, well, it’s a very wide and complex topic, but think of it as sub-virtualisation. Effectively you are bundling an application and anything it needs to run into a small container and running multiple containers on a number of EC2 instances. At the time of writing the smallest EC2 instance is the t2.nano with half a GB RAM and a single CPU. But even this is too large a block of compute for some applications. Container solutions allow you to subdivide EC2 instances, move containers between hosts seamlessly, apply resource allocations and so on. In the specific cost case, containers allow us to consolidate multiple applications onto EC2 host instances and drive up utilisation of those hosts to higher levels than is possible on bare EC2. On the downside, container solutions can be very complex to install and maintain. Score: two unicorns.

Finally we have serverless solutions. You must have heard of serverless, it’s been everywhere lately. Serverless doesn’t mean that there are no servers involved - it means you don’t care much about the servers any more, they are Somebody Else’s Problem. You write some code - AWS supports C#, Node, Java and Python - upload it, tie it to an event and your code runs in response to that event. The classic example is image resizing. You write code that resizes an image to thumbnail size and saves it to a destination S3 bucket. You upload that code as a Lambda function. You wire the Lambda function to a source S3 bucket. When an image is uploaded to the source bucket your Lambda function fires off and does the image resize and saves the new image. Serverless is sometimes called event driven computing as you need an event of some kind to fire off your function - in this case the event is the S3 image upload, but it could be an item in an SQS queue or just a time interval - Lambda supports cron for scheduling functions. You don’t manage any servers - AWS manages it all for you. Some compute resource is provisioned for you when your code needs to run, and that resource is deprovisioned when your code is finished. You are charged for the run time of your code and the amount of memory required. (And, as always, some data transfer costs may be involved). So no server security patching or other management, no excess capacity. It’s a cost control dream. Massive unicorn factor! 1010.

Like what you see? This article is an excerpt from my course AWS Cost Control - a guide to identifying resources, reducing usage and designing for cost - all part of the mission to help you Spend Less on AWS. Nearly five hours of practical cost saving tips and tricks - available now for just US$29.

Need more personal attention? My consultancy company, Vault Solutions, can help with one-off or ongoing AWS cost and security consultations, best practise workshops and more. See for more.