From 07796d78d123b84c7dab13b5cf48551792c0f81f Mon Sep 17 00:00:00 2001 From: Dmitri Lerko Date: Wed, 4 Jan 2023 12:22:59 +0000 Subject: [PATCH] Adding workers flag to configure higher worker counts for super high load testing --- main.go | 3 ++- pkg/replay.go | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 0ca062f..1753070 100644 --- a/main.go +++ b/main.go @@ -34,10 +34,11 @@ func main() { timeout := flag.Int("timeout", 10, "HTTP client timeout in seconds") strict := flag.Bool("strict", false, "Panic on bad input") memprofile := flag.String("memprofile", "", "Write memory profile to `file` before exit") + numWorkers := flag.Int("workers", 1000, "Number of client workers to use") flag.Parse() - exitCode := ripley.Replay(*paceStr, *silent, *dryRun, *timeout, *strict) + exitCode := ripley.Replay(*paceStr, *silent, *dryRun, *timeout, *strict, *numWorkers) defer os.Exit(exitCode) if *memprofile != "" { diff --git a/pkg/replay.go b/pkg/replay.go index a04a051..e6cb08d 100644 --- a/pkg/replay.go +++ b/pkg/replay.go @@ -27,7 +27,7 @@ import ( "time" ) -func Replay(phasesStr string, silent, dryRun bool, timeout int, strict bool) int { +func Replay(phasesStr string, silent, dryRun bool, timeout int, strict bool, numWorkers int) int { // Default exit code var exitCode int = 0 // Ensures we have handled all HTTP request results before exiting @@ -52,7 +52,7 @@ func Replay(phasesStr string, silent, dryRun bool, timeout int, strict bool) int scanner := bufio.NewScanner(os.Stdin) // Start HTTP client goroutine pool - startClientWorkers(1000, requests, results, dryRun, timeout) + startClientWorkers(numWorkers, requests, results, dryRun, timeout) pacer.start() for scanner.Scan() {