drashland / drash

A microframework for building JavaScript HTTP applications. Runtime-agnostic. Strongly typed.
https://drash.land/drash
GNU General Public License v3.0
1.08k stars 32 forks source link

question: k6 tests a lot of fails #695

Closed sysmat closed 1 year ago

sysmat commented 1 year ago

Summary

What is your question?

import * as Drash from "https://deno.land/x/drash/mod.ts";

class HomeResource extends Drash.Resource {
    public paths = ["/"];
    public GET(request: Drash.Request, response: Drash.Response): void {
        return response.json({
            hello: "world",
            time: new Date(),
        });
    }
}

const server = new Drash.Server({
    hostname: "localhost",
    port: 7780,
    protocol: "http",
    resources: [HomeResource],
});

server.run();
console.log(`Server running at ${server.address}.`);
import { check } from 'k6';
import http from 'k6/http';

const TAG_APP_NAME = 'drash-test';
const tags = { app: TAG_APP_NAME };
const AAI_BASE_URL = 'http://localhost:7780';

export let options = {
    scenarios: {
        common: {
            // name of the executor to use
            executor: 'shared-iterations',
            tags,

            // common scenario configuration
            startTime: '10s',
            gracefulStop: '5s',

            // executor-specific configuration
            vus: 10,
            iterations: 200,
            maxDuration: '10s',
        },
        per_vu: {
            executor: 'per-vu-iterations',
            tags,
            vus: 5,
            iterations: 200,
            maxDuration: '10s',
        },
        constant_vus: {
            executor: 'constant-vus',
            tags,
            vus: 5,
            duration: '10s',
        },
        ramping_vus: {
            executor: 'ramping-vus',
            tags,
            startVUs: 0,

            stages: [
                { target: 40, duration: '3m' },
                { target: 20, duration: '2m' },
                { target: 0, duration: '1m' },
            ]
        },
        constant_arrival_rate: {
            executor: 'constant-arrival-rate',
            tags,
            duration: '20s',
            rate: 5,
            timeUnit: '1s',
            preAllocatedVUs: 2,
            maxVUs: 20,
        },
        ramping_arrival_rate: {
            executor: 'ramping-arrival-rate',
            tags,
            startRate: 2,
            timeUnit: "1s",
            preAllocatedVUs: 2,
            maxVUs: 20,   // It is allowed to spin up to 20 maximum VUs in order to sustain the defined
            stages: [
                // It should start 5 iterations per `timeUnit` for the first 2 seconds.
                { target: 5, duration: "2s" },
                { target: 10, duration: "10s" },
                { target: 15, duration: "15s" },
                { target: 2, duration: "2s" },
            ]
        },
    },
    thresholds: {
        http_req_duration: ['p(50)<4000', 'p(70)<5000', 'p(95)<6000'], // 90% of requests must complete below 6s
    },
};

export default function () {

    const url = `${AAI_BASE_URL}/`;

    const params = {
        headers: {
            'Content-Type': 'application/json'
        },
        tags
    };

    let res = http.get(url, params);

    check(res,
        {
            'status is 200': (r) => r.status === 200
        },
        tags
    );
}

running (6m01.4s), 00/65 VUs, 4117 complete and 0 interrupted iterations constant_arrival_rate ✓ [======================================] 00/13 VUs 20s 5.00 iters/s constant_vus ✓ [======================================] 5 VUs 10s per_vu ✓ [======================================] 5 VUs 10s 0025/1000 iters, 200 per VU ramping_arrival_rate ✓ [======================================] 00/20 VUs 29s 04.04 iters/s ramping_vus ✓ [======================================] 00/40 VUs 6m0s common ✗ [========>-----------------------------] 10 VUs 10.4s/10s 050/200 shared iters

 ✗ status is 200
  ↳  0% — ✓ 0 / ✗ 4117

 checks.....................: 0.00%   ✓ 0         ✗ 4117
 data_received..............: 0 B     0 B/s
 data_sent..................: 0 B     0 B/s
 dropped_iterations.........: 1212    3.353532/s
 http_req_blocked...........: avg=0s   min=0s med=0s    max=0s    p(90)=0s    p(95)=0s
 http_req_connecting........: avg=0s   min=0s med=0s    max=0s    p(90)=0s    p(95)=0s

✓ http_req_duration..........: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s http_req_failed............: 100.00% ✓ 4117 ✗ 0 http_req_receiving.........: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s http_req_sending...........: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s http_req_tls_handshaking...: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s http_req_waiting...........: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s http_reqs..................: 4117 11.391494/s iteration_duration.........: avg=2.1s min=2s med=2.03s max=2.76s p(90)=2.34s p(95)=2.39s iterations.................: 4117 11.391494/s vus........................: 1 min=1 max=47 vus_max....................: 65 min=42 max=65

crookse-carimus commented 1 year ago

Hey @sysmat, thanks for bringing this up. Unfortunately, we don't have time to look into this as we are focusing on a major version upgrade for Drash and cleanup efforts of other projects. Apologies! We MAY look into this, but we cannot make any promises.

crookse commented 1 year ago

Closing this since it's quiet. Feel free to reopen.