Skip to content

Commit 76c4453

Browse files
committed
script updates
1 parent 26a89f1 commit 76c4453

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

load-test/scripts/configuration.js

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ export const PRIVATE_KEY = null;
2323
// Long requests time: we don't want requests to go over this time in the p(95) case
2424
export const LONG_REQUEST_MS = 5000;
2525
// Extra long request time: we never want requests to go over this time.
26-
export const EXTRA_LONG_REQUEST_MS = 14000;
26+
export const EXTRA_LONG_REQUEST_MS = 10000;
27+
// Timeout if we go greater than the max request time to ensure we stay
28+
// close to our concurrent user goal.
29+
export const MAX_REQUEST_TIME_MS = 20000;
2730

2831
// Mini-app types
2932
export const MiniAppType = {
@@ -32,28 +35,28 @@ export const MiniAppType = {
3235
THEATER: 'theater'
3336
};
3437

35-
export function getTestOptions(maxUserGoal, rampUpTimeMinutes, highLoadTimeMinutes) {
38+
export function getTestOptions(maxUserGoal, highLoadTimeMinutes) {
3639
const maxConcurrentUsers = Math.floor(maxUserGoal / 30);
3740
return {
3841
scenarios: {
39-
// ramp up to maxConcurrentUsers VUs over rampUpTimeMinutes
40-
rampUp: {
41-
executor: "ramping-vus",
42-
startVUs: 0,
43-
stages: [
44-
{duration: `${rampUpTimeMinutes}m`, target: maxConcurrentUsers}
45-
]
42+
halfConcurrency: {
43+
executor: "constant-vus",
44+
vus: Math.ceil(maxConcurrentUsers / 2),
45+
duration: '1m',
4646
},
47-
// have maxConcurrentUsers VUs do 3 iterations each minute, for a total of highLoadTimeMinutes * 3
48-
// iterations per virutal user.
49-
// Start this after the ramp up time.
47+
initialHighConcurrency: {
48+
executor: "constant-vus",
49+
vus: maxConcurrentUsers,
50+
duration: '1m',
51+
startTime: '1m'
52+
},
53+
// maintain maxConcurrentUsers VUs for highLoadTimeMinutes minutes. Start this after first two
54+
// scenarios have completed.
5055
highLoad: {
51-
executor: "per-vu-iterations",
56+
executor: "constant-vus",
5257
vus: maxConcurrentUsers,
53-
iterations: 3 * highLoadTimeMinutes, // this is iterations per virtual user
54-
// add a large buffer to max duration to ensure all requests can complete.
55-
maxDuration: `${highLoadTimeMinutes + (Math.ceil(highLoadTimeMinutes * 0.5))}m`,
56-
startTime: `${rampUpTimeMinutes}m`,
58+
duration: `${highLoadTimeMinutes}m`,
59+
startTime: '2m',
5760
}
5861
},
5962
thresholds: {

load-test/scripts/loadTest.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { getRandomId, generateToken } from "./tokenHelpers.js";
77
import {
88
LONG_REQUEST_MS,
99
EXTRA_LONG_REQUEST_MS,
10+
MAX_REQUEST_TIME_MS,
1011
MiniAppType,
1112
UPLOAD_URL,
1213
UPLOAD_PARAMS,
@@ -18,15 +19,11 @@ import {
1819
// Change these options to increase the user goal or time to run the test.
1920
export const options = getTestOptions(
2021
/* User goal */ 1000,
21-
/* Ramp up time minutes */ 5,
2222
/* High load time minutes */ 10
2323
);
2424

2525
// Change this to test different code
2626
const sourceToTest = helloWorld;
27-
// Timeout is we go greater than the max request time to ensure we stay
28-
// close to our concurrent user goal.
29-
const MAX_REQUEST_TIME_MS = 20000;
3027

3128
const exceptionCounter = new Counter("exceptions");
3229
const errorCounter = new Counter("errors");
@@ -99,6 +96,8 @@ function onSocketConnect(socket, requestStartTime, websocketStartTime, sessionId
9996
timeoutCounter.add(1);
10097
}
10198

99+
// Sleep this VU if we are under the max request time. This is so we maintain
100+
// a reasonable number of total requests across all virtual users.
102101
const sleepTime = Math.floor((MAX_REQUEST_TIME_MS - totalTime) / 1000);
103102
if (sleepTime > 0) {
104103
sleep(sleepTime);

0 commit comments

Comments
 (0)