diff --git a/experiments/providerdelay/build.sh b/experiments/providerdelay/build.sh new file mode 100755 index 0000000..71fb404 --- /dev/null +++ b/experiments/providerdelay/build.sh @@ -0,0 +1,51 @@ +#!/bin/bash +set -euo pipefail +# set -x + +EXP_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +CONFIGS="$EXP_DIR/image/configs/*.sh" +DOCKER_REPO=147263665150.dkr.ecr.eu-west-1.amazonaws.com +KUBO_IMAGE_NAME=thunderdome:providerdelay-kubo +KUBO_IMAGE=$DOCKER_REPO/$KUBO_IMAGE_NAME + +WORKDIR=$(mktemp -d) +if [ ! -e "$WORKDIR" ]; then + >&2 echo "Failed to create temp directory" + exit 1 +fi + +trap 'rm -rf "$WORKDIR"' EXIT + +echo "Using work directory $WORKDIR" +cd "$WORKDIR" +git clone https://github.com/iand/go-ipfs.git kubo + +cd kubo +git switch feat/remove-provider-search-delay +docker build -t $KUBO_IMAGE_NAME . + +aws ecr get-login-password --region eu-west-1 | docker login --username AWS --password-stdin $DOCKER_REPO + +docker tag $KUBO_IMAGE_NAME $KUBO_IMAGE +docker push $KUBO_IMAGE + + +cd "$EXP_DIR" + +for cf in $CONFIGS +do + if [ -f "$cf" ] + then + file=${cf##*/} + name=${file%.sh} + # Build and push image + echo Building thunderdome:$name + docker build --build-arg config=$file --build-arg kuboimage=$KUBO_IMAGE -t thunderdome:$name image/ + docker tag thunderdome:$name $DOCKER_REPO/thunderdome:$name + docker push $DOCKER_REPO/thunderdome:$name + else + >&2 echo "\"$cf\" was not a file" + exit 1 + fi + +done diff --git a/experiments/providerdelay/image/Dockerfile b/experiments/providerdelay/image/Dockerfile new file mode 100644 index 0000000..650a4c2 --- /dev/null +++ b/experiments/providerdelay/image/Dockerfile @@ -0,0 +1,9 @@ +ARG kuboimage +FROM $kuboimage + +ADD /container-init.d/* /container-init.d/ +ARG config +ADD /configs/$config /container-init.d/ +RUN chmod a+x /container-init.d/* + +EXPOSE 8080 diff --git a/experiments/providerdelay/image/configs/providerdelay-0ms.sh b/experiments/providerdelay/image/configs/providerdelay-0ms.sh new file mode 100644 index 0000000..cd7a53e --- /dev/null +++ b/experiments/providerdelay/image/configs/providerdelay-0ms.sh @@ -0,0 +1 @@ +ipfs config --json Internal.Bitswap.ProviderSearchDelay '0' diff --git a/experiments/providerdelay/image/configs/providerdelay-1000ms.sh b/experiments/providerdelay/image/configs/providerdelay-1000ms.sh new file mode 100644 index 0000000..b8cc76d --- /dev/null +++ b/experiments/providerdelay/image/configs/providerdelay-1000ms.sh @@ -0,0 +1 @@ +ipfs config --json Internal.Bitswap.ProviderSearchDelay '1000ms' diff --git a/experiments/providerdelay/image/configs/providerdelay-100ms.sh b/experiments/providerdelay/image/configs/providerdelay-100ms.sh new file mode 100644 index 0000000..65bfd72 --- /dev/null +++ b/experiments/providerdelay/image/configs/providerdelay-100ms.sh @@ -0,0 +1 @@ +ipfs config --json Internal.Bitswap.ProviderSearchDelay '100ms' diff --git a/experiments/providerdelay/image/configs/providerdelay-200ms.sh b/experiments/providerdelay/image/configs/providerdelay-200ms.sh new file mode 100644 index 0000000..c6287d7 --- /dev/null +++ b/experiments/providerdelay/image/configs/providerdelay-200ms.sh @@ -0,0 +1 @@ +ipfs config --json Internal.Bitswap.ProviderSearchDelay '200ms' diff --git a/experiments/providerdelay/image/configs/providerdelay-20ms.sh b/experiments/providerdelay/image/configs/providerdelay-20ms.sh new file mode 100644 index 0000000..cd9b0d2 --- /dev/null +++ b/experiments/providerdelay/image/configs/providerdelay-20ms.sh @@ -0,0 +1 @@ +ipfs config --json Internal.Bitswap.ProviderSearchDelay '20ms' diff --git a/experiments/providerdelay/image/configs/providerdelay-500ms.sh b/experiments/providerdelay/image/configs/providerdelay-500ms.sh new file mode 100644 index 0000000..bcc03d5 --- /dev/null +++ b/experiments/providerdelay/image/configs/providerdelay-500ms.sh @@ -0,0 +1 @@ +ipfs config --json Internal.Bitswap.ProviderSearchDelay '500ms' diff --git a/experiments/providerdelay/image/configs/providerdelay-50ms.sh b/experiments/providerdelay/image/configs/providerdelay-50ms.sh new file mode 100644 index 0000000..3910e9b --- /dev/null +++ b/experiments/providerdelay/image/configs/providerdelay-50ms.sh @@ -0,0 +1 @@ +ipfs config --json Internal.Bitswap.ProviderSearchDelay '50ms' diff --git a/experiments/providerdelay/image/configs/providerdelay-750ms.sh b/experiments/providerdelay/image/configs/providerdelay-750ms.sh new file mode 100644 index 0000000..61ab161 --- /dev/null +++ b/experiments/providerdelay/image/configs/providerdelay-750ms.sh @@ -0,0 +1 @@ +ipfs config --json Internal.Bitswap.ProviderSearchDelay '750ms' diff --git a/experiments/providerdelay/image/container-init.d/base.sh b/experiments/providerdelay/image/container-init.d/base.sh new file mode 100644 index 0000000..e87caf3 --- /dev/null +++ b/experiments/providerdelay/image/container-init.d/base.sh @@ -0,0 +1,33 @@ +#!/bin/sh +## The shell in the go-ipfs container is busybox, so a version of ash +## Shellcheck might warn on things POSIX sh cant do, but ash can +## In Shellcheck, ash is an alias for dash, but busybox ash can do more than dash +## https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Data.hs#L134 +echo "setting config" +ipfs config --json AutoNAT '{ + "ServiceMode": "enabled", + "Throttle": { + "GlobalLimit": 0, + "Interval": "1m", + "PeerLimit": 3 + } + }' + +ipfs config --json Datastore.BloomFilterSize '268435456' +ipfs config --json Datastore.StorageGCWatermark 90 +ipfs config --json Datastore.StorageMax '"200GB"' +ipfs config --json Datastore.GCPeriod '"10m"' + +ipfs config --json Pubsub.StrictSignatureVerification false + +ipfs config --json Reprovider.Interval '"0"' + +ipfs config --json Routing.Type '"dhtserver"' + +ipfs config --json Swarm.ConnMgr.GracePeriod '"2m"' +ipfs config --json Swarm.ConnMgr.HighWater 5000 +ipfs config --json Swarm.ConnMgr.LowWater 3000 +ipfs config --json Swarm.ConnMgr.DisableBandwidthMetrics true + +ipfs config --json Experimental.AcceleratedDHTClient true +ipfs config --json Experimental.StrategicProviding true diff --git a/experiments/providerdelay/image/container-init.d/gw-config.sh b/experiments/providerdelay/image/container-init.d/gw-config.sh new file mode 100644 index 0000000..b00801c --- /dev/null +++ b/experiments/providerdelay/image/container-init.d/gw-config.sh @@ -0,0 +1,48 @@ +#!/bin/sh +## The shell in the go-ipfs container is busybox, so a version of ash +## Shellcheck might warn on things POSIX sh cant do, but ash can +## In Shellcheck, ash is an alias for dash, but busybox ash can do more than dash +## https://github.com/koalaman/shellcheck/blob/master/src/ShellCheck/Data.hs#L134 +echo "setting Gateway config" +ipfs config --json Gateway '{ + "HTTPHeaders": { + "Access-Control-Allow-Origin": [ + "*" + ] + }, + "RootRedirect": "", + "Writable": false, + "APICommands": [], + "NoFetch": false, + "NoDNSLink": false, + "PublicGateways": { + "dweb.link": { + "NoDNSLink": false, + "Paths": [ + "/ipfs", + "/ipns", + "/api" + ], + "UseSubdomains": true + }, + "gateway.ipfs.io": { + "NoDNSLink": false, + "Paths": [ + "/ipfs", + "/ipns", + "/api" + ], + "UseSubdomains": false + }, + "ipfs.io": { + "NoDNSLink": false, + "Paths": [ + "/ipfs", + "/ipns", + "/api" + ], + "UseSubdomains": false + } + } + }' + diff --git a/tf/experiments.tf b/tf/experiments.tf index f77af5b..6e648ab 100644 --- a/tf/experiments.tf +++ b/tf/experiments.tf @@ -87,6 +87,59 @@ module "peering" { } } +module "providerdelay" { + source = "./modules/experiment" + name = "providerdelay" + + ecs_cluster_id = module.ecs.cluster_id + vpc_subnets = module.vpc.public_subnets + security_groups = [aws_security_group.target.id] + execution_role_arn = aws_iam_role.ecsTaskExecutionRole.arn + log_group_name = aws_cloudwatch_log_group.logs.name + aws_service_discovery_private_dns_namespace_id = aws_service_discovery_private_dns_namespace.main.id + grafana_secrets = [ + { name = "GRAFANA_USER", valueFrom = "${data.aws_secretsmanager_secret.grafana-push-secret.arn}:username::" }, + { name = "GRAFANA_PASS", valueFrom = "${data.aws_secretsmanager_secret.grafana-push-secret.arn}:password::" } + ] + + shared_env = [ + { name = "IPFS_PROFILE", value = "server" }, + ] + + targets = { + "providerdelay-0ms" = { + image = "147263665150.dkr.ecr.eu-west-1.amazonaws.com/thunderdome:providerdelay-0ms" + environment = [] + } + "providerdelay-20ms" = { + image = "147263665150.dkr.ecr.eu-west-1.amazonaws.com/thunderdome:providerdelay-20ms" + environment = [] + } + "providerdelay-50ms" = { + image = "147263665150.dkr.ecr.eu-west-1.amazonaws.com/thunderdome:providerdelay-50ms" + environment = [] + } + "providerdelay-100ms" = { + image = "147263665150.dkr.ecr.eu-west-1.amazonaws.com/thunderdome:providerdelay-100ms" + environment = [] + } + "providerdelay-200ms" = { + image = "147263665150.dkr.ecr.eu-west-1.amazonaws.com/thunderdome:providerdelay-200ms" + environment = [] + } + "providerdelay-500ms" = { + image = "147263665150.dkr.ecr.eu-west-1.amazonaws.com/thunderdome:providerdelay-500ms" + environment = [] + } + "providerdelay-1000ms" = { + image = "147263665150.dkr.ecr.eu-west-1.amazonaws.com/thunderdome:providerdelay-1000ms" + environment = [] + } + } +} + + + resource "aws_security_group" "target" { name = "target" vpc_id = module.vpc.vpc_id