Vegeta: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 58: Line 58:
Main event loop exit conditions:
Main event loop exit conditions:
# The attack duration expires.
# The attack duration expires.
# The <code>Pacer</code> says to stop.
# The <code>stopch</code> is written to.
# The <code>stopch</code> is written to.


Line 63: Line 64:


<font color=darkkhaki>What is a tick? The main event loop <code>count</code> counts ticks.</font>
<font color=darkkhaki>What is a tick? The main event loop <code>count</code> counts ticks.</font>
<code>Pacer</code> computes, via the <code>Pace()</code> method, the duration an <code>Attacker</code> should wait until hitting the next <code>Target</code>, given an already elapsed duration and completed hits. If the second return of the <code>Pace()</code> method is <code>true</code>, the <code>Attacker</code> should stop sending hits. <code>Pacer</code> also keeps the instantaneous hit rate per second at a given elapsed time during an attack.

Revision as of 18:20, 31 July 2024

External

TODO

Internal

Overview

Install

Command Line

brew install vegeta

For Development

go get github.com/tsenart/vegeta/v12@v12.11.1

Command Line Operations

Generate a plot with three different RPS.

Generate the HTTP request in a text file.

Then:

cat request.txt | vegeta attack -insecure -name=10RPS -rate=10 -duration=100s > results.10rps.bin
cat request.txt | vegeta attack -insecure -name=50RPS -rate=50 -duration=100s > results.50rps.bin
cat request.txt | vegeta attack -insecure -name=100RPS -rate=100 -duration=100s > results.100rps.bin
vegeta plot -title "Some Title" results.10rps.bin results.50rps.bin results.100rps.bin > plot.html

To get statistics from the bin file:

vegeta report ./results.10rps.bin

To Read Targets from File

vegeta attack -targets=<file> ...

Implementation Details

The Attack() function has a main event loop and "workers" goroutines, one per worker. The number of workers can be increased from the main event loop during an "attack" depending on what?.

Main event loop exit conditions:

  1. The attack duration expires.
  2. The Pacer says to stop.
  3. The stopch is written to.

The "ticks" channel is a conduit for ticks, represented as struct{}s.

What is a tick? The main event loop count counts ticks.

Pacer computes, via the Pace() method, the duration an Attacker should wait until hitting the next Target, given an already elapsed duration and completed hits. If the second return of the Pace() method is true, the Attacker should stop sending hits. Pacer also keeps the instantaneous hit rate per second at a given elapsed time during an attack.