Posts Tagged: t1.micro

AWS lowers cloud pricing by launching the T2 instance type that can burst to handle occasional workload spikes

Amazon Web Services cloud platform logo

T2 instances are Burstable Performance Instances that provide a baseline level of CPU performance with the ability to burst above the baseline. The baseline performance and ability to burst are governed by CPU Credits. Each T2 instance receives CPU Credits continuously at a set rate depending on the instance size.  T2 instances accrue CPU Credits when they are idle, and use CPU credits when they are active.  T2 instances are a good choice for workloads that don’t use the full CPU often or consistently, but occasionally need to burst (e.g., web servers, developer environments, and small databases).

Continue reading

AWS t1.micro 100% CPU

Sometimes EC2 CloudWatch monitoring shows 100% CPU usage, but when you SSH into your instance and check it with ‘top’, it’s hard to tell what is happening. Amazon is probably “borrowing” some of your CPU cycles to give to someone else who needs them. This is standard practice in a virtualized environment where physical server resources like RAM and CPU cycles are often heavily overcommitted.

slowTo check for CPU steal, run top and look at the %st value. If this value is anything other than zero, your VM’s CPU cycles are being “borrowed”.

To watch per-core steal time continuously over 1-second intervals, you can also run:

mpstat -P ALL 1

Modern Note: Legacy t1.micro shared baseline CPU aggressively when noisy neighbors spiked. Modern Nitro-based T3/T4g instances (and Dedicated hosts) isolate vCPUs much more predictably as long as CPU credits stay positive.

How to survive with an AWS EC2 t1.micro instance

amazon-ec2

With my t1.micro, I can host my personal Redmine, Git, and blog, which I couldn’t do with the default settings.

I used a swap file for it, and here is how you can set it up:

Copy & paste the code below:

sudo dd if=/dev/zero of=/var/swapfile bs=1M count=2048 status=progress
sudo chown root:root /var/swapfile
sudo chmod 0600 /var/swapfile
sudo mkswap /var/swapfile
sudo swapon /var/swapfile
echo '/var/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

To disable it cleanly later, run:

sudo swapoff -v /var/swapfile
sudo rm /var/swapfile
sudo sed -i '\|/var/swapfile|d' /etc/fstab

Alongside swap, keeping a tiny VM responsive came down to caching and restraint: placing Varnish in front of Apache absorbed static/anonymous reads before spawning memory-heavy worker processes, while PHP bytecode caching (APC back then, replaced natively by PHP OPcache today) avoided recompiling scripts on every request.

Cloud & Modern Linux Caveats: Heavy swapping on network-attached EBS volumes adds latency and burns through storage IOPS burst credits, so keep vm.swappiness=10 and treat swap strictly as an OOM safety net. On modern Linux kernels, compressed in-memory swap with zram is much faster and avoids unnecessary disk writes, while older tools like prelink are deprecated because of ASLR.