Skip to content

Commit 2374135

Browse files
committed
minor updates
1 parent be291bd commit 2374135

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

cicd/3-app/load-test.template.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ Resources:
3737
awslogs-group: !Ref CloudwatchLogsGroup
3838
awslogs-region: !Ref AWS::Region
3939
awslogs-stream-prefix: !Sub "${AWS::StackName}-task"
40+
Ulimits:
41+
- HardLimit: 4096
42+
Name: nofile
43+
SoftLimit: 4096
4044
Cpu: 2048
4145
ExecutionRoleArn: !Ref ExecutionRole
4246
Memory: 4096

load-test/scripts/configuration.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const MiniAppType = {
3333
};
3434

3535
export function getTestOptions(maxUserGoal, highLoadTimeMinutes) {
36-
const maxConcurrentUsers = Math.floor(maxUserGoal / 30);
36+
const maxConcurrentUsers = Math.ceil(maxUserGoal / 30);
3737
return {
3838
scenarios: {
3939
halfConcurrency: {

load-test/scripts/loadTest.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ export const options = getTestOptions(
2323

2424
// Change this to test different code
2525
const sourceToTest = helloWorld;
26+
// Set this to true to space out requests every REQUEST_TIME_MS milliseconds. Set to
27+
// false to send as many requests as possible.
28+
const SHOULD_SLEEP = true;
2629

2730
const exceptionCounter = new Counter("exceptions");
2831
const errorCounter = new Counter("errors");
@@ -50,10 +53,14 @@ export default function () {
5053
check(uploadResult, { "upload status is 200": (r) => isResultSuccess(r)});
5154

5255
if (isResultSuccess(uploadResult)) {
53-
const res = ws.connect(WEBSOCKET_URL + authToken, WEBSOCKET_PARAMS, (socket) =>
54-
onSocketConnect(socket, requestStartTime, Date.now(), sessionId)
55-
);
56-
56+
let res = null;
57+
try {
58+
res = ws.connect(WEBSOCKET_URL + authToken, WEBSOCKET_PARAMS, (socket) =>
59+
onSocketConnect(socket, requestStartTime, Date.now(), sessionId)
60+
);
61+
} catch(error) {
62+
console.log(`ERROR ${error} for session id ${sessionId}`);
63+
}
5764
check(res, { "websocket status is 101": (r) => r && r.status === 101 });
5865
} else {
5966
console.log(`ERROR upload failed for session id ${sessionId}`);
@@ -99,9 +106,11 @@ function onSocketConnect(socket, requestStartTime, websocketStartTime, sessionId
99106

100107
// Sleep this VU if we are under the max request time. This is so we maintain
101108
// a reasonable number of total requests across all virtual users.
102-
const sleepTime = Math.floor((REQUEST_TIME_MS - totalTime) / 1000);
103-
if (sleepTime > 0) {
104-
sleep(sleepTime);
109+
if (SHOULD_SLEEP) {
110+
const sleepTime = Math.floor((REQUEST_TIME_MS - totalTime) / 1000);
111+
if (sleepTime > 0) {
112+
sleep(sleepTime);
113+
}
105114
}
106115
});
107116

0 commit comments

Comments
 (0)