英文:
Implementing Throughput controller in K6
问题
在Jmeter中,我们可以使用吞吐量控制器来实现不同API应该具有不同吞吐量的功能。在K6中,要实现相同的功能,应该采用什么方法?
英文:
Different API's should work with different throughput. In Jmeter we have the option to implement it by using the throughput controller. What is the method to implement the same in K6.
答案1
得分: 0
你可以使用场景来调用具有不同特性的不同测试函数。执行器定义了函数将以多快的频率执行(例如,以固定速率、固定用户数、可变速率、可变用户数、固定调用次数等)。你可以在单个测试中混合不同类型的执行器。
例如,一个调用2个具有不同速率的端点的测试设置可以如下所示:
export const options = {
scenarios: {
fast: {
exec: 'fast_function',
executor: 'constant-arrival-rate',
duration: '10m',
preAllocatedVUs: 10,
rate: 10 // 10 rps
},
slow: {
exec: 'slow_function',
executor: 'constant-arrival-rate',
duration: '10m',
preAllocatedVUs: 1,
rate: 1 // 1 rps
}
}
};
export function fast_function() {
// 每秒调用10次
http.get('http://example.com');
}
export function slow_function() {
// 每秒调用1次
http.get('http://example.com');
}
英文:
You can use scenarios to call different test functions with different characteristics. Executors define how often a function will be executed (e.g. with a constant rate, a constant number of users, variable rate, variable users, a fixed number of calls, …). You can mix different executor types in a single test.
For example, a test setup which calls 2 endpoints with different rates could look like the following:
export const options = {
scenarios: {
fast: {
exec: 'fast_function',
executor: 'constant-arrival-rate',
duration: '10m',
preAllocatedVUs: 10,
rate: 10 // 10 rps
},
slow: {
exec: 'slow_function',
executor: 'constant-arrival-rate',
duration: '10m',
preAllocatedVUs: 1,
rate: 1 // 1 rps
}
}
};
export function fast_function() {
// will be called 10 times per second
http.get('http://example.com');
}
export function slow_function() {
// will be called once per second
http.get('http://example.com');
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论