tsenart/vegeta · error

rate frequency and time unit must be bigger than zero

Error message

rate frequency and time unit must be bigger than zero

What it means

errZeroRate is returned by vegeta's attack setup when the configured rate's frequency or per-time-unit value is zero or negative. A rate attacker cannot schedule requests without a positive request frequency and time unit, so vegeta rejects the configuration up front instead of running a no-op attack.

Source

Thrown at attack.go:75

	fs.Var(&opts.headers, "header", "Request header")
	fs.Var(&opts.proxyHeaders, "proxy-header", "Proxy CONNECT header")
	fs.Var(&opts.laddr, "laddr", "Local IP address")
	fs.BoolVar(&opts.keepalive, "keepalive", true, "Use persistent connections")
	fs.StringVar(&opts.unixSocket, "unix-socket", "", "Connect over a unix socket. This overrides the host address in target URLs")
	fs.StringVar(&opts.promAddr, "prometheus-addr", "", "Prometheus exporter listen address [empty = disabled]. Example: 0.0.0.0:8880")
	fs.Var(&dnsTTLFlag{&opts.dnsTTL}, "dns-ttl", "Cache DNS lookups for the given duration [-1 = disabled, 0 = forever]")
	fs.BoolVar(&opts.sessionTickets, "session-tickets", false, "Enable TLS session resumption using session tickets")
	fs.Var(&connectToFlag{&opts.connectTo}, "connect-to", "A mapping of (ip|host):port to use instead of a target URL's (ip|host):port. Can be repeated multiple times.\nIdentical src:port with different dst:port will round-robin over the different dst:port pairs.\nExample: google.com:80:localhost:6060")
	systemSpecificFlags(fs, opts)

	return command{fs, func(args []string) error {
		fs.Parse(args)
		return attack(opts)
	}}
}

var (
	errZeroRate = errors.New("rate frequency and time unit must be bigger than zero")
	errBadCert  = errors.New("bad certificate")
)

// attackOpts aggregates the attack function command options
type attackOpts struct {
	name           string
	targetsf       string
	format         string
	outputf        string
	bodyf          string
	certf          string
	keyf           string
	rootCerts      csl
	http2          bool
	h2c            bool
	insecure       bool
	lazy           bool
	chunked        bool

View on GitHub (pinned to cf58112690)

Solutions

  1. Set a positive rate, e.g. `-rate 100/s` or Rate{Frequency: 100, Per: time.Second}.
  2. Validate the rate value before invoking attack: if opts.rate.Frequency <= 0 || opts.rate.Per <= 0, error out with a clear CLI usage message.
  3. Check where the rate is computed (config files, flags) for zero-producing arithmetic.

Example fix

// before
vegeta attack -rate 0/s -duration 5s -targets targets.txt
// after
vegeta attack -rate 50/s -duration 5s -targets targets.txt
Defensive patterns

Strategy: validation

Validate before calling

if rate.Frequency <= 0 || rate.Per <= 0 {
    return fmt.Errorf("invalid rate %d/%s: frequency and period must be > 0", rate.Frequency, rate.Per)
}

Prevention

When it happens

Trigger: Calling vegeta's attack path (CLI `vegeta attack -rate 0/s` or the library attack/attackOpts flow in attack.go) where rate.Frequency <= 0 or rate.Per <= 0 after flag parsing.

Common situations: Typo in the -rate flag (e.g. `-rate 0`), computing the rate programmatically from a divisor that yields 0, or zero-value rate structs passed to the library API without initialization.

Understand the failure class

Background: "Invalid configuration value" and "Unsupported/Unknown setting value" errors: why libraries reject your config strings, numbers, and types — this error's family across 30 libraries.

Related errors


AI-assisted analysis of tsenart/vegeta@cf58112690 (2026-08-31). Data as JSON: /api/errors/aeaa798604ebea7a. Report an issue: GitHub.