【发布时间】:2021-04-03 18:50:33
【问题描述】:
我想使用 K6 来衡量 API 处理 1.000.000 个请求(总共)所花费的时间。
场景
执行 1.000.000(总共 100 万)获取 50 个并发用户/线程的请求,因此每个用户/线程执行 20.000 个请求。
我已经设法使用 Artillery.io 创建了这样一个场景,但我不确定如何在使用 K6 时创建相同的场景。你能指出我正确的方向以创建场景吗? (大多数示例都使用预定义的持续时间,但在这种情况下,我不知道持续时间 -> 这正是我想要测量的)。
炮兵yml
config:
target: 'https://localhost:44000'
phases:
- duration: 1
arrivalRate: 50
scenarios:
- flow:
- loop:
- get:
url: "/api/Test"
count: 20000
K6 js
import http from 'k6/http';
import {check, sleep} from 'k6';
export let options = {
iterations: 1000000,
vus: 50
};
export default function() {
let res = http.get('https://localhost:44000/api/Test');
check(res, { 'success': (r) => r.status === 200 });
}
【问题讨论】:
标签: load-testing k6