Load testing with Vegeta

Bharat Kalluri / 2020-09-30

Load testing is testing the behavior of an application under real life conditions by stimulating a bunch of concurrent requests.

A load test allows you to understand how the server performs under peak load, using load testing tools you can check how the server performs in terms of CPU, latency, throughput and many more metrics.

Load testing a golang gin server

For my digital ocean 5$ single vCPU 2.1 Ghz instance running a golang gin server. Testing with a simple GET request which just reads and returns data from the database, these are the metrics Vegeta came up with

❯ echo "GET https://golang-api.bharatkalluri.in/api/v1/book" | vegeta attack -max-workers=40 -rate=0 -duration=30s | tee results.bin | vegeta report                              ⏎
Requests      [total, rate, throughput]         2966, 98.22, 98.11
Duration      [total, attack, wait]             30.233s, 30.198s, 34.181ms
Latencies     [min, mean, 50, 90, 95, 99, max]  33.338ms, 407.429ms, 73.615ms, 928.117ms, 938.114ms, 960.45ms, 2.408s
Bytes In      [total, mean]                     329226, 111.00
Bytes Out     [total, mean]                     0, 0.00
Success       [ratio]                           100.00%
Status Codes  [code:count]                      200:2966
Error Set:

The max utilization I saw on my server was 40% at 100 requests per second!


Hand crafted by Bharat Kalluri