The T family of instances are the best choice if you run a very small application, but occasionally it can handle sudden traffic spikes.

If those spikes are becoming more and more common, your application is consuming the entire host bandwidth and sooner you’ll notice that you application is going to response slower than usual.

In that case, the first instinct is to change the host type with a more powerful one, eventually with one that has fixed-performance (M type, C type, etc). But there is one more thing you can try: the T family offers a feature, named unlimited mode. While this is activated (for hosts in free tier and for any T3 host type it’s activated by default), the host is able to sustain higher CPU usage. But, as expected, this extra power comes with extra cost.  The EC2 documentation (here) gives you all details and many accounting calculations when it’s profitable to use this instead of switching to another host type.

Ideally, it would be nice to enable and disable this feature whenever you needs. We have though on that and, using a metric provided in CloudWatch (CPUCreditBalance, available per auto scaling group), we build 2 Lambda functions.

The whole idea is very simple: setup an alarm to enable unlimited mode when CPUCreditBalance is under a given value. If this value goes too high, we can disable unlimited mode by switching back to standard mode.

Implementation and setup details are available in Github (here).