Answer the question
In order to leave comments, you need to log in
Why is http server over net slower than over http?
require('http').createServer((req, res) => {
res.end('hello world');
}).listen(8000);
require("net").createServer((socket) => {
socket.setNoDelay().on("data", (dataBufered) => {
socket.end('HTTP/1.0 200 OK\r\ncontent-length: 11\r\n\r\nhello world');
socket.destroy();
});
}).listen(8000);
autocannon -c 100 localhost:8000
Answer the question
In order to leave comments, you need to log in
Because http keeps connections, and in net you destroy the socket after each request.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question