Both use the standard library, compiled to a unix executable & ran on a $5 VPS (1 cpu core, 1gb ram) using pm2 for the delivery & wrk to test. Completely unscientific, but there you go. Could probably be faster, Kemal might make it faster?
Simply delivers ‘Hello World’ in the test.
I have found pm2 works well with Crystal I have not tried ‘cluster mode’, which I believe is Node specific.
Port 3000 is Crystal, Port 8000 is Deno.
TLDR: Crystal is about 4x faster for a very basic unscientific test & uses about 8mb ram vs 50mb-80mb ram for Deno.
require "http"
require "http/server"
require "json"
server = HTTP::Server.new do |context|
method = context.request.method
path = context.request.path
if path == "/"
context.response << "
<html><body><h1>Hello world</h1><p>This is a html reply</p></body></html>
"
end
if path == "/json"
context.response << "Hello World".to_json
end
end
The code for the below test. I only ran Crystal in this test.
If you wrote this with HTTP::Server, Kemal won’t be faster. It is also implemented in terms of HTTP::Server. The performance difference is pretty impressive, though[1], considering Deno’s HTTP server (which is presumably most of the code in the Deno benchmark) is written in Rust.
[1] I’d caution against posting benchmarks with concurrency settings that high in wrk making requests to localhost. It goes beyond simply “unscientific” and diminishes the impact of the point you’re trying to make. The default -c10 is usually enough and your benchmarks show the steeply diminishing returns you’ll get when you exceed a reasonable concurrency for the workload.
I did a Kemal test it’s in the very first post, it was just faster than the Deno server. This thread is a bit of a mess, I was just sorta popping whatever came out into a comment
I think Deno is actually slower than Node right now (from what I have seen), uses more memory too, but I believe the Deno focus is more on short lived serverless functions and quick boot times.
Really useless test, I would want to test one server flooding another server that had the HTTP servers, if that is possible.