I've cloned uWebSockets, wrote the following file.
#include <App.h>
#include <iostream>
int main() {
uWS::App()
.get("/*", [](auto *res, auto *req) {
res->end("Hello world!");
})
.listen(3000, [](auto *token) {
if (token) {
std::cout << "Listening on port " << 3000 << std::endl;
}
})
.run();
std::cout << "Failed to listen on port 3000" << std::endl;
return 0;
}
Built it with
make -C uWebSockets/uSockets
g++ -flto -O3 -Wconversion -std=c++17 -IuWebSockets/src -IuWebSockets/uSockets/src main.cpp -o main uWebSockets/uSockets/*.o -lz -lssl -lcrypto -luv
When I do a benchmark, this is what I get.
Concurrency Level: 100
Time taken for tests: 116.928 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 68000 bytes
HTML transferred: 12000 bytes
Requests per second: 8.55 [#/sec] (mean)
Time per request: 11692.844 [ms] (mean)
Time per request: 116.928 [ms] (mean, across all concurrent requests)
Transfer rate: 0.57 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 3 2.6 2 10
Processing: 8923 11690 921.2 11995 12012
Waiting: 0 1 1.3 0 10
Total: 8923 11693 921.7 11999 12012
Percentage of the requests served within a certain time (ms)
50% 11999
66% 12001
75% 12002
80% 12003
90% 12006
95% 12008
98% 12010
99% 12011
100% 12012 (longest request)
If I set concurrency to 1, this happens
Concurrency Level: 1
Time taken for tests: 61.655 seconds
Complete requests: 5
Failed requests: 0
Total transferred: 408 bytes
HTML transferred: 72 bytes
Requests per second: 0.08 [#/sec] (mean)
Time per request: 12330.911 [ms] (mean)
Time per request: 12330.911 [ms] (mean, across all concurrent requests)
Transfer rate: 0.01 [Kbytes/sec] received
Did I do something wrong? Did I miss something? Shouldn't it be faster?
PS. I'm running it on single thread.
I was using apache benchmark tool(
ab
) and it was slow, not the program. Used bomberdier and got this result