A 12x performance boost to Node.js.

Irecently hooked up my Raspberry Pi 4 to my TV and because I hadn’t benchmarked something in a while I decided to see if I could serve 100k HTTP req/sec from this little thing, over an actual Ethernet cable.

I began by installing Ubuntu Server 20.10 for ARM64 via the Raspberry Pi Imager tool.

Then I simply ran the HelloWorldThreaded executable and started htop.

If you don’t know about  µWebSockets, this is roughly how it looks like, minimal snippet:

uWS::App().get("/*", [](auto *res, auto *req) {
    res->end("Hello world!");
}).listen(3000, [](auto *listen_socket) {
    if (listen_socket) {
        std::cout << "Listening on port " << 3000 << std::endl;
    }
}).run();

Above test will establish 200 connections making non-pipelined HTTP requests as fast as the server will allow. This got me to 93k req/sec at 400% CPU-time usage (all 4 CPUs on the Pi). So I figured — with my elite cooling solution I ought to manage a slight overclock from the default 1.5Ghz to 1.7Ghz.

#nodejs #fastify

Serving 100k Requests/second From A Fanless Raspberry Pi 4 Over Ethernet
1.55 GEEK