Skip to content

Commit

Permalink
Merge #70642
Browse files Browse the repository at this point in the history
70642: democluster: expose flag for workload rate limit on demo r=knz a=otan

Release note (cli change): The 25 max QPS rate limit for workloads on
`cockroach` demo can now be configured with a `workload-max-qps` flag.

Co-authored-by: Oliver Tan <[email protected]>
  • Loading branch information
craig[bot] and otan committed Sep 24, 2021
2 parents 117de30 + 0955729 commit 6994559
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions pkg/cli/cliflags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,11 @@ can also be specified (e.g. .25).`,
Description: `Run a demo workload against the pre-loaded database.`,
}

DemoWorkloadMaxQPS = FlagInfo{
Name: "workload-max-qps",
Description: "The maximum QPS when a workload is running.",
}

DemoNodeLocality = FlagInfo{
Name: "demo-locality",
Description: `
Expand Down
1 change: 1 addition & 0 deletions pkg/cli/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,7 @@ func setDemoContextDefaults() {
demoCtx.Insecure = false
demoCtx.SQLPort, _ = strconv.Atoi(base.DefaultPort)
demoCtx.HTTPPort, _ = strconv.Atoi(base.DefaultHTTPPort)
demoCtx.WorkloadMaxQPS = 25
}

// stmtDiagCtx captures the command-line parameters of the 'statement-diag'
Expand Down
4 changes: 4 additions & 0 deletions pkg/cli/democluster/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ type Context struct {
// WorkloadGenerator is the desired workload generator.
WorkloadGenerator workload.Generator

// WorkloadMaxQPS controls the amount of queries that can be run per
// second.
WorkloadMaxQPS int

// Localities configures the list of localities available for use
// by instantiated servers.
Localities DemoLocalityList
Expand Down
4 changes: 2 additions & 2 deletions pkg/cli/democluster/demo_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1091,8 +1091,8 @@ func (c *transientCluster) runWorkload(
return errors.Wrap(err, "unable to create workload")
}

// Use a light rate limit of 25 queries per second
limiter := rate.NewLimiter(rate.Limit(25), 1)
// Use a rate limit (default 25 queries per second).
limiter := rate.NewLimiter(rate.Limit(c.demoCtx.WorkloadMaxQPS), 1)

// Start a goroutine to run each of the workload functions.
for _, workerFn := range ops.WorkerFns {
Expand Down
1 change: 1 addition & 0 deletions pkg/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,7 @@ func init() {

intFlag(f, &demoCtx.NumNodes, cliflags.DemoNodes)
boolFlag(f, &demoCtx.RunWorkload, cliflags.RunDemoWorkload)
intFlag(f, &demoCtx.WorkloadMaxQPS, cliflags.DemoWorkloadMaxQPS)
varFlag(f, &demoCtx.Localities, cliflags.DemoNodeLocality)
boolFlag(f, &demoCtx.GeoPartitionedReplicas, cliflags.DemoGeoPartitionedReplicas)
varFlag(f, demoNodeSQLMemSizeValue, cliflags.DemoNodeSQLMemSize)
Expand Down

0 comments on commit 6994559

Please sign in to comment.