I have a small app that sends Server Sent Events. I would like to load test my app so I can benchmark the latency from the time a message is pushed to the time the message is received so I can know when/where the performance breaks down. What tools are available to be able to do this?
2 Answers
Since Server-Sent Events
it is just HTTP you can use siege
utility. Here is the example:
siege -b -t 1m -c45 http://127.0.0.1:9292/streaming
Where:
-b
benchmark mode i.e. don't wait between connections-t 1m
benchmark for 1 minute-c45
number of concurrent connectionshttp://127.0.0.1:9292
my dev server host and custom port/streaming
HTTP-endpoint which respond withContent-Type: text/event-stream
Output:
Lifting the server siege... done.
Transactions: 79 hits
Availability: 100.00 %
Elapsed time: 59.87 secs
Data transferred: 0.01 MB
Response time: 23.43 secs
Transaction rate: 1.32 trans/sec
Throughput: 0.00 MB/sec
Concurrency: 30.91
Successful transactions: 79
Failed transactions: 0
Longest transaction: 30.12
Shortest transaction: 10.04
-
i'm trying to use siege Server-Sent Events and when i run this command "siege -c2 -d10 -t30s streaming_end_point" i get the following, fundamentally everything returns 0 but actually the connections are made successfully, any idea?– SaiOct 15, 2016 at 2:16
-
Lifting the server siege... Transactions: 0 hits Availability: 0.00 % Elapsed time: 29.61 secs Data transferred: 0.00 MB Response time: 0.00 secs Transaction rate: 0.00 trans/sec Throughput: 0.00 MB/sec Concurrency: 0.00 Successful transactions: 0 Failed transactions: 0 Longest transaction: 0.00 Shortest transaction: 0.00
– SaiOct 15, 2016 at 2:16 -
@Sai that is rather odd, could you please post development server log? Also passing
--verbose
option tosiege
could provide some info. Oct 15, 2016 at 14:26 -
thank you for responding, i really appreciate it. I tried running the siege with --verbose but wasn't able to get any information on why it returns everything as 0. I verified the DEV logs and i was able to see the streaming end point being executed the number of times mentioned in the -c value, each request will be associated with a UUID and i was able to see the UUID in the logs but not getting any data back from siege. The siege version i use is SIEGE 4.0.2.– SaiOct 16, 2016 at 2:37
-
I have created a question stackoverflow.com/questions/40048289/… with little more details about the service and SSE. I was also analyzing the GATLING tool to perform load test for SSE and found a bit info here gatling.io/docs/2.2.2/http/sse.html. On the other hand when i use siege against a normal req/res then it works like a charm but for this particular streaming end point it does not return any value.– SaiOct 16, 2016 at 2:39
I took a simple path of creating a shell script that initiates N background jobs of cURL which connected to the SSE endpoint of my service. To get the exact cURL syntax, open your Chrome web dev tools -> Network tab -> right click on the entry of the request to the SSE endpoint and choose from the context menu "Copy as cURL"
Then you paste that command in a shell script that roughly looks like:
#!/bin/bash
i=0;
while [ $i -lt 50 ] ;do
[PASTE YOUR cURL COMMAND HERE] -s -o /dev/null &
i=`expr $i + 1`;
done
This will add 50 background cURL jobs each time it's run. Notice that I added to Chrome's cURL command the params -s -o /dev/null
. This is to run cURL in silent mode and to suppress any output.
In my case the service was implemented in NodeJs, so I used process.hrtime()
for high precision timing to measure the delay of looping through the N connected clients to broadcast the data.
The results were ok: it served 1000+ active connections in ~0.02sec
Keep in mind that if you run server + cURL clients from the same machine, you'll probably hit OS limits of open files
. To see open file
limits on your linux box (common case is 1024) run:
$ ulimit -n
To avoid reaching the 1000+ active cURLs I got, you can:
- start them from multiple machines
- or increase this limit (see sysctl)
The problem I faced was that eventually node crushed with an ELIFECYCLE error and the log was not very helpful in diagnosing the problem. Any suggestions are welcome.