Davenchy / live-torrent

Torrent Web Client
http://live-torrent.herokuapp.com
MIT License
628 stars 210 forks source link

Download/streaming video in non-blocking way? #55

Closed owen800q closed 4 years ago

owen800q commented 4 years ago

I am new to node, no idea how to optimize the whole performance, I deployed live torrent behind Nginx reverse proxy on Azure VM. it works perfectly for single connection with fast speed. The download speed up to 20 MB/s But once the second download request was established to get the video from the same torrent, it keep waiting until the first download request done. sometime multiple connections could be concurrently streaming but only up to 4 concurrent connections from my testing. Isn't node serve requests in Non-blocking way? why incoming requests are being queued? I am pretty sure the quality of torrent is good. Azure VM specs

OS: ubuntu 18.04 LTS
Memory: 16GB
vcpus:2
bandwidth: upload 1300 mbps, download 1021 mbps
owen800q commented 4 years ago

@Davenchy

owen800q commented 4 years ago

Does webtorrent cache videos on server? I didn't find any related code on live torrent, not sure why docker container eat too much disk space..

 docker system df --verbose
EPOSITORY          TAG                 IMAGE ID            CREATED             SIZE                SHARED SIZE         UNIQUE SIZE         CONTAINERS
live-torrent        latest              fb4ab314a8cd        4 days ago          1.131GB             916.2MB             214.3MB             1
node                12                  0c601cba9f11        6 days ago          916.2MB             916.2MB             0B                  0

Containers space usage:

CONTAINER ID        IMAGE               COMMAND                  LOCAL VOLUMES       SIZE                CREATED             STATUS                    NAMES
68a3211da33f        redis               "docker-entrypoint.s…"   1                   0B                  4 days ago          Exited (0) 21 hours ago   redis
19035a5ee088        live-torrent        "docker-entrypoint.s…"   0                   204.7GB              4 days ago          Up 50 seconds             live-torrent

Local Volumes space usage:

VOLUME NAME                                                        LINKS               SIZE
5520f541e04836aaf50a4deb1e7112b9183bc58670d6c038745289c680a57365   1                   133.3kB
6a31753ec17cffadf9e2cfd140a32f2530924ba44bf977f11e884528aaf65afe   0                   92B
owen800q commented 4 years ago

Right, found it

