How to Stress Test an AWS t2.micro Instance

If you're running workloads on AWS, it's important to understand how your instance handles stress under different conditions. In this post, we'll simulate high CPU, memory, and disk I/O usage on an AWS t2.micro instance using the stress-ng tool.

Why Stress Test?

Stress testing helps in:

  • Evaluating instance performance under load.

  • Identifying bottlenecks before deploying critical applications.

  • Understanding how AWS burstable instances behave under sustained usage.

Installing Stress Tools

To install the stress and stress-ng tools on Ubuntu, run:

sudo apt update && sudo apt install stress stress-ng -y

CPU Stress Test (~80% Load)

Since t2.micro has 1 vCPU, we’ll load the CPU to ~80%:

stress-ng --cpu 1 --cpu-load 80 --timeout 300

Breakdown:

  • -cpu 1 → Uses 1 CPU core.

  • -cpu-load 80 → Keeps CPU usage at ~80%.

  • -timeout 300 → Runs the test for 5 minutes.

Memory Stress Test (~80% RAM)

A t2.micro instance has 1 GB RAM. We'll allocate ~800MB:

stress-ng --vm 1 --vm-bytes 800M --timeout 300

Breakdown:

  • -vm 1 → Uses 1 memory worker process.

  • -vm-bytes 800M → Allocates ~80% of RAM.

  • -timeout 300 → Runs for 5 minutes.

Disk I/O Stress Test (~80% Load)

If you have an EBS volume, stress disk writes:

stress-ng --hdd 1 --hdd-bytes 800M --timeout 300

Breakdown:

  • -hdd 1 → Uses 1 worker for disk stress.

  • -hdd-bytes 800M → Writes ~800MB to disk.

  • -timeout 300 → Runs for 5 minutes.

Run All Tests Together

For a full system stress test, run:

stress-ng --cpu 1 --cpu-load 80 --vm 1 --vm-bytes 800M --hdd 1 --hdd-bytes 800M --timeout 300

This will: ✅ Load CPU to ~80% ✅ Consume RAM to ~800MB ✅ Perform disk writes for 5 minutes

Monitoring System Performance

While stress testing, monitor system resources with:

top

or

htop

This helps ensure your instance doesn't become unresponsive.

Key Considerations

  • t2.micro has burstable CPU credits—if exhausted, performance degrades.

  • Avoid overloading memory, or the system may start swapping.

  • Ensure you have enough disk space before running I/O stress tests.

Conclusion

Stress testing an AWS t2.micro instance helps identify performance limits before deploying real applications. Use stress-ng to simulate CPU, RAM, and disk load, and monitor your system to prevent crashes.

Would you like to add network stress testing or test on different instance types? Let me know in the comments!

Last updated