bittorrent-tracker icon indicating copy to clipboard operation
bittorrent-tracker copied to clipboard

Use uWebSocket.js encrease I/O productivity few times

Open mrlika opened this issue 5 years ago • 6 comments

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.

mrlika avatar Feb 13 '19 10:02 mrlika

Will be good 👍

Vladislavik avatar Feb 13 '19 10:02 Vladislavik

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

DiegoRBaquero avatar Feb 13 '19 17:02 DiegoRBaquero

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 avatar Feb 13 '19 19:02 mrlika

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.

mrlika avatar Feb 27 '19 09:02 mrlika

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

github-actions[bot] avatar Jul 22 '21 12:07 github-actions[bot]

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?

Bruce-Hopkins avatar Jan 04 '22 07:01 Bruce-Hopkins