YouROK / TorrServer

Torrent stream server
GNU General Public License v3.0
1.34k stars 178 forks source link

[Feature] Implementation of TS API for paid traffic. Clients (TorrServe\Web) use a large amount of traffic from TorrServer while idle. #389

Open filimonic opened 1 month ago

filimonic commented 1 month ago

Is your feature request related to a problem? Please describe. Web UI queries TorrServer for POST /torrents in a second after previous request was completed. TorrServe for Android seems to be acting the same way.

In my case, I have ~500 kb response. It is ~ 30 Mb per minute, or 💥 41 GB 💥 per day! wasted just in idle mode!

Describe the solution you'd like

  1. Add some kind of "paid traffic mode" and light version API when client gets data only if it is updated: 1.1 Send Only necessary info about torrent: do not send any extra data when torrent is "active" like file_stats 1.2 Support ETag or similar way of indicating that response was not changed since previous request 1.3 Make request timeouts larger (30 sec, ex)

  2. Replace requests with notifications over established connection: switch to WebSocket or HTTP LongPolling and send all necessary data only it is needed.

Describe alternatives you've considered No alternatives, just not to forget turn off TV and do not leave WebUI opened.

tsynik commented 1 month ago

Just as described: if you care about traffic much - don't leave web UI opened or don't store torrents on server, they'll be removed after timeout. In most use cases it's LAN traffic between player and local torrserver. 30 MB per minute is nothing against 1080/4K video played at the same time.

filimonic commented 1 month ago

In most use cases it's LAN traffic between player and local torrserver. 30 MB per minute is nothing against 1080/4K video played at the same time.

Totally agree, this is because it's FR, not a bug.

tsynik commented 1 month ago

Also, it's not related to TorrServer directly. You can use any script to communicate with TorrServer or play torrent data. So, it's not a FR for it.

filimonic commented 1 month ago

Also, it's not related to TorrServer directly. You can use any script to communicate with TorrServer or play torrent data. So, it's not a FR for it.

It is related directly, as it requires implementing new API for TS "ecosystem":

cocool97 commented 1 month ago

What about using websockets to prevent client from polling ?

filimonic commented 1 month ago

What about using websockets to prevent client from polling ?

IMO:

  1. Websockets are good, but IDK if they work good without TLS on modern software, maybe there is a limitation?
  2. Not all API should be websocket-ized, only torrent list, and maybe cache updates.
cocool97 commented 1 month ago

AFAIK there is no limitation caused by TLS or not, you can use ws for HTTP or wss for HTTPS.

I truly think that this should just be for these endpoints as client polling can be quite verbose