vitejs / vite

Next generation frontend tooling. It's fast!
http://vite.dev
MIT License
68.54k stars 6.19k forks source link

Explore uWebSockets as a ws alternative #16579

Open privatenumber opened 6 months ago

privatenumber commented 6 months ago

Description

I learned about https://github.com/uNetworking/uWebSockets.js which is a faster alternative to ws.

Bun uses a fork of it for WebSockets, and based on these HTTP server benchmarks, uWebSockets.js via Node is actually faster than bun.

More benchmarks: https://github.com/uNetworking/uWebSockets/discussions/1415

I'm not sure how much of a bottleneck ws is, but it may be worth exploring.

Suggested solution

Explore adopting uWebSockets.js

Alternative

No response

Additional context

No response

Validations

rtritto commented 3 weeks ago

Other benchmarks:

Reference to Vite v6 discussion: https://github.com/vitejs/vite/discussions/15886#discussioncomment-11010384

sapphi-red commented 3 weeks ago

I checked uWebSockets.js and I think it has the following problems to be used in Vite:

Even if these problems were solved, it has a big package size even for a single platform (5MB; ws is 143kB), so it would need to improve the perf significantly to make it worth.

rtritto commented 3 weeks ago

Thanks for the checks, I opened https://github.com/uNetworking/uWebSockets.js/discussions/1120

Second point can be (partially) achieved with https://github.com/uNetworking/uWebSockets.js/issues/1112