Vegeta: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(9 intermediate revisions by the same user not shown)
Line 13: Line 13:


=Internal=
=Internal=
* [[Load_Testing#Tools|Load Testing]]
* [[Performance_Concepts#Tools|Performance Concepts]]


=Overview=
=Overview=
=Vegeta and Coordinated Omission=
Vegeta avoids the coordinated omission problem because it keeps sending requests at constant rate when the system under load starts not responding in time. It does that by increasing the number of workers (goroutines) when the current workers get stuck handling slow requests. Explanation [https://github.com/tsenart/vegeta/pull/92/files#r20198929 here].
{{Internal|Performance_Concepts#Coordinated_Omission|Performance Concepts | Coordinated Omission}}


=Install=
=Install=
Line 25: Line 30:
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
go get github.com/tsenart/vegeta/v12@v12.11.1
go get github.com/tsenart/vegeta/v12@v12.11.1
</syntaxhighlight>
==On Linux==
<syntaxhighlight lang='bash'>
wget https://github.com/tsenart/vegeta/releases/download/v12.12.0/vegeta_12.12.0_linux_amd64.tar.gz
tar xfvz ./vegeta_12.12.0_linux_amd64.tar.gz
rm ./vegeta_12.12.0_linux_amd64.tar.gz
chmod a+x ./vegeta
</syntaxhighlight>
</syntaxhighlight>


Line 50: Line 62:
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
vegeta attack -targets=<file> ...
vegeta attack -targets=<file> ...
</syntaxhighlight>
==Filter Output==
<syntaxhighlight lang='bash'>
cat ./results.bin | vegeta encode | jq -c 'del(.body)' | jq
</syntaxhighlight>
</syntaxhighlight>


Line 66: Line 82:


<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.
<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.
The main event loop <code>Sleep(wait)</code>s after calling the pacer <code>Pace()</code>.
An individual worker goroutine blocks reading from <code>ticks</code> channel and for each tick, executes a hit and writes the result on the <code>results</code> channel
{{Internal|Vegeta_Diagram|Diagram}}

Latest revision as of 22:00, 2 August 2024

External

TODO

Internal

Overview

Vegeta and Coordinated Omission

Vegeta avoids the coordinated omission problem because it keeps sending requests at constant rate when the system under load starts not responding in time. It does that by increasing the number of workers (goroutines) when the current workers get stuck handling slow requests. Explanation here.

Performance Concepts | Coordinated Omission

Install

Command Line

brew install vegeta

For Development

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

On Linux

wget https://github.com/tsenart/vegeta/releases/download/v12.12.0/vegeta_12.12.0_linux_amd64.tar.gz
tar xfvz ./vegeta_12.12.0_linux_amd64.tar.gz 
rm ./vegeta_12.12.0_linux_amd64.tar.gz
chmod a+x ./vegeta

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> ...

Filter Output

cat ./results.bin | vegeta encode | jq -c 'del(.body)' | jq

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.

The main event loop Sleep(wait)s after calling the pacer Pace().

An individual worker goroutine blocks reading from ticks channel and for each tick, executes a hit and writes the result on the results channel

Diagram