Stresstest
StressTest
To perform a stresstest use the following instructions:
As reicom user enter the following dir /opt/reitek/nodejs/ctlive/stresstest/
[reicom@tpl-centos7-ctlive ~]$ cd /opt/reitek/nodejs/ctlive/stresstest/
Here you find a predefined scenario (customer.yml).
You can tune it changing the following parameters
config:
target: "http://localhost"
socketio:
path: "/livechat/socket.io"
transports: ["websocket"]
phases:
- duration: 100
arrivalCount: 200
variables:
domain:
- "stresstest"
target is nginx URL
domain the ctlive tenant to use
arrivalCount: the total number of runs
duration: How to distribute test runs. E.g. 200 arrivalCount and duration 100 → run 2 scenarios each seconds for the first 100s and than wait they will complete
Scenario duration
The scenario duration is variable. In the proposed scenario you can change it using the following parameters:
- loop:
#- log: "Send message for cid {{ id }} with id {{ id }}{{ $loopCount }}"
- emit:
channel: "message"
data: { room: "{{ id }}", "domain": "{{domain}}", data: {id: "{{ id }}{{ $loopCount }}", messageType: "TEXT", content: {text: "{{ id }}", user: "myself"}}}
response:
channel: 'messageReceived'
capture:
json: "$"
as: 'messageReceived'
#- log: "Message received: {{ messageReceived }} - cid {{ id }} with id {{ id }}{{ $loopCount }}"
- think: 5
- emit:
channel: "keepAliveContact"
data: { room: "{{ id }}", "domain": "{{domain}}", "data": { "contactLifeTimeInSeconds": 180 } }
acknowledge:
match:
json: '$.0'
value: null
count: 20
#- log: "send end contact"
- emit:
channel: "endContact"
data: { room : "{{ id }}", "domain": "{{domain}}", data : {user: "myself", isFromContactEnded: false}}
acknowledge:
match:
json: "$"
value: "{{ cid }}"
#- log: "Scenario completed"
You can change line 12 and 20 in this way:
Duration is about: count * think → 20 * 5 = 100s
Using a scenario that lasts about 100s, arrivalCount 200 and (test) duration 100s, you will perform a stresstest of 200 concurrent chat sessions.
Test execution
Run the following command
artillery run /opt/reitek/nodejs/ctlive/stresstest/customer.yml
You can verify it counting websocket opened on nginx:
watch "netstat -nap | grep 127.0.0.1:80 | grep EST | grep nginx | wc -l"
The test is successful if the final report is similar to the following:
All virtual users finished
Summary report @ 09:23:00(+0100) 2022-02-08
Scenarios launched: 200
Scenarios completed: 200
Requests completed: 12600
Mean response/sec: 41.77
Response time (msec):
min: 0.5
max: 160
median: 2.5
p95: 18.7
p99: 56.1
Scenario counts:
0: 200 (100%)
Codes:
0: 12600