An overview of some key differences between k6 Cloud (JS) and LoadImpact (Lua)
From a general performance testing perspective the 3.0 and 4.0 products are more or less the same:
- You create one or more user scenarios that step through a particular process of your target system that you want to test.
- You then combine your user scenario(s) with a traffic simulation profile that specifies how many Virtual Users (VUs) should be concurrently executing the user scenario(s) at different points in time of the test.
- You execute your test, metrics data is collected and you are presented with results.
When looking more closely though there are some differences in how you accomplish step 1, 2 and 3 above.
A big difference is in the workflow that you can accomplish with each respective product.
The 3.0 product is completely cloud based, user scenarios and test configuration are created/edited and stored in the LoadImpact cloud service, and running tests is also done exclusively from the cloud. This also means the target system that is being tested needs to be accessible from the public Internet.
In the 3.0 product user scenarios described using Lua code. You can end up with the Lua code in various ways, by using one of the recorder options, the Postman converter or hand coding it, but at the end of the day the output of all these various ways is a piece of Lua code.
See the Lua to JS migration guide down below for more information on how to migrate your Lua user scenarios to JS.
In the 3.0 product you compose one or more user scenarios into a separate entity known as a "Test" (aka "Test configuration"), and then add additional configuration like traffic simulation profile and thresholds. This is done through the LoadImpact WebApp UI.
In the 4.0 product the equivalent configuration options are specified in the script itself:
On highest level there are some differences to be aware of before we continue on into more details.
In Lua all the available functionality is loaded by default, APIs can be called right away without explicit loading/importing, while In JS you need to explicitly import the builtin modules and APIs that you want to use:
In Lua VUs execute the script from top to bottom over and over, while in JS VUs execute the global scope (aka "init code") once to initialize, and then executes the "main function" (export default function) over and over:
Below you have examples on how to have a VU sleep or think for a specific amount of time (in the example below for 3 seconds), pausing the VU execution:
To make HTTP requests there are a number of different Lua APIs available. In the end they're all wrappers around the http.request_batch() API. Below you can see a comparison for Lua and JS:
See the HTTP API docs for k6 for more information and examples.
In the 3.0 product there's a concept of pages. Lua code in between calls to http.page_start() and http.page_end() will be measured to provide a page load times in the results. The equivalent in JS would be to use Groups:
In the 3.0 product there's a concept of a datastore. A CSV file that you can upload to the service and then attach to your user scenario for accessing and using the data in your user scenario logic.
In the 4.0 product there's no specific concept of a datastore, but in k6 you have two different ways to separate test parameterization data from script logic.
Both of the examples below can be run with:
more info here: open
Beyond the standard metrics collected by the 3.0 product you can also collect custom metrics using the results.custom_metric() API in the example below. The equivalent in JS would be to use the Trend custom metric:
For more information, see our docs on custom metrics (Additional metrics for Counter, Gauge and Rate are available beyond the Trend one used above).