How to generate variable load using single scenario by specifying stream min and max size

I am using K6 with “k6/x/loki” extension to test Loki so that I can configure it to meet my requirements. Loki is installed in K8S cluster. The tests are running in same cluster.

I am trying to create a test with constant requests/second and variable stream size between 1MB and 10 MB. I have tried various approaches for this and so far, haven’t achieved the expected results.

Please note that I am not trying to increase load by increasing number of requests per second here. I am increasing load by increasing stream size. That’s why I have kept rate constant in each scenario.

Given below is K6 custom resource configuration:

Name:         k6-test-run-6343683
Namespace:    k6-test-run-6343683
Labels:       <none>
Annotations:  <none>
API Version:  k6.io/v1alpha1
Kind:         TestRun
Spec:
  Arguments:  --log-output=none
  Initializer:
    Image:  k6-image
    Node Selector:
      some-node-selector:  true
    Tolerations:
      Effect:    NoSchedule
      Key:       some-toleration-key
      Operator:  Equal
      Value:     true
  Parallelism:   10
  Runner:
    Image:    k6-image
    Node Selector:
      some-nodeselector:  true
    Tolerations:
      Effect:    NoSchedule
      Key:       some-toleration-key
      Operator:  Equal
      Value:     true
  Script:
    Config Map:
      File:  script.js
      Name:  k6-test-run-6343683
  Separate:  true

Test scenario:

scenarios: {
    generateLoad: {
      startTime: "0s",
      executor: "constant-arrival-rate",
      exec: "writePath",
      rate: 100,
      timeUnit: "1s",
      preallocatedVUs: 1000,
      maxVUs: 1100,
      duration: "60m"
  }

Test function:

export function writePath() {
  
  const random = Math.floor(Math.random() * 10) + 1; // A random integer from 1 to 10 
  const streamSize = random * 1024 * 1024;
  const res = lokiDistributorClient.pushParameterized(1, streamSize, (streamSize + 1));

  WriteOK.add(res.status === 204);
}

Expected result:
With above test design, I was expecting that because min size of the stream is 1MB, the test would generate the load between 1MB to 10MB.

Actual result:

But the Distributor Received bytes / sec graph came up like:


Can somebody please help me to understand why it did not work as expected?

@taraktrivedi

constant-arrival-rate executor tries to start 100 iterations over every second. If each iteration ends within 1 second, then you should get something around 500 MB/sec. I think you have a massive droped_iterations in the test end summary.

1 Like

Thanks @bandorko !

You are right. There were lots of dropped iterations (around 50%). I checked the reason and found that Loki Distributor was throwing following error.

client intended to send too large body

To solve this error I will have to either break the requests in to multiple small requests or increase value of max_body_size of Loki Gateway. As I want to test Loki with large size streams, I am going to try second option.

The problem I am facing right now is, I am using loki-distributed and it does not expose max_body_size parameter. So, I am looking into how can I set it even if it is not exposed by loki-distributed.

1 Like