uNetworking / uWebSockets.js

μWebSockets for Node.js back-ends :metal:
Apache License 2.0
7.65k stars 560 forks source link

uWebsockets.js server much slower if host wasn't passed to listen #1054

Closed doxlik closed 2 months ago

doxlik commented 2 months ago

Hello dear authors and community. I did some benchmarks last days against uWebsockets server for simple "Hello, World!" example on my MacBook M1 Pro (16GB) using both wrk and bombardier load testing tools. And it may sounds strange, but after dozens of attempts I constantly get much lower throughput when I just use server.lisnen(port, callback) instead of server.listen("0.0.0.0", port, callback). In terms of magnitude that is ~120K/s without passing host and ~180-200K/s for explicit host parameter passing. I also noticed this effect in Bun (built on top of uWebsockets), that passing hostname explicitly make throughput much higher. Is it something related to MacOS or what? I will be grateful for your explanation. P.S the version of uWebsockets is 20.43.0.

uNetworkingAB commented 2 months ago

0.0.0.0 is an IPv4 address. So without it you most likely listen over IPv6 which could be slower in your case (for whatever reason)