alexfernandez / loadtest

Runs a load test on the selected URL. Fast and easy to use. Can be integrated in your own workflow using the API.
MIT License
2.58k stars 210 forks source link

Command-line hanging / not exiting on completion #229

Open hoeken opened 12 months ago

hoeken commented 12 months ago

I'm using loadtest to test the performance of my websocket server on an embedded device (which is why the #s are so low)

I have a script that tests at different levels of concurrent users, from 1 to 20. Everything works great from 1 to 7, but as soon as I test with a concurrency of 8 the program doesn't exit. It seems this is true for any concurrency # above 7. I am setting --cores to 1 since I want to control exactly how many connections I have to the device.

If I remove the --cores 1 option, then it works fine, although then I have to do some math to get the exact # of connections.

The weird thing is that the script completes and prints statistics, but then it simply doesn't exit as if its waiting for something else to complete.

Also, every time it starts up, it lists a bunch of potential memory leak errors which you can see below:

loadtest -c 8 --cores 1 -t 10 ws://192.168.2.131/ws
(node:34199) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added to [WebSocketConnection]. Use emitter.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)
(node:34199) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [WebSocketConnection]. Use emitter.setMaxListeners() to increase limit
(node:34199) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added to [WebSocketConnection]. Use emitter.setMaxListeners() to increase limit
(node:34199) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added to [WebSocketConnection]. Use emitter.setMaxListeners() to increase limit
(node:34199) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [WebSocketConnection]. Use emitter.setMaxListeners() to increase limit
(node:34199) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added to [WebSocketConnection]. Use emitter.setMaxListeners() to increase limit
(node:34199) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added to [WebSocketConnection]. Use emitter.setMaxListeners() to increase limit
(node:34199) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [WebSocketConnection]. Use emitter.setMaxListeners() to increase limit
(node:34199) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added to [WebSocketConnection]. Use emitter.setMaxListeners() to increase limit
(node:34199) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added to [WebSocketConnection]. Use emitter.setMaxListeners() to increase limit
(node:34199) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [WebSocketConnection]. Use emitter.setMaxListeners() to increase limit
(node:34199) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added to [WebSocketConnection]. Use emitter.setMaxListeners() to increase limit
(node:34199) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added to [WebSocketConnection]. Use emitter.setMaxListeners() to increase limit
(node:34199) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [WebSocketConnection]. Use emitter.setMaxListeners() to increase limit
(node:34199) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added to [WebSocketConnection]. Use emitter.setMaxListeners() to increase limit
(node:34199) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added to [WebSocketConnection]. Use emitter.setMaxListeners() to increase limit
(node:34199) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [WebSocketConnection]. Use emitter.setMaxListeners() to increase limit
(node:34199) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added to [WebSocketConnection]. Use emitter.setMaxListeners() to increase limit
(node:34199) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added to [WebSocketConnection]. Use emitter.setMaxListeners() to increase limit
(node:34199) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [WebSocketConnection]. Use emitter.setMaxListeners() to increase limit
(node:34199) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added to [WebSocketConnection]. Use emitter.setMaxListeners() to increase limit
Requests: 521, requests per second: 104, mean latency: 64.8 ms

Target URL:          ws://192.168.2.131/ws
Max time (s):        10
Concurrent clients:  8
Agent:               none

Completed requests:  1066
Total errors:        0
Total time:          10.006 s
Mean latency:        64.2 ms
Effective rps:       107

Percentage of requests served within a certain time
  50%      57 ms
  90%      103 ms
  95%      114 ms
  99%      132 ms
 100%      146 ms (longest request)

I am running on Mac with this software installed:

% npm -v             
10.2.0
% node -v            
v21.1.0
% loadtest --version 
Loadtest version: 8.0.5
alexfernandez commented 11 months ago

Sorry for the delay. I have seen this behavior also for non-websocket tests, not sure what is causing the memory leak?

alexfernandez commented 11 months ago

Hi again! After some investigation, there is a definite memory leak for websockets. Support was added by another developer but the package has evolved a lot and I'm afraid it is not up to par at the moment. I don't have the knowledge or the time to fix it; if you want to work on it you are most definitely welcome!

hoeken commented 11 months ago

I might give it a look at some point. Its definitely meeting my needs for now right now though with wss support working.