Skip to content

Commit 82856fa

Browse files
maxdaydarklight3it
andauthored
fix: throttling issue (#654)
* fix: throttling issue * fix: slow down docker-retry backoff to 1/2/5 min with jitter public.ecr.aws / Docker Hub rate-limit windows recover on a minute-scale timer, so the previous 5s..60s exponential ladder tended to exhaust its retry budget before the throttle slot reopened. Replace with a fixed 1min / 2min / 5min ladder + additive [0,30]s jitter. --------- Co-authored-by: Davide Melfi <darklight3it@gmail.com>
1 parent d343d78 commit 82856fa

3 files changed

Lines changed: 27 additions & 11 deletions

File tree

‎.github/workflows/runtime-interface-client_pr.yml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,15 @@ jobs:
136136
platform: linux/arm64/v8
137137
name: "integration-test (${{ matrix.buildspec }} / ${{ matrix.arch.label }})"
138138
steps:
139+
- name: Jitter start (stagger matrix shards to spare public.ecr.aws rate limit)
140+
# Every shard is scheduled within milliseconds of the others and hits
141+
# public.ecr.aws / docker hub inside the same rate-limit window, so they
142+
# collectively trip the throttle.
143+
run: |
144+
jitter=$((RANDOM % 61))
145+
echo "Sleeping ${jitter}s to stagger this shard"
146+
sleep "${jitter}"
147+
139148
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
140149

141150
- name: Set up Docker Buildx

‎aws-lambda-java-runtime-interface-client/test/integration/codebuild-local/docker-retry.sh‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@
33

44
set -uo pipefail
55

6-
MAX_ATTEMPTS="${RETRY_MAX_ATTEMPTS:-5}"
7-
BASE_DELAY="${RETRY_BASE_DELAY:-5}"
8-
MAX_DELAY="${RETRY_MAX_DELAY:-60}"
6+
# Ladder of base wait times (in seconds) between successive attempts.
7+
# Default: 1 min, 2 min, 5 min — 4 attempts total (initial + 3 retries).
8+
# public.ecr.aws / Docker Hub rate-limit windows recover on a minute-scale
9+
# timer, so short exponential backoff (5s..60s) tends to exhaust its budget
10+
# before the rate-limit slot reopens.
11+
IFS=' ' read -r -a DELAYS <<< "${RETRY_DELAYS:-60 120 300}"
12+
JITTER_MAX="${RETRY_JITTER_MAX:-30}"
13+
MAX_ATTEMPTS=$(( ${#DELAYS[@]} + 1 ))
914

1015
if (( $# == 0 )); then
1116
>&2 echo "usage: docker-retry.sh <command> [args...]"
@@ -22,14 +27,13 @@ while true; do
2227
exit "$status"
2328
fi
2429

25-
# Exponential backoff: BASE_DELAY * 2^(attempt-1), capped at MAX_DELAY.
26-
backoff=$(( BASE_DELAY * (2 ** (attempt - 1)) ))
27-
(( backoff > MAX_DELAY )) && backoff=$MAX_DELAY
28-
# Full jitter: wait a random duration in [0, backoff] so concurrent jobs
29-
# spread out instead of retrying at the same moment.
30-
delay=$(( RANDOM % (backoff + 1) ))
30+
# Base delay from the ladder + additive jitter in [0, JITTER_MAX] so
31+
# concurrent shards don't retry in the exact same second.
32+
base=${DELAYS[$((attempt - 1))]}
33+
jitter=$(( RANDOM % (JITTER_MAX + 1) ))
34+
delay=$(( base + jitter ))
3135

32-
>&2 echo "docker-retry: '$*' failed (exit ${status}); attempt ${attempt}/${MAX_ATTEMPTS}, retrying in ${delay}s."
36+
>&2 echo "docker-retry: '$*' failed (exit ${status}); attempt ${attempt}/${MAX_ATTEMPTS}, retrying in ${delay}s (${base}s + ${jitter}s jitter)."
3337
sleep "$delay"
3438
attempt=$(( attempt + 1 ))
3539
done

‎aws-lambda-java-runtime-interface-client/test/integration/codebuild-local/test_one.sh‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ main() {
6262
mkdir -p "$ARTIFACTS_DIR"
6363

6464
LOCAL_AGENT_IMAGE="$(get_local_agent_image)"
65-
"$(dirname "$0")"/docker-retry.sh docker pull "$LOCAL_AGENT_IMAGE" || true
65+
66+
if ! docker image inspect "$LOCAL_AGENT_IMAGE" >/dev/null 2>&1; then
67+
"$(dirname "$0")"/docker-retry.sh docker pull "$LOCAL_AGENT_IMAGE"
68+
fi
6669

6770
# Run CodeBuild local agent.
6871
"$(dirname "$0")"/codebuild_build.sh \

0 commit comments

Comments
 (0)