Skip to content

Instantly share code, notes, and snippets.

@anklos
Last active June 7, 2017 02:01
Show Gist options
  • Save anklos/e37c46cd27a3c52af5fe to your computer and use it in GitHub Desktop.
Save anklos/e37c46cd27a3c52af5fe to your computer and use it in GitHub Desktop.
socket vs http performance

Apache benchmark test:

ab -n 900 -c 80 -p test.data http://localhost:8183/api/accounts/authenticate

HTTP:

Percentage of the requests served within a certain time (ms)
  50%    151
  66%    163
  75%    173
  80%    178
  90%    188
  95%    197
  98%    222
  99%    240
 100%    256 (longest request)

Some requests throw exceptions:

{"message":"socket hang up","name":"Error","stack":"Error: socket hang up\n  at createHangUpError (http.js:1472:15)\n  at Socket.socketOnEnd [as onend] (http.js:1568:23)\n  at Socket.g (events.js:180:16)\n  at Socket.EventEmitter.emit (events.js:117:20)\n  at _stream_readable.js:920:16\n  at process._tickDomainCallback (node.js:459:13)\n","code":"ECONNRESET"},"msg":"socket hang up","time":"2014-07-04T01:10:50.641Z","v":0}

Socket:

Percentage of the requests served within a certain time (ms)
 50%     79
 66%     84
 75%     88
 80%     90
 90%     97
 95%    100
 98%    102
 99%    104
100%    105 (longest request)

All requests served well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment