OSS Release: HTTP Load + SLA Testing Utility With Go

This blog introduces an open-source HTTP load testing command line utility implemented in Go, khsLoad. It is used to test the performance of APIs and websites through user simulation and has features for creating data graphs useful for SLAs.

The Go programming language is a popular way to develop middleware and system-level type applications. Introduced in 2009, Go was invented by Google engineers as an alternative to the stalwart C and C++ languages.

It boasts clean, concise syntax, type safeness, and automatic memory management that build into executable binaries which have made it a good alternative to C. Go’s popularity in the infrastructure-as-code DevOps and microservice architecture space are apparent by all the frameworks and tools built with Go (i.e., Docker, Istio, and Kubernetes… to name a few).

khsLoad is available as open-source; visit the repository at https://github.com/in-the-keyhole/khs-load and see the README for installation and running instructions.

khsLoad, The Open Source Go Utility

khsLoad is used to test the performance of APIs and websites. The command-line utility allows for simulated users to invoke HTTP-based URLs over a specified duration. Throughput and bytes transferred are reported and results can be saved to a CSV file that can be generated into a graph plot.

Use cases include:

  • A/B testing a load on an application’s web pages—testing web pages with khsLoad, then applying caching or other performance optimizations and validating if those changes make a difference.
  • Testing the working functionality of mechanisms like governing, throttling, and rate-limiting on APIs for consumer use.
  • Testing and validating websites and APIs to ensure that response time service-level agreements (SLAs) are being met.

Seeing khsLoad In Action

Let’s discuss an example that runs a free weather API that returns meta-data for a longitude/latitude location. It will be configured to run for 30 seconds with four users.

$ ./khsload do

When executed, the following information will be output to the console:

Throughput Per Second
Bytes Per Second
Transaction Execution Time That Exceeds Sla Default 1 Second

Command-line flags can be used to configure a load test execution. Available options are shown below.

--duration Int Number of seconds to run test
--users Int Number of users to simulate
--ramp Int Number of seconds between starting users
--wait Int Number of seconds to wait between requests
--sla Int Number of milliseconds used to report transaction duration that exceeds this amount
--config string YAML config file see YAML Config section below
--save string Save results to CSV file
--replace string Save and replace file if exists results to CSV file
--contenttype string Type (e.g. application/json) for POSTING data
--authtoken string Authorization token
--tokentemplate string Expression to format authtoken in request header

Here’s an example test session that load tests a URL for 120 seconds with 25 users that ramp up every two seconds.

$./khsload do –users 25 –duration 120 –ramp 2

All of these options can be specified in a YAML config file – details are in the section below.

Graphing Results

Load test results can be saved to a CSV file that can then be used to produce graphs. A CSV file is generated by using the –save or –replace flags. An example is shown below.

$./khsload do –users 4 –save testapi.csv

Results will be saved to a testapi.csv which can then be used as input to the plot command to produce a performance graph named test.png. Here’s the command:

$./khsload plot testapi.csv -file test.png

Here is the plot that is generated to a file named test.png:

Service Level Agreement (SLA) Graph

SLA results of the test can also be generated from the CSV file. This helps visualize transactions that exceed the SLA value. The command below shows this.

$./khsload sla testapi.csv –file tesla.png

Here’s an example graph that would be generated:

YAML Configuration

You can configure load test options by specifying users, duration, time between, requests with command-line flags, or defined in a YAML config. See the README in the repository for more details.

Sum Up

So, to sum up, khsLoad is a Go-based command-line utility that simulates users to invoke HTTP-based URLs over a specified duration. Throughput and bytes transferred are reported and results can be saved to a CSV file that can be generated into a graph plot.

khsLoad is available as open source. Please visit its Github repository for more information:
https://github.com/in-the-keyhole/khs-load.

Leave a Reply

Your email address will not be published. Required fields are marked *