Loading group of URLs testing Http duration threshold

Hi all,

I am trying to load test a group of urls to see if it can load them in sequence in less than 5 seconds. would this be the correct way to do that? When I run it there are no errors but many of the mins and meds are 0s and thats concerning for me.

import http from 'k6/http';

import { group, sleep } from "k6";

export let options = {

    stages: [

        { duration: "45s", target: 50 },

        { duration: "1m", target: 50 },

        { duration: "45s", target: 0 },

      ],

    thresholds: {

      'http_req_duration': ['avg < 5000'],

    },

};

export default function () {

    group(' elasticsearch', function () {

      group(':9200', function () {

        let responses = http.batch([

            ['POST', 'http://10.1.11.254...........'],

            ['POST', 'http://10.1.11.254..........'],

            ['POST', 'http://10.1.11.254:............'],

            ['POST', 'http://10.1.11.254...........'],

            ['POST', 'http://10.1.11.254..........'],

            ['POST', 'http://10.1.11.254...........'],

            ['POST', 'http://10.1.11.254.........'],

            ['GET', 'http://10.1.11.254..........'],

            ['GET', 'http://10.1.11.254...........'],

            ['GET', 'http://10.1.11.254...........'],

            ['POST', 'http://10.1.11.254.........'],

            ['POST', 'http://10.1.11.254.......'],

            ['POST', 'http://10.1.11.254......'],

            ['POST', 'http://10.1.11.254......'],

            ['POST', 'http://10.1.11.254..........'],

            ['POST', 'http://10.1.11.254.........'],

            ['GET', 'http://10.1.11.254..........'],

            ['POST', 'http://10.1.11.254.........],

            ['POST', 'http://10.1.11.254............'],

            ['POST', 'http://10.1.11.254......'],

            ['POST', 'http://10.1.11.254.........'],

            ['POST', 'http://10.1.11.254........'],

            ['POST', 'http://10.1.11.254...........'],

        

        ])

    });

  })

}

Hi @ralex7,

The reason behind some of the 0s will be that … they are zeros :slight_smile: If you take a close look at the builtin HTTP metrics. You will see that http_req_connecting and http_req_tls_handshaking for example will always be 0 for requests on an already made a connection.

Depending on how you make your requests and whether it uses HTTP1/1 or HTTP2 you do have even chance to start getting the result before the full request has been send (this IMO is fairly rare, but still possible) you can even get http_req_waiting to be 0 :wink: .

Other of the “sub” http_req_duration can also pretty easily be 0 in good network conditions and no overloading on both side, especially if the SUT is on the same machine as k6. To get the whole http_req_duration to be 0 is probably going to be hard … but again not impossible.

Especially in the end results in the cli, as it might be showing 0s but that might still mean 1ms or something like that. See this issue for how to circumvent that.

You can change the reusing of connections behavior through no-connection-reuse and no-vu-connection-reuse depending on what you want to simulate .

As far as I can see you are doing things … correctly, maybe if you provide some specific numbers and why you think those can’t be zero we can help :).