webtorrent / bittorrent-tracker

🌊 Simple, robust, BitTorrent tracker (client & server) implementation
https://webtorrent.io
MIT License
1.75k stars 317 forks source link

Use uWebSocket.js encrease I/O productivity few times #310

Open mrlika opened 5 years ago

mrlika commented 5 years ago

P2P technologies should be scalable and efficient when it goes to high loads.

The goal is to rewrite the code to be able to use uWebSockets.js HTTP/HTTPS/WebSocket server as an option for HTTP I/O. At least to refactor the code to use the maximum of the logic from this project in a new tracker project that will be based on uWebSockets.js I/O.

This article and this one describe how uWebSockets.js is a few times more efficient in I/O than any other Node.js solutions and even C/C++/Golang solutions. Also, it will lead to the use of the built-in uWebSockets.js HTTPS support and remove the need for Nginx in front of the tracker.

The performance of µWebSockets is in most cases what you would expect from an efficient server software. In some cases, especially small messages, the difference in performance can be dramatical (10 - 15x). Because of the nature of WebSocket messages (they are mostly very small at sub 1kb), this plays a major role in performance.

The benefit is that public and private trackers will be able to serve a few times more peers.

It will help to solve #308, #299, #269 (uWebTorrent tracker is written using uws and uWebSockets.js is the successor of it written by the same author) and other related issues.

Vladislavik commented 5 years ago

Will be good 👍

DiegoRBaquero commented 5 years ago

It's good to have it back, didn't know it was already publicly released with binaries, had checked 2 weeks back. Will implemented in uwt soon. Or if @feross agrees, just merge all back into this module using uWebSockets

mrlika commented 5 years ago

Great! @DiegoRBaquero please keep in mind HTTPS support. Using Nginx as HTTPS proxy in front of the tracker may dramatically decrease I/O productivity.

mrlika commented 5 years ago

We decided to create our own open source high-performance implementation of WebTorrent tracker using uWebSockets.js: https://github.com/Novage/wt-tracker

It can handle 100k peers (no SSL) using 1.2Gb of memory and 50% of a single CPU core.

github-actions[bot] commented 3 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

Bruce-Hopkins commented 2 years ago

Is this relevant? If so, can implement this enhancement?

I'm not sure if uWebSockets.js has compatibility with all systems. Should we implement this as an additional option for ws or a replacement?