Performance test using k6

Performance test using k6

K6 is a popular open-source load testing tool designed for developers and DevOps teams to create and execute performance , load tests to simulate user traffic, API requests, and other types of network activity. K6 offers a user-friendly, scriptable interface that allows you to write and execute load tests with simplicity.

K6 has offers high level of customization, real-time metrics,distributed testing,multiple protocols.It has very strong documentation . K6 is used by a variety of organizations and individuals, including developers, testers, DevOps engineers,?and site reliability engineers, to help ensure their applications and systems can handle high levels of traffic and activity without performance degradation or downtime.?

Organization who need high-performance, reliable, and scalable web applications or APIs must use k6


Here is a very simple code to test my localhost application login behavior with 50 users

import http from 'k6/http'

import { check, sleep } from 'k6';

export let options = {

?vus: 50,?????????????????????? ?// number of virtual users

?duration: '5m',????????????// duration for which virtual users can send reuqest

?thresholds: {

??http_req_duration: ['p(90)<5000'],??????// 90 % request should pass within 5 sec

??http_req_failed: ['rate<0.1'],??????????????// only 10 % request can fail

?},};

export default function () {

?let res = http.post('https://localhost/login', {???????//application url

??email: '[email protected]',??????????????? ?//login username?

??password: 'password123',???????????????? ?//login password

?});

?check(res, { 'status was 200': (r) => r.status == 200 }); //check response code

?sleep(1);???????????????????????? ? //sleep for 1 sec

};        

?

You can run the test like?

k6 run Applicationlogin.js???//Applicationlogin is the name of file where you wrote the above test

How store results?

you can use influx plugin with grafana to store the results.if you have already installed/configure influx?

you can run "k6 run --out influxdb=influxURL Applicationlogin.js"?to store the performance and loadtest results in influxdb and display them using grafana

要查看或添加评论,请登录

Kashif Mehmood的更多文章

  • AWS SSM for Bastion host

    AWS SSM for Bastion host

    Many IT companies already using cloud providers (like Amazon AWS, Google GCP or Microsoft Azure) . A lot of IT…

  • Monitor websites with Prometheus, Granfa and Blackbox

    Monitor websites with Prometheus, Granfa and Blackbox

    I am assuming that you have already setup Prometheus and Grafana Lets start with blackbox exporter installation and…

    2 条评论
  • How to reduce docker Image?

    How to reduce docker Image?

    Docker is an open-source platform that enables developers to build, package, and deploy applications as containerized…

    1 条评论

社区洞察

其他会员也浏览了