Skip to content

Instantly share code, notes, and snippets.

@sdogruyol
Last active June 25, 2022 15:32
Show Gist options
  • Select an option

  • Save sdogruyol/bdd400a6eac13e26228e to your computer and use it in GitHub Desktop.

Select an option

Save sdogruyol/bdd400a6eac13e26228e to your computer and use it in GitHub Desktop.

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 commented Apr 18, 2016

Copy link
Copy Markdown

Holy shit lol

@Nephos

Nephos commented May 13, 2016

Copy link
Copy Markdown

I love this lang ❤️

@nemoDreamer

Copy link
Copy Markdown

!!!

@Nicolab

Nicolab commented Aug 28, 2018

Copy link
Copy Markdown

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

@proyb6

proyb6 commented Jan 25, 2019

Copy link
Copy Markdown

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

Sadly the uws author deprecated his repo for some reason.
https://www.reddit.com/r/node/comments/91kgte/uws_has_been_deprecated/

ClusterWS is quite new.

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