Efficient Streaming and Chat through HTTP and WebSockets - Devtooling Twitch

  Рет қаралды 29,329

Hussein Nasser

Hussein Nasser

Күн бұрын

Пікірлер: 75
@hnasr
@hnasr 3 жыл бұрын
Learn the fundamentals of the backend, scaling and load balancing with my Introduction to NGINX udemy course Grab a discount coupon here nginx.husseinnasser.com
@olddepressedgamer
@olddepressedgamer 2 жыл бұрын
Bit late to the video (missed it the first time for some reason). Just wanted to say that the .ts request is for a transport stream (something I think you might find interesting). These are the most common method of delivering video + stuff. The ts is more than a video file, it could also contain subtitles, program data (ie program guide on TV), encrytpion data (Conditional Access stuff that works with your viewing card on satellite to enable you to watch pay per view/subscription channels) etc . It is basically a packet system very much like network packets. You can see the structure on the MPEG poster (search for 'MPEG2 transport stream diagram' on google and click the first link, or third for the Tektronix one as they created it, for a PDF of the packet structure. You used to be able to get the poster for free at one point and it was all over the place when I worked in satellite software (they didn't even charge postage :D). It would be interesting to what twitch's one contains.
@ab-oc5ho
@ab-oc5ho 3 жыл бұрын
Twitch is the best open source project!
@dev_among_men
@dev_among_men 3 жыл бұрын
If you know you know
@subhasishmandal2023
@subhasishmandal2023 3 жыл бұрын
LOL
@nikolas8741
@nikolas8741 3 жыл бұрын
Agree
@prenomnom5637
@prenomnom5637 3 жыл бұрын
lol
@nikolas8741
@nikolas8741 3 жыл бұрын
I've download the full 129GB or so. But idk anything about web apps😅 I guess I'm gonna keep it here on my 1tb ssd drive
@syz3981
@syz3981 3 жыл бұрын
I would be sick if you went through twitch's leaked codebase
@Kid420
@Kid420 3 жыл бұрын
Pretty sure he wouldn't risk it xD
@unitedmarcus8731
@unitedmarcus8731 3 жыл бұрын
why what's wrong? (genuine q)
@manuyel4845
@manuyel4845 3 жыл бұрын
@@unitedmarcus8731 copyrighted code you know, not sure how well youtube will see it.
@q1joe
@q1joe 3 жыл бұрын
@@unitedmarcus8731 Technically possessing it is a grey area... might be kind of Illegal... its definitely got a copyright on it and could be taken down.
@AKASH-sw9bs
@AKASH-sw9bs Жыл бұрын
At the very first of my career of backend engineer i didn’t find any interest in your contents,but as with my growth of career your chanel seems to be as a "GOLD MINE" 🖤. Thanks for your beautiful contribution to the community. Hearties respect.
@ZeeshanAli-nk3xk
@ZeeshanAli-nk3xk Жыл бұрын
This is GOLD! jazakAllah u khair ya Ustadh!
@4nkitpatel
@4nkitpatel 3 жыл бұрын
Dev tooling is one of the best thing in this channel keep doing it we are enjoying so so so so much and learning as well thank you for this 🙏
@Stoney_Eagle
@Stoney_Eagle 3 жыл бұрын
The wasm connects to their stream server. The stream server tells the script to fetch file x, the browser fetches it and then HLS stitches it onto the video.
@hnasr
@hnasr 3 жыл бұрын
Dev Tool them ALL! Playlist kzbin.info/aero/PLQnljOFTspQX9U79P6eD_V9USIUTE9yAD
@viveksai9353
@viveksai9353 3 жыл бұрын
Such raw and grassroot level content is rare on youtube. Thank you.
@VivekYadav-ds8oz
@VivekYadav-ds8oz 3 жыл бұрын
There seems to be a lot of protocol overhead. For CORS, TCP -> SSL -> close. For each 2 second clip, TCP -> SSL -> download -> close.
@rab_x6958
@rab_x6958 2 жыл бұрын
hello Hussein Nasser, I'm a new viewer of your channel , Back-end crazyed person I'm getting a big fan of you. the away you teardown every little thing is impressive, solve all the hidden things under the hood. You just draw the conclusion to-the point. Thank you Man,
@hnasr
@hnasr 2 жыл бұрын
appreciate you, glad you enjoy the content dear
@unitedmarcus8731
@unitedmarcus8731 3 жыл бұрын
my favourite series: devtool them all !
@gamer-gw9iy
@gamer-gw9iy 3 жыл бұрын
Have you seen the twitch source code yet? There was a leak recently
@snehasishroy39
@snehasishroy39 2 жыл бұрын
Thank you for this awesome series. Loving the deep dive.
@SaadHassan43
@SaadHassan43 3 жыл бұрын
Can you do the same Devtool analysis of the Netflix platform?
@mohammadsalehdehghanpour9856
@mohammadsalehdehghanpour9856 3 жыл бұрын
I think as the wasm web worker sits in the browser, the protocol we see in devtools is the one between our machine and server (which is http 1.1 for streams). Anyway a packet capture will prove whether this is correct
@barnabuswizardspook
@barnabuswizardspook 2 жыл бұрын
Really high-quality stuff
@anarelle
@anarelle Жыл бұрын
I was just watching some live streaming on Facebook and it had multiple glitches, not just skipped frames but even music getting faster and then slowed down. I understand maybe the person who was streaming had a poor connection, but I was surprised Facebook doesn't have anything in place to prevent this and make live videos run smoothly, since other platforms seem to handle it much better. So it kept me wondering what exactly could be done from the technical point of view? Are there any known "techniques" that can be applied to avoid these glitches in live video? Thanks for the amazing content!!
@VivekYadav-ds8oz
@VivekYadav-ds8oz 3 жыл бұрын
Atleast on Firefox, you can allow CORS if the main domain is the same.
@antonyinjila7152
@antonyinjila7152 3 жыл бұрын
always a blessing Hussein
@thetechnoob12
@thetechnoob12 3 жыл бұрын
ok if I understand correctly when someone streams on the backend twitch divides the steam to a two second video. Then it created a list of urls that contains the 2 second videos and sends the lists to the client and the client fetch each url.
@abdulazizs2931
@abdulazizs2931 Жыл бұрын
This is the HLS protocol for playing live streaming on Apple products. Twitch is following their standard. With HLS the parent manifest is divided into sub manifests which contain chunks corresponding to certain video stream properties like resolution/bit rate/etc. For Android devices(DASH) the video chunks for 4 seconds long which has the manifest file in a totally different format.
@obaid5761
@obaid5761 3 жыл бұрын
Ayy I'm first. Keep up the good work brother :)
@raiyansarker3809
@raiyansarker3809 2 жыл бұрын
Do Google once! And please make more of these videos!!!!
@stanislavpetkov7408
@stanislavpetkov7408 3 жыл бұрын
TS is Mpeg transport stream. Same type of data that goes over satelite, terestrial, hls and etc…
@shuluspa
@shuluspa 2 жыл бұрын
Were you using Russian VPN? Because your recommended channels on Twitch were primarily Russian :D
@kailashyogeshwar8492
@kailashyogeshwar8492 3 жыл бұрын
Would like to see you digging gmail network request someday 👏
@weathercontrol0
@weathercontrol0 3 жыл бұрын
Are you going to make a video going through their backend?
@kushalkamra3803
@kushalkamra3803 Жыл бұрын
Thank you 🙏
@hiruthicsha
@hiruthicsha 3 жыл бұрын
Thanks!
@hichamlotfi4277
@hichamlotfi4277 3 жыл бұрын
great video please keep doing this type of videos
@rishiagrawal812
@rishiagrawal812 3 жыл бұрын
Hi sir, can you please make a tutorial on how file uploading works? when we make a connection to server to upload file , how it gets large file data to the server
@hnasr
@hnasr 3 жыл бұрын
kzbin.info/www/bejne/f6mQlGWObMmfodU
@rishiagrawal812
@rishiagrawal812 3 жыл бұрын
@@hnasr Thanks for pointing out the video. Sir, can you give some idea: When we select image/video on the web page. What exactly happens is complete file transferred/copy to browser memory or we get some reference to disk storage so later we can load. ? Hope to hear from you soon
@rishabhanand4270
@rishabhanand4270 3 жыл бұрын
So they're running a web assembly module to just decode the video segments (probably a emscriptten compiled ffmpeg?) and "stitch" it all together? They might be using a SharedArrayBuffer to share the video memory between the wasm and their main thread. Lot of optimizations around here, beautiful architecture gotta say.
@ThePapanoob
@ThePapanoob 3 жыл бұрын
The thing is theyre using standard hls with ts playlists. They dont have to stitch anything because of that. My bet is theyre doing it because of ads.
@CODFactory
@CODFactory 2 жыл бұрын
so some worker tells the client which url to go to for fetching the next 2s segment? and is that the web assembly worker? Is it possible that a websocket connection be opened and server keeps sending a stream of continuous bytes and client just start streaming those bytes as video? If its possible, then these 2 seconds segments are not needed and so many requests won't happen right?
@mockingbird3809
@mockingbird3809 3 жыл бұрын
Can you make a video on HLS streaming? It'd be nice to see a detailed HLS streaming video from you!
@hnasr
@hnasr 3 жыл бұрын
I discussed KZbin streaming which uses HLS kzbin.info/www/bejne/Z16unn-ZZchlqc0 enjoy
@jayshah5695
@jayshah5695 3 жыл бұрын
Is there a standard websocket subprotocol one should use ?
@rainthstrive
@rainthstrive 3 жыл бұрын
Great explanation, thank you!
@FilthySnob
@FilthySnob 2 жыл бұрын
What a great video
@bhumit070
@bhumit070 3 жыл бұрын
Hussein please make a video on how to disable options request
@abhisheknarwal4437
@abhisheknarwal4437 2 жыл бұрын
How do the handle these many connections to sockets on their servers??
@puntirock717
@puntirock717 3 жыл бұрын
Can we actually make the websocket connection given there is a nonce being used
@pajeetsingh
@pajeetsingh 3 жыл бұрын
Thanks bro.
@Mutlaq777
@Mutlaq777 3 жыл бұрын
Good job!
@sapn1s16
@sapn1s16 3 жыл бұрын
Do you have any ideas why are they using HTTP/Websockets instead of WebRTC?
@shashankshekhar8970
@shashankshekhar8970 3 жыл бұрын
My guess would be primarily because webrtc doesnt scale too well. In a live video call you will at max be in a meeting with 250-300 people. Thats fine for WebRTC, its a whole different ball game when the content has to be streamed to hundered thousand users. Also TCP helps them with analytics and gives a better control
@sapn1s16
@sapn1s16 3 жыл бұрын
@@shashankshekhar8970 Thank you
@AnimatedHooman
@AnimatedHooman 3 жыл бұрын
This is a fucking goldmine
@sheriffola
@sheriffola 3 жыл бұрын
Cool stuff 👍🏽
@davidagyakwa288
@davidagyakwa288 3 жыл бұрын
how do you group metadata from actual data
@saeed99977
@saeed99977 3 жыл бұрын
Hi hussein make video about how clubhouse voice chat work
@xdxdhehe
@xdxdhehe 3 жыл бұрын
You inspire me to be a better engineer! Keep it up!
@prenomnom5637
@prenomnom5637 3 жыл бұрын
good video
@khld413
@khld413 3 жыл бұрын
did you see the leaked source of Twitch ?
@DrDoctopus
@DrDoctopus 3 жыл бұрын
Why devtool it when you can see the source code for yourself! 😅
@nikolas8741
@nikolas8741 3 жыл бұрын
Come to me bots
@ShubhamSpawN
@ShubhamSpawN Жыл бұрын
Thanks!
@saeed99977
@saeed99977 3 жыл бұрын
Hi hussein make video about how clubhouse voice chat work
How TikTok short content is delivered through HTTP - Devtooling TikTok
19:44
Spotify Web is bloated - Devtooling Spotify
30:24
Hussein Nasser
Рет қаралды 77 М.
бабл ти гель для душа // Eva mash
01:00
EVA mash
Рет қаралды 8 МЛН
How Instagram content is served through GraphQL - Devtooling Instagram
27:28
Identifying backend connection latencies with chrome devtools
17:59
Hussein Nasser
Рет қаралды 14 М.
Six stages of a good software engineer
37:12
Hussein Nasser
Рет қаралды 31 М.
Apple is wrong!  Most people DO NOT need a new Mac!
11:39
Reboot Retro
Рет қаралды 174
I like this Backend
21:11
Hussein Nasser
Рет қаралды 299 М.