Skip to content

Instantly share code, notes, and snippets.

@samber
Created July 12, 2017 00:15
Show Gist options
  • Select an option

  • Save samber/4b6335de0f95161efdef2803c9f98e63 to your computer and use it in GitHub Desktop.

Select an option

Save samber/4b6335de0f95161efdef2803c9f98e63 to your computer and use it in GitHub Desktop.
Load testing on AWS (auto-scalling-group)

First: generate scp command list. (to cp in terminal to send the file everywhere

$ ./get_ips_asg.sh  | jq -r . | sed 's#^#scp load-test.py ec2-user@#g' | sed 's#$#:/tmp/load-test.py#g'
scp load-test.py ec2-user@54.93.255.106:/tmp/load-test.py
scp load-test.py ec2-user@35.158.214.117:/tmp/load-test.py
scp load-test.py ec2-user@52.59.253.207:/tmp/load-test.py
scp load-test.py ec2-user@35.158.119.156:/tmp/load-test.py
scp load-test.py ec2-user@52.59.251.109:/tmp/load-test.py
scp load-test.py ec2-user@52.59.229.218:/tmp/load-test.py
scp load-test.py ec2-user@54.93.229.138:/tmp/load-test.py
scp load-test.py ec2-user@54.93.40.238:/tmp/load-test.py
scp load-test.py ec2-user@54.93.87.144:/tmp/load-test.py
scp load-test.py ec2-user@54.93.206.242:/tmp/load-test.py

Then, run csshx (cluster ssh) to type command on every servers at the same time ❤️)

$ csshX $(./get_ips_asg.sh  | jq -r . | sed 's#^#ec2-user@#g')
#!/bin/bash
# usage: ./get_ips_asg.sh <asg-name>
for i in `aws autoscaling describe-auto-scaling-groups --auto-scaling-group-name $1 | grep -i instanceid | awk '{ print $2}' | cut -d',' -f1| sed -e 's/"//g'`
do
aws ec2 describe-instances --instance-ids $i | grep -i PublicIpAddress | awk '{ print $2 }' | head -1 | cut -d"," -f1
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment