Skip to content

Commit 1ab0aee

Browse files
feat: add 70% CPU load simulation for realistic demo metrics
1 parent e351311 commit 1ab0aee

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

modules/api-server/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ Overmind analyzes the PR and catches the hidden risk.
4141

4242
**The trap**: Both instances look identical on paper, but t3 uses CPU credits. At 70% sustained CPU, credits exhaust and performance collapses.
4343

44+
## 🔥 CPU Load Simulation
45+
46+
The instance runs a **permanent 70% CPU load** via `stress-ng` to simulate a real CPU-intensive workload. This ensures:
47+
48+
- CloudWatch shows realistic CPU utilization (~70%)
49+
- Overmind can detect the risk from actual metrics
50+
- The demo reflects real-world conditions
51+
52+
The load runs as a systemd service that starts on boot and restarts automatically. No extra cost - EC2 is billed by time, not CPU usage.
53+
4454
## 🔍 What Overmind Catches
4555

4656
1. **Blast Radius** - ALB, target groups, alarms, security groups

modules/api-server/ec2.tf

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,28 @@ resource "aws_instance" "api_server" {
2525
user_data = base64encode(<<-EOF
2626
#!/bin/bash
2727
yum update -y
28-
yum install -y httpd
28+
yum install -y httpd stress-ng
29+
30+
# Create systemd service for CPU load simulation (70% sustained)
31+
cat > /etc/systemd/system/cpu-load-simulator.service <<'SERVICE'
32+
[Unit]
33+
Description=Simulate 70% CPU load for demo purposes
34+
After=network.target
35+
36+
[Service]
37+
Type=simple
38+
ExecStart=/usr/bin/stress-ng --cpu 2 --cpu-load 70
39+
Restart=always
40+
RestartSec=10
41+
42+
[Install]
43+
WantedBy=multi-user.target
44+
SERVICE
45+
46+
# Enable and start CPU load simulation
47+
systemctl daemon-reload
48+
systemctl enable cpu-load-simulator
49+
systemctl start cpu-load-simulator
2950
3051
cat > /var/www/html/health <<'HEALTH'
3152
OK

0 commit comments

Comments
 (0)