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:

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:

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:

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:

or

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