grafana K6压测
https://grafana.com/docs/k6/latest/get-startedinstall and run
[*]install
# mac
brew install k6
[*]当前目录下生成压测脚本
# create file script.js
k6 new # create file ‘script.js’ in the current directory
3 run
k6 run script.js
[*]reports
默认环境下,k6 将总结结果打印到 stdout 。
script.js
import http from 'k6/http';
import { check, sleep } from 'k6';
export const options = {
vus: 10,
duration: '30s',
};
export default function () {
const res = http.get('http://test.k6.io');
check(res, { 'status was 200': (r) => r.status == 200 });
sleep(1);
}
options
https://grafana.com/docs/k6/latest/using-k6/k6-options/reference/
[*]vus
虚拟用户数
[*]duration
连续时间
[*]rps
每秒哀求数量
哀求总数 = vus * rps * durance(s)
import http from 'k6/http';
import { check, sleep } from 'k6';
export const options = {
maxRedirects: 4,
duration: '300s',
vus: 10,
rps: 300
};
// stages : 逐步提升/降低
export const options = {
stages: [
{ target: 200, duration: '30s' },
{ target: 0, duration: '30s' },
],
};
export const options = {
stages: [
{ duration: '10s', target: 100 },
{ duration: '5m', target: 100 },
{ duration: '10s', target: 0 },
],
rps: 100,
};
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页:
[1]