From a0311f79f2735d04b8e1da3468eeb0b697003017 Mon Sep 17 00:00:00 2001 From: Joanhey Date: Sat, 20 Apr 2024 00:45:36 +0200 Subject: [PATCH 1/3] Clean Makefile --- 001_symfony7_wo_db/Makefile | 91 +++++-------------- .../k6/script_vus10000_dur30s.js | 18 ---- .../testing-tools/k6/script_vus1000_dur30s.js | 18 ---- .../testing-tools/k6/script_vus100_dur30s.js | 18 ---- .../testing-tools/k6/script_vus10_dur30s.js | 18 ---- .../testing-tools/k6/script_vus5_dur10s.js | 35 ------- .../testing-tools/k6/script_vus5_dur30s.js | 18 ---- 001_symfony7_wo_db/testing-tools/k6_bench.js | 35 +++++++ 8 files changed, 56 insertions(+), 195 deletions(-) delete mode 100644 001_symfony7_wo_db/testing-tools/k6/script_vus10000_dur30s.js delete mode 100644 001_symfony7_wo_db/testing-tools/k6/script_vus1000_dur30s.js delete mode 100644 001_symfony7_wo_db/testing-tools/k6/script_vus100_dur30s.js delete mode 100644 001_symfony7_wo_db/testing-tools/k6/script_vus10_dur30s.js delete mode 100644 001_symfony7_wo_db/testing-tools/k6/script_vus5_dur10s.js delete mode 100644 001_symfony7_wo_db/testing-tools/k6/script_vus5_dur30s.js create mode 100644 001_symfony7_wo_db/testing-tools/k6_bench.js diff --git a/001_symfony7_wo_db/Makefile b/001_symfony7_wo_db/Makefile index 950dc2e..f84daec 100644 --- a/001_symfony7_wo_db/Makefile +++ b/001_symfony7_wo_db/Makefile @@ -2,6 +2,14 @@ help : Makefile @sed -n 's/^##//p' $< + +vus := 100 +duration := 30s +reqs := 1000 +#bench_port := :80 +bench_url := http://symfony7site$(bench_port)/?firstName=Randomlfirstname&lastName=Randomlastname + + ## #################### 001 APACHE + mod_php #################### ## @@ -245,7 +253,7 @@ down/runtime/011-caddy-phpfpm: ## shell/runtime/011-caddy-phpfpm : Login to 011 Runtime: Caddy + PHP-FPM.. shell/runtime/011-caddy-phpfpm: @docker container exec -it 011_caddy_phpfpm bash -======= + #################### 010 Adapterman #################### ## ## start/runtime/010-adapterman : Start 010 Runtime: Adapterman. @@ -272,75 +280,18 @@ shell/runtime/010-adapterman: #################### Load Testing #################### ## -## run/loadtest/ab-n1000-c5 : Run "ab -n 1000 -c 5 URL" -run/loadtest/ab-n1000-c5: - docker run --rm --name ab-loadttest --network php-benchmarks httpd:2.4.58-bookworm ab -n 1000 -c 5 "http://symfony7site/?firstName=Randomlfirstname&lastName=Randomlastname" - -## run/loadtest/ab-n1000-c10 : Run "ab -n 1000 -c 10 URL" -run/loadtest/ab-n1000-c10: - docker run --rm --name ab-loadttest --network php-benchmarks httpd:2.4.58-bookworm ab -n 1000 -c 10 "http://symfony7site/?firstName=Randomlfirstname&lastName=Randomlastname" - -## run/loadtest/ab-n1000-c100 : Run "ab -n 1000 -c 100 URL" -run/loadtest/ab-n1000-c100: - docker run --rm --name ab-loadttest --network php-benchmarks httpd:2.4.58-bookworm ab -n 1000 -c 100 "http://symfony7site/?firstName=Randomlfirstname&lastName=Randomlastname" - -## run/loadtest/ab-n10000-c1000 : Run "ab -n 10000 -c 1000 URL" -run/loadtest/ab-n10000-c1000: - docker run --rm --name ab-loadttest --network php-benchmarks httpd:2.4.58-bookworm ab -n 10000 -c 1000 "http://symfony7site/?firstName=Randomlfirstname&lastName=Randomlastname" - -## run/loadtest/k6-vus5-dur10s : Run k6 vus:5 duration: 10s -run/loadtest/k6-vus5-dur30s: - docker run --rm --net php-benchmarks -i grafana/k6 run - <./testing-tools/k6/script_vus5_dur30s.js - -## run/loadtest/k6-vus10-dur30s : Run k6 vus:10 duration: 30s -run/loadtest/k6-vus10-dur30s: - docker run --rm --net php-benchmarks -i grafana/k6 run - <./testing-tools/k6/script_vus10_dur30s.js - -## run/loadtest/k6-vus100-dur30s : Run k6 vus:100 duration: 30s -run/loadtest/k6-vus100-dur30s: - docker run --rm --net php-benchmarks -i grafana/k6 run - <./testing-tools/k6/script_vus100_dur30s.js - -## run/loadtest/k6-vus1000-dur30s : Run k6 vus:1000 duration: 30s -run/loadtest/k6-vus1000-dur30s: - docker run --rm --net php-benchmarks -i grafana/k6 run - <./testing-tools/k6/script_vus1000_dur30s.js - -## run/loadtest/k6-vus10000-dur30s : Run k6 vus:10000 duration: 30s -run/loadtest/k6-vus10000-dur30s: - docker run --rm --net php-benchmarks -i grafana/k6 run - <./testing-tools/k6/script_vus10000_dur30s.js - -## run/loadtest/bombardier-c5-d30s : Run bombardier concurrent connections: 5, duration: 30s -run/loadtest/bombardier-c5-d30s: - docker run --rm --name bombardier-loadttest --network php-benchmarks alpine/bombardier:1.2.6 -c 5 -d 30s "http://symfony7site/?firstName=Randomlfirstname&lastName=Randomlastname" - -## run/loadtest/bombardier-c10-d30s : Run bombardier concurrent connections: 10, duration: 30s -run/loadtest/bombardier-c10-d30s: - docker run --rm --name bombardier-loadttest --network php-benchmarks alpine/bombardier:1.2.6 -c 10 -d 30s "http://symfony7site/?firstName=Randomlfirstname&lastName=Randomlastname" - -## run/loadtest/bombardier-c100-d30s : Run bombardier concurrent connections: 100, duration: 30s -run/loadtest/bombardier-c100-d30s: - docker run --rm --name bombardier-loadttest --network php-benchmarks alpine/bombardier:1.2.6 -c 100 -d 30s "http://symfony7site/?firstName=Randomlfirstname&lastName=Randomlastname" - -## run/loadtest/bombardier-c1000-d30s : Run bombardier concurrent connections: 1000, duration: 30s -run/loadtest/bombardier-c1000-d30s: - docker run --rm --name bombardier-loadttest --network php-benchmarks alpine/bombardier:1.2.6 -c 1000 -d 30s "http://symfony7site/?firstName=Randomlfirstname&lastName=Randomlastname" - -## run/loadtest/bombardier-c10000-d30s : Run bombardier concurrent connections: 10000, duration: 30s -run/loadtest/bombardier-c10000-d30s: - docker run --rm --name bombardier-loadttest --network php-benchmarks alpine/bombardier:1.2.6 -c 10000 -d 30s "http://symfony7site/?firstName=Randomlfirstname&lastName=Randomlastname" - -## run/loadtest/wrk-c5-d30s : Run wrk, concurrent connections: 5, duration: 30s -run/loadtest/wrk-c5-d30s: - docker run --rm --name wrk-loadtest --network php-benchmarks williamyeh/wrk:4.0.2 -c 5 -d 30s "http://symfony7site/?firstName=Randomlfirstname&lastName=Randomlastname" - +## run/loadtest/ab : Run ab, reqs=1000 (default) vus=100 (default) +run/loadtest/ab: + docker run --rm --name ab-loadttest --network php-benchmarks httpd:2.4.58-bookworm ab -n $(reqs) -c $(vus) $(bench_url) -## run/loadtest/wrk-c10-d30s : Run wrk, concurrent connections: 10, duration: 30s -run/loadtest/wrk-c10-d30s: - docker run --rm --name wrk-loadtest --network php-benchmarks williamyeh/wrk:4.0.2 -c 10 -d 30s "http://symfony7site/?firstName=Randomlfirstname&lastName=Randomlastname" +## run/loadtest/k6 : Run k6 vus=100 (default) duration=30s (default) +run/loadtest/k6: + docker run --rm --net php-benchmarks -i grafana/k6 run --vus $(vus) --duration $(duration) - <./testing-tools/k6_bench.js -## run/loadtest/wrk-c100-d30s : Run wrk, concurrent connections: 100, duration: 30s -run/loadtest/wrk-c100-d30s: - docker run --rm --name wrk-loadtest --network php-benchmarks williamyeh/wrk:4.0.2 -c 100 -d 30s "http://symfony7site/?firstName=Randomlfirstname&lastName=Randomlastname" +## run/loadtest/bombardier : Run bombardier vus=100 (default) duration=30s (default) +run/loadtest/bombardier: + docker run --rm --name bombardier-loadttest --network php-benchmarks alpine/bombardier:1.2.6 -c $(vus) -d $(duration) $(bench_url) -## run/loadtest/wrk-c1000-d30s : Run wrk, concurrent connections: 1000, duration: 30s -run/loadtest/wrk-c1000-d30s: - docker run --rm --name wrk-loadtest --network php-benchmarks williamyeh/wrk:4.0.2 -t 1 -c 1000 -d 30s "http://symfony7site/?firstName=Randomlfirstname&lastName=Randomlastname" \ No newline at end of file +## run/loadtest/wrk : Run wrk, vus=100 (default) duration=30s (default) +run/loadtest/wrk: + docker run --rm --name wrk-loadtest --network php-benchmarks williamyeh/wrk:4.0.2 -c $(vus) -d $(duration) $(bench_url) diff --git a/001_symfony7_wo_db/testing-tools/k6/script_vus10000_dur30s.js b/001_symfony7_wo_db/testing-tools/k6/script_vus10000_dur30s.js deleted file mode 100644 index 22a3a9e..0000000 --- a/001_symfony7_wo_db/testing-tools/k6/script_vus10000_dur30s.js +++ /dev/null @@ -1,18 +0,0 @@ -import http from 'k6/http'; -import { sleep } from 'k6'; - -export const options = { - // A number specifying the number of VUs to run concurrently. - vus: 10000, - // A string specifying the total duration of the test run. - duration: '30s', -}; - -// The function that defines VU logic. -// -// See https://grafana.com/docs/k6/latest/examples/get-started-with-k6/ to learn more -// about authoring k6 scripts. -// -export default function() { - http.get('http://symfony7site/?firstName=Randomlfirstname&lastName=Randomlastname'); -} diff --git a/001_symfony7_wo_db/testing-tools/k6/script_vus1000_dur30s.js b/001_symfony7_wo_db/testing-tools/k6/script_vus1000_dur30s.js deleted file mode 100644 index 9a56549..0000000 --- a/001_symfony7_wo_db/testing-tools/k6/script_vus1000_dur30s.js +++ /dev/null @@ -1,18 +0,0 @@ -import http from 'k6/http'; -import { sleep } from 'k6'; - -export const options = { - // A number specifying the number of VUs to run concurrently. - vus: 1000, - // A string specifying the total duration of the test run. - duration: '30s', -}; - -// The function that defines VU logic. -// -// See https://grafana.com/docs/k6/latest/examples/get-started-with-k6/ to learn more -// about authoring k6 scripts. -// -export default function() { - http.get('http://symfony7site/?firstName=Randomlfirstname&lastName=Randomlastname'); -} diff --git a/001_symfony7_wo_db/testing-tools/k6/script_vus100_dur30s.js b/001_symfony7_wo_db/testing-tools/k6/script_vus100_dur30s.js deleted file mode 100644 index d1eb098..0000000 --- a/001_symfony7_wo_db/testing-tools/k6/script_vus100_dur30s.js +++ /dev/null @@ -1,18 +0,0 @@ -import http from 'k6/http'; -import { sleep } from 'k6'; - -export const options = { - // A number specifying the number of VUs to run concurrently. - vus: 100, - // A string specifying the total duration of the test run. - duration: '30s', -}; - -// The function that defines VU logic. -// -// See https://grafana.com/docs/k6/latest/examples/get-started-with-k6/ to learn more -// about authoring k6 scripts. -// -export default function() { - http.get('http://symfony7site/?firstName=Randomlfirstname&lastName=Randomlastname'); -} diff --git a/001_symfony7_wo_db/testing-tools/k6/script_vus10_dur30s.js b/001_symfony7_wo_db/testing-tools/k6/script_vus10_dur30s.js deleted file mode 100644 index de6ae93..0000000 --- a/001_symfony7_wo_db/testing-tools/k6/script_vus10_dur30s.js +++ /dev/null @@ -1,18 +0,0 @@ -import http from 'k6/http'; -import { sleep } from 'k6'; - -export const options = { - // A number specifying the number of VUs to run concurrently. - vus: 10, - // A string specifying the total duration of the test run. - duration: '30s', -}; - -// The function that defines VU logic. -// -// See https://grafana.com/docs/k6/latest/examples/get-started-with-k6/ to learn more -// about authoring k6 scripts. -// -export default function() { - http.get('http://symfony7site/?firstName=Randomlfirstname&lastName=Randomlastname'); -} diff --git a/001_symfony7_wo_db/testing-tools/k6/script_vus5_dur10s.js b/001_symfony7_wo_db/testing-tools/k6/script_vus5_dur10s.js deleted file mode 100644 index c52a638..0000000 --- a/001_symfony7_wo_db/testing-tools/k6/script_vus5_dur10s.js +++ /dev/null @@ -1,35 +0,0 @@ -import http from 'k6/http'; -import { textSummary } from 'https://jslib.k6.io/k6-summary/0.0.2/index.js'; - -export const options = { - // A number specifying the number of VUs to run concurrently. - vus: 5, - // A string specifying the total duration of the test run. - duration: '5s', -}; - -// The function that defines VU logic. -// -// See https://grafana.com/docs/k6/latest/examples/get-started-with-k6/ to learn more -// about authoring k6 scripts. -// -export default function() { - http.get('http://symfony7site/?firstName=Randomlfirstname&lastName=Randomlastname'); -} -export function handleSummary(data) { - /*return { - 'summary.json': JSON.stringify(data), //the default data object - };*/ - const customizedData = { - http_reqs: data.metrics.http_reqs.values.count, - - rate: data.metrics.http_reqs.values.rate, - avg_response_time: data.metrics['http_req_duration{expected_response:true}'].values.avg - } - return { - 'stdout': textSummary(data, { indent: ' ', enableColors: true }), // Show the text summary to stdout... - 'summary_full.json': JSON.stringify(data), // and a JSON with all the details... - 'summary_short.json': JSON.stringify(customizedData), // and a JSON with all the details... - }; -} - diff --git a/001_symfony7_wo_db/testing-tools/k6/script_vus5_dur30s.js b/001_symfony7_wo_db/testing-tools/k6/script_vus5_dur30s.js deleted file mode 100644 index 0f228fb..0000000 --- a/001_symfony7_wo_db/testing-tools/k6/script_vus5_dur30s.js +++ /dev/null @@ -1,18 +0,0 @@ -import http from 'k6/http'; -import { sleep } from 'k6'; - -export const options = { - // A number specifying the number of VUs to run concurrently. - vus: 5, - // A string specifying the total duration of the test run. - duration: '30s', -}; - -// The function that defines VU logic. -// -// See https://grafana.com/docs/k6/latest/examples/get-started-with-k6/ to learn more -// about authoring k6 scripts. -// -export default function() { - http.get('http://symfony7site/?firstName=Randomlfirstname&lastName=Randomlastname'); -} diff --git a/001_symfony7_wo_db/testing-tools/k6_bench.js b/001_symfony7_wo_db/testing-tools/k6_bench.js new file mode 100644 index 0000000..e29d3dd --- /dev/null +++ b/001_symfony7_wo_db/testing-tools/k6_bench.js @@ -0,0 +1,35 @@ +import http from 'k6/http'; +import { textSummary } from 'https://jslib.k6.io/k6-summary/0.0.2/index.js'; + +// export const options = { +// // A number specifying the number of VUs to run concurrently. +// vus: 5, +// // A string specifying the total duration of the test run. +// duration: '5s', +// }; + +// The function that defines VU logic. +// +// See https://grafana.com/docs/k6/latest/examples/get-started-with-k6/ to learn more +// about authoring k6 scripts. +// +export default function() { + http.get('http://symfony7site/?firstName=Randomlfirstname&lastName=Randomlastname'); +} +// export function handleSummary(data) { +// /*return { +// 'summary.json': JSON.stringify(data), //the default data object +// };*/ +// const customizedData = { +// http_reqs: data.metrics.http_reqs.values.count, + +// rate: data.metrics.http_reqs.values.rate, +// avg_response_time: data.metrics['http_req_duration{expected_response:true}'].values.avg +// } +// return { +// 'stdout': textSummary(data, { indent: ' ', enableColors: true }), // Show the text summary to stdout... +// 'summary_full.json': JSON.stringify(data), // and a JSON with all the details... +// 'summary_short.json': JSON.stringify(customizedData), // and a JSON with all the details... +// }; +// } + From acbbf9feec78f3ec68859dcfdfb2750d8eaaa365 Mon Sep 17 00:00:00 2001 From: Joanhey Date: Sat, 20 Apr 2024 11:40:57 +0200 Subject: [PATCH 2/3] Run bench with all runtimes --- 001_symfony7_wo_db/Makefile | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/001_symfony7_wo_db/Makefile b/001_symfony7_wo_db/Makefile index f84daec..f887450 100644 --- a/001_symfony7_wo_db/Makefile +++ b/001_symfony7_wo_db/Makefile @@ -9,6 +9,8 @@ reqs := 1000 #bench_port := :80 bench_url := http://symfony7site$(bench_port)/?firstName=Randomlfirstname&lastName=Randomlastname +dirs := $(sort $(wildcard runtimes/*)) +runtimes := $(subst _,-,$(notdir $(dirs))) ## #################### 001 APACHE + mod_php #################### @@ -295,3 +297,12 @@ run/loadtest/bombardier: ## run/loadtest/wrk : Run wrk, vus=100 (default) duration=30s (default) run/loadtest/wrk: docker run --rm --name wrk-loadtest --network php-benchmarks williamyeh/wrk:4.0.2 -c $(vus) -d $(duration) $(bench_url) + +run/bench: start/runtime/$(runtime) run/loadtest/k6 stop/runtime/$(runtime) + @echo ---- $(runtime) ---- + +## run/bench/all : Run bench with k6, vus=100 (default) duration=30s (default) +run/bench/all: + @for name in $(runtimes); do \ + make run/bench runtime=$${name}; \ + done From 0ef71060a4220a6ee33ab56acb0d22a505a06329 Mon Sep 17 00:00:00 2001 From: Joanhey Date: Sat, 20 Apr 2024 13:51:13 +0200 Subject: [PATCH 3/3] Add sleep between runtimes --- 001_symfony7_wo_db/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/001_symfony7_wo_db/Makefile b/001_symfony7_wo_db/Makefile index f887450..d1ea5b9 100644 --- a/001_symfony7_wo_db/Makefile +++ b/001_symfony7_wo_db/Makefile @@ -305,4 +305,5 @@ run/bench: start/runtime/$(runtime) run/loadtest/k6 stop/runtime/$(runtime) run/bench/all: @for name in $(runtimes); do \ make run/bench runtime=$${name}; \ + sleep 3; \ done