find / -size +400M -ls
   262175 532660 -rw-r--r--   1 root     root     545439734 Apr 13 05:38 /tmp/webtorrent/607dfef6f88feb60e60f8784fcfb2316f8e6d6d1/[EMTP-Raws&TamersUnion]\343\203\207\343\202\270\343\203\242\343\203\263\343\202\242\343\203\211\343\203\231\343\203\263\343\203\201\343\203\243\343\203\274\357\274\232[01][WEBrip][x264_AAC][CHT_JPN].mp4
   393227 418356 -rw-r--r--   1 root     root     428391182 Apr 13 12:04 /tmp/webtorrent/f59304e2b70aa4af71d1f902726d81371e941b3f/[FYSub][Pocket_Monsters][021][1080P][GB].mp4
   262181 786892 -rw-r--r--   1 root     root     805769472 Apr 13 04:51 /tmp/webtorrent/f95eadd5e81188ca5a6b248e07acd0aeb77cda4f/[Lilith-Raws]\ Hachi-nan\ tte,\ Sore\ wa\ Nai\ deshou!\ -\ 01\ [BiliBili][WEB-DL][1080p][AVC\ AAC][CHT][MKV].mkv
   786436 505864 -rw-r--r--   1 root     root     517997134 Apr 13 12:35 /tmp/webtorrent/784bd23c0d1692b3c6e7b15dd7567596abc112bc/[EMTP-Raws&TamersUnion]\343\203\207\343\202\270\343\203\242\343\203\263\343\202\242\343\203\211\343\203\231\343\203\263\343\203\201\343\203\243\343\203\274\357\274\232[02][WEBrip][x264_AAC][CHS_JPN].mp4
   132657 648376 -rw-r--r--   1 root     root     663932093 Apr 12 13:41 /tmp/webtorrent/feef559220bdb66757ab9d29e2296b49d926d6fd/[XKSub][Digimon\ Adventure\ (2020)][02][CHT_JAP][1080p][WEBRip][MP4].mp4
   393225 418172 -rw-r--r--   1 root     root     428201382 Apr 13 08:13 /tmp/webtorrent/7640f24a323a6555813613b5806585c4426e1687/[FYSub][Pocket_Monsters][021][1080P][BIG5].mp4
  1310757 473296 -rw-r--r--   1 root     root     484647569 Apr 16 13:53 /tmp/webtorrent/8ea6b94aacfa00f395578f128a854c96ca1d6dab/[Airota][Houkago\ Teibou\ Nisshi][02][1080p\ AVC\ AAC][CHT].mp4
  1310744 627832 -rw-r--r--   1 root     root     642892515 Apr 15 16:00 /tmp/webtorrent/96d63a959e326627f372ba3da3512656f477ca86/[Sakurato.Sub]\ Princess\ Connect!\ Re\ Dive\ -\ 02\ (HEVC-10Bit-2160P\ AAC)/[Sakurato.Sub]\ Princess\ Connect!\ Re\ Dive\ -\ 02\ (HEVC-10Bit-2160P\ AAC).mkv
   262185  26768 -rw-r--r--   1 root     root     436092261 Apr 13 05:36 /tmp/webtorrent/fc02f6a7076f87df7dbc2c536ce47b93b6959325/[JYFanSub][Hachi-nan_tte,Sore_wa_Nai_deshou\357\274\201][02][GB][1080p].mp4
  1048579 876648 -rw-r--r--   1 root     root     897679564 Apr 13 14:16 /tmp/webtorrent/939c5a01e8a3d175212a141bc2cdf31a4ed74912/[Lilith-Raws]\ Oshibudo\ -\ 12\ [Baha][WEB-DL][1080p][AVC\ AAC][CHT][MKV].mkv
   786434 505760 -rw-r--r--   1 root     root     517890310 Apr 13 12:28 /tmp/webtorrent/6c1d2ef3a9340e8e40d15dcc4ad9f615f18ad76d/[EMTP-Raws&TamersUnion]\343\203\207\343\202\270\343\203\242\343\203\263\343\202\242\343\203\211\343\203\231\343\203\263\343\203\201\343\203\243\343\203\274\357\274\232[02][WEBrip][x264_AAC][CHT_JPN].mp4
   917508 639448 -rw-r--r--   1 root     root     654787823 Apr 13 13:40 /tmp/webtorrent/fe4afed8814671476b24d0c6900060735616fd4a/[Lilith-Raws]\ Tamayomi\ -\ 01\ [BiliBili][WEB-DL][1080p][AVC\ AAC][CHT][MKV].mkv
   132659 648488 -rw-r--r--   1 root     root     664045694 Apr 12 13:36 /tmp/webtorrent/012faf4395e155bf33f4328a821aca9102abe561/[XKSub][Digimon\ Adventure\ (2020)][02][CHS_JAP][1080p][WEBRip][MP4].mp4
   524308 532416 -rw-r--r--   1 root     root     545189466 Apr 13 13:06 /tmp/webtorrent/5f18044632535fed18327dbe3b16cedbf1eced41/[BeanSub&LoliHouse]\ Nanatsu\ no\ Taizai\ -\ Kamigami\ no\ Gekirin\ [WebRip\ 1080p\ HEVC-10bit\ AAC\ ASSx2]/[BeanSub&LoliHouse]\ Nanatsu\ no\ Taizai\ -\ Kamigami\ no\ Gekirin\ -\ 06\ [WebRip\ 1080p\ HEVC-10bit\ AAC\ ASSx2].mkv
Davenchy commented 4 years ago

OK, I don't have any experience with Azure at all, but yes, live torrent backend runs with clusters support, and yes, node handles requests in non-blocking way but I don't have any idea about what you are facing. I will try on Heroku app and localhost may be I can find something. Thank you for the feedback.