tsenart/vegeta · error
-rate=0 requires setting -max-workers
Error message
-rate=0 requires setting -max-workers
What it means
Vegeta's attack command rejects a configuration where the request rate is left at its default (Freq==0, i.e. `-rate=0` meaning 'as fast as possible') while the worker pool is also left at the default max-workers. In that mode throughput is unbounded and driven entirely by workers, so vegeta requires an explicit worker count to avoid an ambiguous/accidentally unlimited attack. This is a deliberate argument-validation guard in attack().
Source
Thrown at attack.go:119
redirects int
maxBody int64
headers headers
proxyHeaders headers
laddr localAddr
keepalive bool
resolvers csl
unixSocket string
promAddr string
dnsTTL time.Duration
sessionTickets bool
connectTo map[string][]string
}
// attack validates the attack arguments, sets up the
// required resources, launches the attack and writes the results
func attack(opts *attackOpts) (err error) {
if opts.maxWorkers == vegeta.DefaultMaxWorkers && opts.rate.Freq == 0 {
return fmt.Errorf("-rate=0 requires setting -max-workers")
}
if len(opts.resolvers) > 0 {
res, err := resolver.NewResolver(opts.resolvers)
if err != nil {
return err
}
net.DefaultResolver = res
}
net.DefaultResolver.PreferGo = true
files := map[string]io.Reader{}
for _, filename := range []string{opts.targetsf, opts.bodyf} {
if filename == "" {
continue
}
f, err := file(filename, false)View on GitHub (pinned to cf58112690)
Solutions
- Pass an explicit worker count, e.g. add `-max-workers=10` (or the concurrency you want) alongside `-rate=0`.
- If you did not intend unlimited rate, set a real rate such as `-rate=100/s` and leave -max-workers at its default.
- If -rate is read from a config/variable, ensure it is never the zero value unless max-workers is also set.
Example fix
// before vegeta attack -rate=0 -duration=10s -targets=targets.txt // after vegeta attack -rate=0 -max-workers=50 -duration=10s -targets=targets.txt
Defensive patterns
Strategy: validation
Validate before calling
if rate == 0 && maxWorkers == vegeta.DefaultMaxWorkers {
return fmt.Errorf("-rate=0 requires setting -max-workers")
} Prevention
- Always pass -max-workers explicitly when using -rate=0.
- Wrap vegeta invocations in a script that asserts rate/max-workers combination before exec.
- Keep rate and worker settings together in one config block to avoid partial overrides.
When it happens
Trigger: Running `vegeta attack -rate=0 ...` (or omitting -rate so it defaults to 0) without also passing a `-max-workers` value other than the default (DefaultMaxWorkers).
Common situations: Users copying old vegeta examples where `-rate=0` meant unlimited rate; CI scripts that pass -rate=0 for maximum throughput but forget -max-workers; users upgrading vegeta and hitting the newly enforced rule.
Related errors
- format %q isn't one of [%s]
- encode: unknown encoding %q
- rate frequency and time unit must be bigger than zero
- encode: can't detect encoding of %q
- header '%s' has a wrong format
AI-assisted analysis of tsenart/vegeta@cf58112690 (2026-08-31).
Data as JSON: /api/errors/59200db6c35f919c.
Report an issue: GitHub.