How Web Sockets work | System Design Interview Basics

Поділитися
Вставка
  • Опубліковано 7 лют 2025
  • In this video I explain basics of Web Sockets, and compare it with Polling and HTTP Long Polling, which you must know for system design interview.
    / bytemonk
    • System Design Intervie...
    • System Design Questions
    • LLM
    • Machine Learning Basics
    • Microservices
    • Emerging Tech
    AWS Certification:
    AWS Certified Cloud Practioner: • How to Pass AWS Certif...
    AWS Certified Solution Architect Associate: • How to Pass AWS Certif...
    AWS Certified Solution Architect Professional: • How to Pass AWS Certif...

КОМЕНТАРІ • 105

  • @ByteMonk
    @ByteMonk  5 місяців тому +7

    Part-2: Web Sockets Deep Dive
    ua-cam.com/video/G0_e02DdH7I/v-deo.html

    • @evbike
      @evbike 3 місяці тому +1

      Glad to know you accepted feedback and posted a new video ❤

  • @kyleh1623
    @kyleh1623 10 місяців тому +31

    Really appreciated how you explained web sockets in comparison with HTTP Requests, making the exact point of utilizing web sockets stand out. That really helped me understand much better🙌

    • @ByteMonk
      @ByteMonk  10 місяців тому +3

      Thanks for taking the time to comment on the video. Soon I will be publishing an advance tutorial on Web Sockets, so stay tuned :)

  • @bluesquare23
    @bluesquare23 Рік тому +14

    I could listen to you say "full duplex asynchronous messaging" all day.

  • @distortedjams
    @distortedjams Рік тому +42

    Really appreciate the video. The animations made it so much easier to follow along and I completely understood it with a single watch. Keep up the great work.

  • @fatbubble123
    @fatbubble123 Рік тому +4

    It is so easy to study for my system design interviews when I have so much quality youtube to click through, quite lazily I might add. Thanks for the amazing videos!

  • @RadenVijaya
    @RadenVijaya Рік тому +2

    I learnt this is computer communication lecture many years ago. Glad to have a refresher now!

  • @Tyrone-Ward
    @Tyrone-Ward 11 місяців тому +46

    I like how 90% of this video has NOTHING to do with Websockets 😂

  • @sushantp25
    @sushantp25 Рік тому +2

    Incredible efforts! to be honest i am truly grateful to find this channel ! keep up the good work! thank you so much

    • @ByteMonk
      @ByteMonk  Рік тому +1

      thank you for the comment, keeps me going :)

  • @ruturajbhandari7695
    @ruturajbhandari7695 11 місяців тому +2

    Amazing content. I hope You Reach Millions of subscribers

  • @MrGangel77
    @MrGangel77 25 днів тому

    Realyl well explained for beginners. Perhaps also need to include SSE?

  • @sahaneakanayaka3394
    @sahaneakanayaka3394 Рік тому +5

    Crystal clear explanation

  • @betterwithrum
    @betterwithrum Рік тому +5

    As others have said, this is some of the best content on UA-cam. Could you do a complete course on K8S? I’d happily pay for it

  • @gphii
    @gphii 29 днів тому

    Good video 👌👍

    • @ByteMonk
      @ByteMonk  27 днів тому +1

      Stay connected☺️

  • @tawfeeqsenan
    @tawfeeqsenan Місяць тому

    great explanation 😍

  • @mylaidbacklife
    @mylaidbacklife Рік тому +3

    It took 200 mins to watch but everything explained really well

  • @kvelez
    @kvelez 2 місяці тому +1

    Great video.

  • @amritvasyal7149
    @amritvasyal7149 4 місяці тому +1

    Very nice bhai...

  • @AshootoshBhardwaj
    @AshootoshBhardwaj 6 місяців тому +3

    Great Video! For the impatient ones, jump directly to 03:20 to know about websockets!

  • @lunaq3681
    @lunaq3681 Рік тому +1

    appreciate your work thanks a ton

  • @maedalnatour1516
    @maedalnatour1516 Рік тому +1

    Amazing 👌

  • @KDOERAK
    @KDOERAK Рік тому +1

    excellent👍

  • @therevealerDev
    @therevealerDev Рік тому +2

    This is very clear and easy to understand.
    Thanks!

  • @hmbil694
    @hmbil694 Рік тому +2

    This is A-tier content. Keep up the good work!

  • @satyanarayandalei-rz2kw
    @satyanarayandalei-rz2kw Рік тому +1

    That was awesome explanation.

  • @fabianleon7640
    @fabianleon7640 Рік тому +2

    Really well represented, thanks for sharing

  • @abhiydv8624
    @abhiydv8624 6 місяців тому +1

    awesome explanation, thank you

  • @justafreak15able
    @justafreak15able 7 місяців тому +9

    Title should have benn HTTP polling 😂

    • @ByteMonk
      @ByteMonk  7 місяців тому

      This was made from system design interview perspective. I have done a part-2 follow up video to deep dive on web sockets , please check that out in my channel

  • @davidmartensson273
    @davidmartensson273 4 місяці тому

    Quite good video, but one thing with long polling is that the server did not necessarily have to end the request to send data, by writing to the response and then triggering a flush, the written parts got sent to the client and the get request stayed open so the client only had to re connect once it timed out, and if the server kept sending something, the browser kept waiting.
    This might not work with modern ajax type requests but we used an even older solution where you added a script tag for a js file, I think that later got the name jsonp.
    The browser will parse and process that js file as data comes through so the server send js commands that when executed triggered a reaction, and if the server had nothing to send it sent a command that did nothing.
    This still tied up resources of cause, but this was before ajax was a thing so it was this method or using a java applet, flash object or similar if you wanted any type of polling.

  • @Lottielogic
    @Lottielogic Рік тому

    Loved this!

  • @Mayaadyby.
    @Mayaadyby. Рік тому +3

    So clear & well described 👌

  • @ibrahimnaser5233
    @ibrahimnaser5233 8 місяців тому

    cool, very simple explanation 👍

  • @jagrit07
    @jagrit07 6 місяців тому +1

    Nice video, Thank you!

  • @quintencabo
    @quintencabo Рік тому +1

    Nice video!

  • @oleksandrsova4803
    @oleksandrsova4803 Рік тому +117

    But you haven't explained *how* it works. Not even a bit. Like what is behind those well-known WS interfaces? What is in the TCP package? Is it any special for WS? Do we need a URL to establish a connection? How to distinguish one connection from another one? Is there a notion of a cookie? How does the session work in the context of WS-based service? How does load balancing work with WS connections? What is the usual limit on the number of WS connections? Is it a number of opened file descriptors? What it depends on?

    • @ByteMonk
      @ByteMonk  Рік тому +19

      Thanks for the feedback with specific examples. While these are good question, this video was made for System Design Interviews. To our knowledge, this level of detailing on web-sockets is not required in any of the Tier1/Tier2 Tech companies from System Design perspective, unless one is applying for a speciality position. Based on my market research, I may plan to deep dive on websockets in future. Thanks again!

    • @narebinhaa
      @narebinhaa Рік тому +47

      He means that the title of this videos should not be "How websocket work". It should be "What is websocket".

    • @MrEliteXXL
      @MrEliteXXL 4 місяці тому

      That's exactly what I was expecting 😅

  • @GalGreen
    @GalGreen Рік тому

    It was a nice video, but it barely explained "How Web Sockets work", only in 3:45 to 4:18.
    Almost all of the video was actually about "What are Web Sockets", focusing mainly on a comparison between polling and sockets, which was well presented, but wasn't supposed to be the topic of the video promised by the title.

    • @snuffbox2006
      @snuffbox2006 Рік тому

      it is important to know the motivation for why web socket exists before we learn web sockets. What problem is it solving and why do we need it?

  • @Jai-xq5hi
    @Jai-xq5hi Рік тому +2

    Wonderful explanation ❤

  • @Kitsune_Dev
    @Kitsune_Dev 4 місяці тому +1

    thank you!

  • @pfever
    @pfever Рік тому +2

    Amazing simple explanation, subscribed :)

  • @chaudang1279
    @chaudang1279 Рік тому +6

    Hi there. Thank you for sharing such a well-presented and easy to understand explanation. Can I ask for your permission to remake this video and translate it into Vietnamese to share with my audiences on UA-cam? Most of them are IT students and of course it is non-commercial purpose. Thank you!

  • @raghavaggarwal9093
    @raghavaggarwal9093 Рік тому +1

    Nicely explained

  • @Max-ot2jc
    @Max-ot2jc Рік тому +2

    Thanks! Really useful

  • @amitanshusahu1079
    @amitanshusahu1079 Рік тому +4

    Love this .. explanation, use cases, when not use every thing was covered 10/10

  • @py7432
    @py7432 5 місяців тому

    WS is like an additional layer of protocol on top of http/s, however browser supports client server due to security reasons so how the socket able to send request from the server to the client?

    • @ByteMonk
      @ByteMonk  5 місяців тому

      please checkout the deep dive video, link in pinned comment/description

  • @MuhammadBilal-cs3dg
    @MuhammadBilal-cs3dg Рік тому +1

    Amazing content

  • @Curious_Citizen0
    @Curious_Citizen0 Рік тому +1

    good one!!

  • @rohith8269
    @rohith8269 Рік тому +1

    Great video. Keep going!

  • @lazerbaconpro
    @lazerbaconpro 5 місяців тому +1

    Excellent video.

  • @hassaan-dev
    @hassaan-dev Місяць тому

    Great

  • @dinesh.p8642
    @dinesh.p8642 5 місяців тому +1

    gold content. thank you!!

  • @afrikanonyma
    @afrikanonyma Рік тому +2

    Great ! If possible to make a longer video about its usecases, like a small tuto ?

    • @ByteMonk
      @ByteMonk  Рік тому +1

      thank you for the suggestion

  • @JohnSmith-qg3jb
    @JohnSmith-qg3jb 4 місяці тому

    U misrepresented a normal request. The response is in the same connection, not a new one as there is no way for the server to contact the client.

  • @aaAaa-rq2cj
    @aaAaa-rq2cj Рік тому

    What tool u used for animation in the video

  • @santoshbhat7847
    @santoshbhat7847 Рік тому +1

    How do you create animations ?

    • @Mr.Motion.
      @Mr.Motion. Рік тому

      With the help of Adobe after effects.

  • @popguy2046
    @popguy2046 Рік тому

    whats the best way to track websocket payload acknowledgement from frontend? (given we can't do it with the same websocket connection)

    • @ByteMonk
      @ByteMonk  Рік тому +1

      When you cannot directly track WebSocket payload acknowledgments using the same WebSocket connection, you can implement a custom acknowledgment mechanism using a combination of techniques.
      1. Create a Unique Identifier for Each Payload:
      Before sending a payload from the frontend, assign a unique identifier (message ID) to each payload. This ID will help you correlate the acknowledgments received from the backend with the original payloads sent from the frontend.
      2. Use a Separate Channel for Acknowledgments:
      Set up a separate communication channel between the frontend and backend. This can be another WebSocket connection, an HTTP REST API, or any other messaging protocol that suits your application.
      3. Send Payloads and Wait for Acknowledgments:
      When sending a payload from the frontend to the backend via the primary WebSocket connection, store the payload's unique identifier along with its content in a local data structure (e.g., a map).
      4. Backend Processing and Acknowledgment:
      On the backend, process the received payload and perform the required actions. After the backend has processed the payload successfully, it sends an acknowledgment message back to the frontend via the separate communication channel, containing the unique identifier of the processed payload.
      5. Frontend Acknowledgment Handling:
      When the frontend receives an acknowledgment, it can use the unique identifier in the acknowledgment message to identify the corresponding payload in the local data structure and mark it as acknowledged. You can remove the entry or update its status in the map.

  • @ahmedghallab5342
    @ahmedghallab5342 Рік тому +1

    شكرا thanks

  • @jasonranaweera3630
    @jasonranaweera3630 4 місяці тому +1

    I even reported this dude for misinformation 😂

    • @ByteMonk
      @ByteMonk  4 місяці тому +1

      thank you for sharing :D

  • @henryl7421
    @henryl7421 2 роки тому +2

    this is gold info

    • @henryl7421
      @henryl7421 2 роки тому +1

      thank you for doing this!!

    • @henryl7421
      @henryl7421 2 роки тому +1

      I will tell everyone about this channel

    • @ByteMonk
      @ByteMonk  2 роки тому +1

      @@henryl7421 Thank you for supporting my work 🙏, this will keep me going

  • @lezeroq
    @lezeroq 4 місяці тому +1

    I stopped watching when author said that for polling you need to open connections for each request. Http 1.1 support keep-alive header to keep connection open. So you use the same connection to make requests.

    • @ByteMonk
      @ByteMonk  4 місяці тому +1

      Yes, HTTP/1.1 supports the Keep-Alive header, allowing the reuse of a single connection for multiple requests.
      Thanks for pointing that out! What I meant to highlight is that in polling, even though the connection can be kept open, the client still has to send repeated requests at regular intervals to check for updates. This can lead to inefficiencies in terms of bandwidth and server load, especially when there’s no new data.
      Alternatives like long polling and WebSockets can be more efficient for real-time updates, as they reduce the need for frequent requests or allow continuous, bidirectional communication.
      I have made a deep-dive video on Web Sockets in the description.

  • @saeeduchiha5537
    @saeeduchiha5537 Рік тому +2

    Almost all apps nowadays have Real Time part in them

  • @martinabeita8852
    @martinabeita8852 Рік тому +1

    nicely explained

  • @WaldoTheWombat
    @WaldoTheWombat 4 місяці тому +1

    Wait web sockets use TCP? But I thought UDP was the fast one. Then who the the hell DOES use UDP?

    • @ByteMonk
      @ByteMonk  4 місяці тому

      WebSockets use TCP, not UDP because TCP provides reliable, ordered, and error-checked communication, which is crucial for WebSocket connections. UDP is used in scenarios where speed is more important than reliability, and some data loss is acceptable, for instance Video streaming (e.g., live broadcasts), Online gaming, Voice over IP (VoIP), video calls and IoT devices , all these are stateless.
      So, WebSockets excel in real-time, full-duplex communication with reliable data delivery, ideal for chat apps, stock updates, and collaborative tools. For lightweight, low-latency, or stateless tasks, protocols like UDP and RTP are more efficient due to lower overhead.

    • @WaldoTheWombat
      @WaldoTheWombat 4 місяці тому +1

      ​@@ByteMonkBut in your video you said that for gaming we use web web sockets

  • @blueboy-tm
    @blueboy-tm Рік тому +1

    Nice thanks bro

  • @haydonrex
    @haydonrex Місяць тому

    wow

  • @supersoniqamanyi3075
    @supersoniqamanyi3075 Рік тому +1

    Great great

  • @danushadhaamarasekera7215
    @danushadhaamarasekera7215 10 місяців тому

    thank you brother

  • @AjayCoding
    @AjayCoding Рік тому +1

    Great

  • @jairajsahgal7101
    @jairajsahgal7101 Рік тому +1

    thank you

  • @krishna26g
    @krishna26g Рік тому +1

    Who asked you about polling

  • @wassup102
    @wassup102 Рік тому +1

    thanks

  • @Zmey5656
    @Zmey5656 8 місяців тому +1

    I use WebSocket to get real cryptocurrency data

  • @Pablo-hp2jp
    @Pablo-hp2jp 10 місяців тому

    Das Video erklärt viel Kontext, aber leider keine Details zu WebSockets. Schade

  • @aakaashwani
    @aakaashwani 2 місяці тому

    Start at 3:17 - spends 15 sec on web sockets. Then gets into use cases. Useless video

    • @ByteMonk
      @ByteMonk  2 місяці тому

      This was done from system design interview perspective, I made a part-2 to deep dive into web sockets , link in comments/description

  • @eminence_grise
    @eminence_grise 2 місяці тому

    If I wanted to know about HTTP, I would have studied it somewhere else. This is a completely misleading title.

    • @ByteMonk
      @ByteMonk  2 місяці тому

      This is web sockets from System Design interview perspective, where you are only expected to know about websockets at a high level. Based on previous request I have also made a part-2 deep dive video in my pinned comment below. Thanks.

  • @Apoorvpandey
    @Apoorvpandey 2 роки тому +1

    Crisp

  • @siyaram2855
    @siyaram2855 2 роки тому +1

    1st

  • @zixuanzhao6043
    @zixuanzhao6043 5 місяців тому

    speaking too fast bro

    • @ByteMonk
      @ByteMonk  5 місяців тому

      thanks for the feedback, will work on my pace

  • @shahfaisal3923
    @shahfaisal3923 Рік тому

    You won a subscriber from Afghanistan.
    Great Video.