Instantly share code, notes, and snippets.

Embed
What would you like to do?

Crystal vs Node.js Websocket Benchmark

Crystal 0.9.1 with Kemal

require "kemal"

ws "/" do |socket|
  socket.on_message do |message|
  end
end

Node.js v4.2.1 with ws

var WebSocketServer = require('ws').Server
  , wss = new WebSocketServer({ port: 3000 });

wss.on('connection', function connection(ws) {
  ws.on('message', function incoming(message) {
  });

});

Thor is used to run the benchmark.

thor -A 10000 http://localhost:3000

Platform CPU Usage Memory Usage
Crystal (Kemal) 1.85 11.2 MB
Node.js (ws) 38.95 906.3 MB

This benchmark was performed on a 2013 Late Macbook Pro with 2Ghz i7 and 8G ram.

P.S: Less is better

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Apr 18, 2016

Holy shit lol

ghost commented Apr 18, 2016

Holy shit lol

@Nephos

This comment has been minimized.

Show comment
Hide comment
@Nephos

Nephos May 13, 2016

I love this lang ❤️

Nephos commented May 13, 2016

I love this lang ❤️

@nemoDreamer

This comment has been minimized.

Show comment
Hide comment
@nemoDreamer

nemoDreamer commented Jul 14, 2016

!!!

@Nicolab

This comment has been minimized.

Show comment
Hide comment
@Nicolab

Nicolab Aug 28, 2018

The result will be more representative with uws package, ws is slow.

Nicolab commented Aug 28, 2018

The result will be more representative with uws package, ws is slow.

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