mirror of
https://github.com/tailscale/tailscale.git
synced 2026-12-01 14:12:32 -08:00
kernel/linux/{scripts,DESIGN.md}: resize EC2 instances, and record 50 Gbps results
ec2.sh gets "resize TYPE N..." (for stopped instances) and "start N..." (some instances), and numbers new instances after all existing ones, stopped ones included. With a c7i.48xlarge router (50 Gbps) and 8 clients, tswg forwards 31.5 Gbps at MTU 1280 (wireguard-go 7.2, kernel WireGuard 12.3 using 137 of 192 CPUs), limited by EC2's packet rate per NIC receive queue (about 715k pps, 7.3 Gbps of tunnel packets) with only 8 tunnel flows to spread over 16 queues; and at line rate with a jumbo tunnel MTU, a data point only, since MTU 1280 is the target. Updates #426 Signed-off-by: Brad Fitzpatrick <[email protected]> Change-Id: I70744651f3385343bf8890607911d9b4e0f70620
This commit is contained in:
1 parent
f810784988
commit
95c00517eb
2 files changed
+62
-13
No files matched your search
+36
-13
@@ -27,7 +27,9 @@
|
||||
#
|
||||
# usage:
|
||||
# ec2.sh up [COUNT [TYPE]] launch COUNT (default 2) instances of TYPE (default c7i.xlarge)
|
||||
# ec2.sh start start stopped instances, and rewrite the hosts file
|
||||
# ec2.sh start [N...] start stopped instances (all, or those numbered N),
|
||||
# and rewrite the hosts file
|
||||
# ec2.sh resize TYPE N... change stopped instances N... to TYPE
|
||||
# ec2.sh stop stop the instances (as ec2-idle-stop.sh does)
|
||||
# ec2.sh hosts rewrite the hosts file from the running instances
|
||||
# ec2.sh ssh N [CMD...] ssh to instance N (0-based)
|
||||
@@ -69,6 +71,16 @@ instance_ids() {
|
||||
--query 'Reservations[].Instances[].InstanceId' --output text
|
||||
}
|
||||
|
||||
# ids_of N... prints the IDs of our (not terminated) instances numbered N.
|
||||
ids_of() {
|
||||
for n in "$@"; do
|
||||
ec2 describe-instances --filters "Name=tag:owner,Values=claude-tswg" \
|
||||
"Name=tag:Name,Values=$name-$n" \
|
||||
"Name=instance-state-name,Values=pending,running,stopping,stopped" \
|
||||
--query 'Reservations[].Instances[].InstanceId' --output text
|
||||
done | tr '\n' ' '
|
||||
}
|
||||
|
||||
ensure_key() {
|
||||
if [ ! -f "$key" ]; then
|
||||
ssh-keygen -q -t ed25519 -N '' -C "$name" -f "$key"
|
||||
@@ -178,16 +190,12 @@ up)
|
||||
ami=$(aws ssm get-parameter \
|
||||
--name /aws/service/canonical/ubuntu/server/24.04/stable/current/amd64/hvm/ebs-gp3/ami-id \
|
||||
--query Parameter.Value --output text)
|
||||
stopped=$(ec2 describe-instances --filters "Name=tag:owner,Values=claude-tswg" \
|
||||
"Name=instance-state-name,Values=stopping,stopped" \
|
||||
--query 'length(Reservations[].Instances[])' --output text)
|
||||
if [ "$stopped" != 0 ]; then
|
||||
echo "$stopped instances are stopped; use \"$0 start\" (or \"$0 down\" first)" >&2
|
||||
exit 1
|
||||
fi
|
||||
# Number new instances after all existing ones, stopped ones included.
|
||||
existing=$(ec2 describe-instances --filters "Name=tag:owner,Values=claude-tswg" \
|
||||
"Name=instance-state-name,Values=pending,running" \
|
||||
--query 'length(Reservations[].Instances[])' --output text)
|
||||
"Name=instance-state-name,Values=pending,running,stopping,stopped" \
|
||||
--query 'Reservations[].Instances[].Tags[?Key==`Name`].Value[]' --output text |
|
||||
tr '\t' '\n' | sed -n "s/^$name-//p" | sort -n | tail -1)
|
||||
existing=$((${existing:--1} + 1))
|
||||
ids=""
|
||||
i=$existing
|
||||
while [ "$i" -lt $((existing + count)) ]; do
|
||||
@@ -214,9 +222,13 @@ up)
|
||||
cat "$hosts"
|
||||
;;
|
||||
start)
|
||||
ids=$(ec2 describe-instances --filters "Name=tag:owner,Values=claude-tswg" \
|
||||
"Name=instance-state-name,Values=stopping,stopped" \
|
||||
--query 'Reservations[].Instances[].InstanceId' --output text)
|
||||
if [ $# -gt 0 ]; then
|
||||
ids=$(ids_of "$@")
|
||||
else
|
||||
ids=$(ec2 describe-instances --filters "Name=tag:owner,Values=claude-tswg" \
|
||||
"Name=instance-state-name,Values=stopping,stopped" \
|
||||
--query 'Reservations[].Instances[].InstanceId' --output text)
|
||||
fi
|
||||
if [ -n "$ids" ]; then
|
||||
# shellcheck disable=SC2086
|
||||
ec2 wait instance-stopped --instance-ids $ids
|
||||
@@ -230,6 +242,17 @@ start)
|
||||
wait_ready
|
||||
cat "$hosts"
|
||||
;;
|
||||
resize)
|
||||
type=$1
|
||||
shift
|
||||
ids=$(ids_of "$@")
|
||||
# shellcheck disable=SC2086
|
||||
ec2 wait instance-stopped --instance-ids $ids
|
||||
for id in $ids; do
|
||||
ec2 modify-instance-attribute --instance-id "$id" --instance-type "Value=$type"
|
||||
echo "$id is now $type" >&2
|
||||
done
|
||||
;;
|
||||
stop)
|
||||
ids=$(instance_ids)
|
||||
if [ -n "$ids" ]; then
|
||||
|
||||
Reference in new issue
Block a user