Skip to content

Instantly share code, notes, and snippets.

@billywhizz
Created February 22, 2017 23:45
Show Gist options
  • Save billywhizz/a2343e02e2e3475ecf6ecb0af4c8a719 to your computer and use it in GitHub Desktop.
Save billywhizz/a2343e02e2e3475ecf6ecb0af4c8a719 to your computer and use it in GitHub Desktop.
uWebSockets Techempower Benchmark

install

npm install

run node.js server

node app

run uws server

node app --uws

run standard plaintext benchmark

wrk -c 100 -t 2 http://127.0.0.1:8080/plaintext

run insane http pipeline plaintext benchmark

wrk -c 100 -t 2 -s ./plaintext.lua http://127.0.0.1:8001/plaintext

run standard json benchmark

wrk -c 100 -t 2 http://127.0.0.1:8080/json

run insane http pipeline json benchmark

wrk -c 100 -t 2 -s ./json.lua http://127.0.0.1:8001/json

results

environment

  • Intel(R) Core(TM) i7-6560U CPU @ 2.20GHz
  • 4.4.0-47-generic, x86-64, Ubuntu 14.04
  • node.js v6.9.1

results in krps

plaintext json
standard uws 196 125
standard node.js 24 22
pipeline uws 870 365
pipeline node.js 49 43
const http = process.argv[2]==="--uws"?require("uws").http:require("http")
const hello = 'Hello world!'
const helloBuffer = Buffer.from(hello)
const notFound = "Not Found"
const plainText = "/plaintext"
const json = "/json"
const contentType = "Content-Type"
const contentTypes = {
text: "text/plain; charset=UTF-8",
json: "application/json"
}
function onRequest(req, res) {
if(req.url === plainText) {
res.setHeader(contentType, contentTypes.text);
res.end(helloBuffer)
}
else if(req.url === json) {
res.setHeader(contentType, contentTypes.json);
res.end(Buffer.from(JSON.stringify({ message: hello })))
}
else {
res.statusCode = 404
res.end(notFound)
}
}
http.createServer(onRequest).listen(8080)
init = function(args)
depth = 24
local r = {}
for i=1,depth do
r[i] = wrk.format(nil, "/json")
end
req = table.concat(r)
end
request = function()
return req
end
{
"name": "uws-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"uws": "0.13.0"
}
}
init = function(args)
depth = 24
local r = {}
for i=1,depth do
r[i] = wrk.format(nil, "/plaintext")
end
req = table.concat(r)
end
request = function()
return req
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment