From 50f1c0703094a1601b85023e10023d30d029faa9 Mon Sep 17 00:00:00 2001 From: Justin Walgran Date: Thu, 24 Mar 2022 13:54:48 -0700 Subject: [PATCH 1/4] Add VU_MULTIPLIER as a tile load test variable The tile load test uses k6 virtual users to run different batches of requests with an increasing delay. To simulate multiple users in parallel we add a `VU_MULTIPLIER` variable that sets the desired number of parallel executions. --- load-tests/README.md | 11 +++++++++++ load-tests/docker-compose.yml | 1 + .../zoom_rio_de_janerio_with_contributor_filter.js | 9 ++++++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/load-tests/README.md b/load-tests/README.md index c63e2f0ba..8a862d069 100644 --- a/load-tests/README.md +++ b/load-tests/README.md @@ -8,6 +8,7 @@ components necessary to execute a load test are encapsulated in this directory. - `K6_CLOUD_TOKEN`: An Auth Token for interacting with the k6 Cloud (optional) - `CACHE_KEY_SUFFIX`: A suffix to append in the path to ensure tile requests miss the cache (optional) +- `VU_MULTIPLER`: An integer number of parallel executions of each batch of requests ## Running @@ -59,6 +60,16 @@ default ✓ [======================================] 10 VUs 01m38.9s/10m0s 10/ ERRO[0101] some thresholds have failed ``` +To invoke an instance of the load test running with 10 times the number of +parallel requests and a random cache key suffix to avoid CloudFront + +```console +VU_MULTIPLIER=10 \ +CACHE_KEY_SUFFIX=$(echo $(date) | sha1sum | cut -c1-8) \ +docker-compose -f docker-compose.yml run --rm \ + k6 run /scripts/zoom_rio_de_janerio_with_contributor_filter.js +``` + To invoke an instance of the load test streaming output to the k6 Cloud: ```console diff --git a/load-tests/docker-compose.yml b/load-tests/docker-compose.yml index 6f5b44274..035a95142 100644 --- a/load-tests/docker-compose.yml +++ b/load-tests/docker-compose.yml @@ -5,6 +5,7 @@ services: environment: - K6_CLOUD_TOKEN - CACHE_KEY_SUFFIX + - VU_MULTIPLIER volumes: - ./:/scripts/ command: run /scripts/zoom_rio_de_janerio_with_contributor_filter.js diff --git a/load-tests/zoom_rio_de_janerio_with_contributor_filter.js b/load-tests/zoom_rio_de_janerio_with_contributor_filter.js index ef07fcc0b..eb026bf9b 100644 --- a/load-tests/zoom_rio_de_janerio_with_contributor_filter.js +++ b/load-tests/zoom_rio_de_janerio_with_contributor_filter.js @@ -63,11 +63,13 @@ batches = batches.sort((a, b) => a - b); const failRate = new Rate("failed requests"); +const VU_MULTIPLIER = __ENV.VU_MULTIPLIER || 1; + export const options = { // We want VUs and iterations to match the number of parallel request // batches we're going to issue so we can replay traffic 1:1. - vus: batches.length, - iterations: batches.length, + vus: batches.length * VU_MULTIPLIER, + iterations: batches.length * VU_MULTIPLIER, discardResponseBodies: true, maxRedirects: 0, @@ -79,7 +81,8 @@ export const options = { export default function () { // Sleep each Batch so that everything doesn't happen at once const firstBatchTime = batches[0]; - const thisBatchTime = batches[__VU - 1]; + const batchIndex = (__VU - 1) % batches.length; + const thisBatchTime = batches[batchIndex]; sleep(Math.floor((thisBatchTime - firstBatchTime) / 1000)); const responses = http.batch(requests[thisBatchTime]); From 553b24a4e7383149b1ffbd3965cad6e654533aa5 Mon Sep 17 00:00:00 2001 From: Justin Walgran Date: Thu, 24 Mar 2022 14:27:54 -0700 Subject: [PATCH 2/4] Incorporate virtual user number into tile load cache busting Adding the VU index into the cache key attempts to simulate a tile fetching situation that is a resource intensive as possible, where each batch of tile requests from each parallel user always misses the cache. --- load-tests/zoom_rio_de_janerio_with_contributor_filter.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/load-tests/zoom_rio_de_janerio_with_contributor_filter.js b/load-tests/zoom_rio_de_janerio_with_contributor_filter.js index eb026bf9b..6c2ae90ca 100644 --- a/load-tests/zoom_rio_de_janerio_with_contributor_filter.js +++ b/load-tests/zoom_rio_de_janerio_with_contributor_filter.js @@ -24,9 +24,14 @@ har.log.entries.forEach((entry) => { const cacheKey = crypto .sha1(entry.request.url.match(pattern)[5], "hex") .slice(0, 8); + // Including the __VU in the cache key should generate a worse situation + // than typical. Each batch of requests is made by a separate VU and when + // VU_MULTIPLIER is larger than 1, we repeat the same batch of requests a + // number of times equal to VU_MULTIPLIER. Using __VU in the cache key means + // subsequent requests for the same batch will not hit the cache. const url = entry.request.url.replace( pattern, - `${cacheKey}${__ENV.CACHE_KEY_SUFFIX}/$2/$3/$4.pbf?$5` + `${cacheKey}-vu-${__VU}-${__ENV.CACHE_KEY_SUFFIX}/$2/$3/$4.pbf?$5` ); const referer = entry.request.headers.find( From e52b84ca9a3d6b0dc5a22444e43eb77dedbee895 Mon Sep 17 00:00:00 2001 From: Justin Walgran Date: Thu, 24 Mar 2022 14:36:51 -0700 Subject: [PATCH 3/4] Fix typo in load-test README The path to the script needs a leading "/" --- load-tests/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/load-tests/README.md b/load-tests/README.md index 8a862d069..a74772343 100644 --- a/load-tests/README.md +++ b/load-tests/README.md @@ -75,6 +75,6 @@ To invoke an instance of the load test streaming output to the k6 Cloud: ```console $ export K6_CLOUD_TOKEN=... $ docker-compose \ - -f docker-compose.k6.yml \ - run --rm k6 run -o cloud scripts/zoom_rio_de_janerio_with_contributor_filter.js + -f docker-compose.yml \ + run --rm k6 run -o cloud /scripts/zoom_rio_de_janerio_with_contributor_filter.js ``` From 4b8df5042816f1bcaf88758e3d15022345c68ddc Mon Sep 17 00:00:00 2001 From: Justin Walgran Date: Fri, 25 Mar 2022 12:44:15 -0700 Subject: [PATCH 4/4] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5423ce034..841b8a489 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Changed - Update DB anonymization script [#1769](https://github.com/open-apparel-registry/open-apparel-registry/pull/1769) +- Update tileer load test script [#1770](https://github.com/open-apparel-registry/open-apparel-registry/pull/1770) ### Deprecated