Skip to main content

ASG's are So, So Good. Let me Tell you About Them.

·2 mins

We’ve all been there, someone wants you to make an application perform faster for cheaper and without having to optimise any code. It’s not a fun ride, but I found the golden ticket out of it: ASG’s and the technologies round them.

What things Used to Be Like #

In a more on-premise centric environment, hearing the word “scalability” would often send shudders down your spine. Yes, you can get another server (or VM) and put a Load Balancer infant of them, but there’s the downsides to go along with that: What if the power at the DC goes out? What if we lose network connectivity? And the one that caused me the most pain… What about Shared Storage?!

That last question is often what drives your costs up massively because all of a sudden you need a SAN or a hodge-bodge of clustered file systems with 0 documentation that turn your 99.9% SLA down a digit (or two).

There’s a Better Way #

Autoscaling Groups Diagram

Learning autoscaling can be quite daunting, and looking through AWS documentation while comprehensive, is quite tough to get your teeth into. Here’s the TL:DR of what AWS Says:

  • Autoscaling groups can be across multiple Availability Zones (Virtual Datacenters)
  • Like any AWS EC2 instance, they can access shared storage such as EFS or FSx which is surprisingly cheap for what it’s worth
  • You can scale based on any monitoring metric (CPU, RAM, NIC usage etc.) and can set the logic for how this scaling should work.
  • Automatic external health checks can be used to instantly relaunch an instance.
  • You can set a minimum instance count, maximum and desired amount.
  • You don’t have to use the same instance type across the whole group and mixing and matching doesn’t stray away from best practice
  • You can even automatically request spot instances rather than having to use on-demand or reserved instances. This can save you tons!
  • ASG’s are free, and you only pay for the instances themselves!

The key combo here in my opinion is using ASG’s , Spot instances and EFS. With this combo, you can have cheap, scalable instances with the storage to match. Running this site, despite being totally unnecessary, I have an ASG that has a user-data config that will automatically mount the EFS share to /var/www/html so any newly created instance can read from the same data as the rest.