Hi.
I would like to create a map of SharedArray
s and was wondering if there was a good way to do so. I currently have a data set which is a map from site IDs to productIDs. The reason I want to use a SharedArray
is because some sites have up to 100k product IDs.
{
"site0": [
1,
2,
3,
4
],
"site1": [
3,
4,
5,
6
],
...
}
I tried creating an object like so:
var productMap = JSON.parse(open("productsBySite.json"));
var productsBySite = {};
var sites = Object.keys(productMap);
for (let i = 0; i < sites.length; i++) {
productsBySite[sites[i]] = new SharedArray(sites[i], function () {
return productMap[sites[i]];
});
}
I have 2 questions:
1. When retrieving an object in VU code, will just the productID be called into the VU’s memory, or is the entire map first loaded into memory?
For example:
const siteName = randomItem(sites);
const productId = randomItem(products[siteName]);
// is the whole of products copied to VU memory, or just productID?
2. This has caused k6 to use an unsustainable amount of CPU and memory usage when starting a load test, and when using many VUs would take a very long time to start. Is there a more efficient way of performing this?
Here is the output from top
when trying to initiate 100VUs using the script above. It was starting the VUs very slowly, maybe 2-3 per minute.
Thanks!