
John Hayes
Senior Product Marketing Manager, SquaredUp
Senior Product Marketing Manager, SquaredUp
Load testing is an extremely valuable practice for assessing how your application will actually perform in production. Whether you're expecting a handful of concurrent users or anticipate thousands, it's important to have an idea of the kind of loads that will be placed on your systems and be aware of where bottlenecks or saturation may occur.
If you are running your applications in the cloud, load testing has the additional advantage of letting you know whether you have actually over-provisioned resources – therefore enabling you to right-size and make cost savings.
There was a time when load testing tools were unwieldy and expensive. Today though, there are a large number of open source load testing applications, and Grafana’s K6 is one of the most popular.
If you want to visualize and share the results of your K6 tests, then just let SquaredUp take the load!
K6 runs as a transient application that does not expose a persistent public API. You can, however, forward on your test results to a number of different endpoints, or you can output them in a number of formats, including CSV.
In this article we will be creating a simple load test in K6 and saving the output as a CSV file. We will then retrieve our data using the SquaredUp CSV Data Source and visualize the results with our smart dashboards.
K6 load tests are written in Javascript, and both the structure and syntax are really intuitive. The image below shows the code that will run our tests.
Without any prior knowledge, it's pretty easy to see that our test consists of three stages, where we ramp up to 20 users, and then ramp down again.
We then define an array of URLs and create a loop to invoke the Check function against each URL. It really is beautifully simple.
Equally, to kick off the test and have the results output to a CSV file, we just run a simple command in our terminal:
In the example above, we execute a test script called ‘script.js’ and it will output the results in CSV format with the file name we have specified.
All we need to do now is upload this CSV file to any http endpoint, so that it can be queried by the SquaredUp CSV Data Source. The K6 output file contains many different metrics, so there are plenty of different visualizations we can create.
In this article we are going to look a creating a dashboard like the one below – but there are myriad other possibilities:
As the image below shows, using the SquaredUp CSV Data Source to retrieve our test results is simplicity itself – just enter the URL of the file:
Now we have our data, let's start building our dashboard. Our first dashboard tile uses a Table Visualization to list the tests we have run:
If you look at the structure of the test results file, you will see that it is quite jagged, with a mix of different types of record.
For our table, we want to exclude the summary rows. In SquaredUp, this is not a problem. In the non-standard rows, the Name field is empty and I can use a simple filter to exclude them.
Now that I have excluded unwanted results, I can concentrate on extracting insights from the subset that interests me. When it comes to analyzing and summarizing the results of this test, there are a number of headline metrics I want to focus on.
Firstly, I want to compare performance across sites. I can represent this really effectively with a donut chart.
Generating this was completely frictionless, as SquaredUp automatically guessed the right fields for labels and values:
Next I wanted to dig a bit deeper and get a breakdown of errors by http status code. Straightaway, I can see that there are a lot of 403 errors – indicating an authentication issue:
Once again, building this visualization was really straightforward. First of all I needed to do some data shaping. As I want to analyze only those requests that resulted in an error, I have filtered out any result where the http Status Code was not 200 (the value for success) and then grouped the dataset by Status:
Then all I had to do was select the Bar Chart Visualization and SquaredUp identified the correct X and Y-axis fields.
Naturally, for a load test, I will want to see average page load times and also analyze the performance of each of the underlying processes as user numbers increase.
In the tile below, I can see that, as the user count grows from 1 to 2, there is quite a dramatic uplift in metrics such as request duration, request blockage and handshaking.
For creating this tile, I wanted to group my results by User Count. Effectively, this means that I want to treat the number of users as a string rather than a number. I can do this with some simple column formatting:
In order to group each of the metrics by user count, I need to do some manual configuration for the bar chart mapping:
The two most important configurations here are:
For the next tile in my dashboard, I want to compare load times across my websites.
To achieve this result, I am going to take a slightly different approach to the previous visualization. In the Shaping step I am going to define two groupings. One for Name (the name of the website) and one for Metric Name.
I then need to specify that I want SquaredUp to show me the Average for each metric type.
I also need to check the mappings for my bar chart.
Because I have shaped the data, SquaredUp can automatically identify the correct values for the X-axis, Y-axis and Series settings. So all I need to do is toggle the Show as groups option.
In this article, we have covered quite a lot of ground. By combining the robust and scalable testing capabilities of K6 with the simplicity and versatility of SquaredUp, we can build advanced load testing scenarios and visualize the results with sophisticated visualizations in SquaredUp.
At SquaredUp, we want to democratize your data so that all relevant stakeholders have access to important insights. This is why we have introduced dashboard sharing on all of our plans.
If you don't have a SquaredUp account, you can get started on Free Forever plan and start building smart dashboards in minutes. Sign up now and have a try!