Reduced Pricing for Azure Container Instances
ACI - great for short-lived workloads
Azure Container Instances is a great service that combines the benefits of containers and "serverless". They make it really simple to run a container in the cloud without needing to pre-provision any servers at all. And the billing model is per-second - only pay while your containers are actually running, which can result in dramatic cost-savings.
This makes them a great choice for short-lived or "bursty" workloads. There's no need to pay for a VM sitting idle most of the time when it's this quick and easy to spin up a container to do some work and then exit. In my Azure Container Instances: Getting Started course on Pluralsight, I provided some calculations to show when you would save money with ACI containers versus an always-on VM.
Up until recently, my recommendation was to only consider ACI if you were sure that at least half the time you didn't need the container running. And that was because the original pricing of ACI worked out to about double the cost of a VM. There were savings to be had, but only when you were dealing with occasional workloads.
Reduced ACI prices
However, recently the ACI pricing was reduced which makes them a much more attractive proposition for situations where you don't need compute all the time, but you do need it most of the time. Let's do some quick calculations with the handy Azure pricing calculator.
For comparison purposes I've chosen to look at US dollar pricing in East US, but it should be roughly similar whatever your region.
If we price up a Linux ACI instance with 1 vCPU and 1GB of RAM that costs $32.81 per month. If we switch up to 2 vCPU's and 8GB RAM, then it's $85.12 per month. If we compare that to running a D2 v3 Virtual Machine (with 2 vCPUs and 8GB RAM) that costs $70.08 per month. So although the VM is still cheaper in an always-on scenario, the difference is much closer (ACI costs about 20% more in this example).
With this new pricing, your container could run 20 hours a day before it matched the cost of an always-on VM.
Windows costs more
It's worth pointing out that there's an additional charge for Windows (an extra $63 in this example). This means the same size Windows ACI container costs $148.19 to run for a month, compared with $137.24 to run Windows on the equivalently sized D2 v3 VM. The ACI markup is smaller in this example - only about 10% more.
What should I use?
VM's still win in always-on scenarios, so if you're running a web-site that needs to be available 24/7, ACI is not the best choice. But in almost all other cases, if your workload doesn't need to run all day every day, ACI has potential to save you some money.
One advantage VM's do still have up their sleeve is the substantial "reserved instance" pricing discounts. If you have those available, then it may be cheaper to run VMs even if they sit idle for half the time.
There are a few more considerations when picking between VMs and ACI. If your usage patterns are very predictable - e.g. you only run during working hours on weekdays, then you can automate turning VMs on and off (make sure it's stopped deallocated) as a way of cutting costs without needing to use ACI. But booting VMs is typically a lot slower than starting a container, so ACI will be more responsive when load is unpredictable and you want to start up new instances quickly. ACI also likely will have lower memory requirements - there isn't as much OS overhead, meaning that an 8GB VM might be actually more comparable to a 7GB container instance, making the pricing comparison even closer.
In short, you should do your own calculations to make the decision whether you'd get the cheapest compute with VMs or ACI, but the reduced ACI pricing makes them a much more attractive option in many scenarios. It also makes the AKS Virtual Kubelet and AKS Virtual Nodes a much more compelling option, which use the elastic scale of ACI to rapidly scale applications on AKS.