A credit is 100% CPU for 1 minute or 50% CPU for 2 minutes, etc.
A t2.nano gets 3 credits per hour.
Based on this, I calculate that 1 credit is equal to 1.65% CPU for 60 minutes. So 3 credits add up to about 5% CPU for 60 minutes at which point you will have received another 3 credits. So by these calculations, a continuous workload of 5% CPU every minute of every day should be credit neutral. Here’ the CPU usage on some t2.nanos.
Credits are consumed LIFO, not FIFO, and they expire after 24 hours.
If your credit balance is high enough that your oldest credits hit their 24hr expiry, every hour you’ll see the nominal credit burn rate plus old credits expiring at the rate they were accumulated.
I mean none of this changes the fact that these machines are doing a 2% idle and still losing credits. However the math works, it seems like there’s no practical value in the product if I can’t have the machine sit idle and gain credits to “burst” with later.
If the machine’s sitting idle consuming close to zero credits from the top of the stack while its oldest credits expire off the bottom, you’re going to see a nonzero burn rate. You need to have enough load or load spikes to burn down credits before they have a chance to expire.
re:practicality, it’s a matter of timescale. If you want to hit an effective 15% duty cycle and make good use of credits, but need to be able to sit idle for hours to days, T2 is perhaps not the right platform versus something like ECS. If your load cycles have a period of minutes to hours, it’s less likely you’ll lose credits to expiration.
I think what I’m hearing is that t2 instances aren’t meant to be run for more than 24 hours… at any workload. Since both ECS anis based on EC2. Saying “use ECS” seems like you’re saying “use a different type of EC2 instance”. The problem with this is that the smallest (non-burst) instance is a m3.medium. Using 1yr reserved instance pricing as a benchmark, we are talking about $30 for a t2.nano vs $350 m3.medium. That kinda breaks the bank for me.
Amazon Lightsail looked promising, but then I read they are just t2 instances in disguise. I think I might have to take the whole project to DigitalOcean where small, affordable always-on instances are a thing.
I think what I’m hearing is that t2 instances aren’t meant to be run for more than 24 hours
I think it’s more like they’re not meant to be idled for more than a few hours— or, rather, they don’t want to incentivize long idles and long bursts through the credit mechanism.
Since t2 seem to be just a higher degree of multi-tenancy than other instance types, it makes sense that they’d favor more uniform, higher frequency but still “spiky” workloads to avoid starving the other tenants.
And yeah regarding ECS i’m just not clued into what you’re working on here so that suggestion is probably way off base. DO/Linode/Vultr are definitely better choices for small, cheap, always-on boxes if you’re not vendor-locked
Apparently, you can have up to 100 burst instance restarts per 24 hours. Each time an instance restarts it’s credited with a new cache of burst credits! It also resets the expiration of credits. Since I’m running a distributed application, restarting one instance isn’t that big of a deal, so it works well with my architecture. In fact, it kinda justifies some of the complexity.
Here’s a tool to make sure only one machine in a given set of machines is restarting at any given time https://github.com/coreos/locksmith which gives me a lot of ideas. For example, it would not be difficult to make a script to monitor the credit balance through the CloudWatch API and reboot if the credits go below a certain threshold.
Since these t2’s are some of the most economical VM’s in the entire cloud, it’s worth it to figure out how to use them properly.