When to use UDP vs TCP in Building a Backend Application?

Sdílet
Vložit
  • čas přidán 27. 07. 2024
  • In this video I explain when to use TCP vs UDP as a communication protocol on your backend app. I go through the advantages and disadvantages of UDP I also discuss the protocol within the context of Chatting System, Multiplayer game, and building a browser and a web server
    0:00 Intro
    2:00 UDP
    3:00 TCP
    6:00 UDP vs TCP for Building a Chatting System
    9:20 UDP vs TCP for Building a Multiplayer game
    15:30 UDP vs TCP for Building a Browser and WebServer
    19:11 Summary
    🏭 Backend Engineering Videos
    • Backend Engineering (B...
    💾 Database Engineering Videos
    • Database Engineering
    🛰 Network Engineering Videos
    • Network Engineering
    🏰 Load Balancing and Proxies Videos
    • Proxies
    🐘 Postgres Videos
    • PostgresSQL
    🚢Docker
    • Docker
    🧮 Programming Pattern Videos
    • Programming Patterns
    🛡 Web Security Videos
    • Web Security
    🦠 HTTP Videos
    • HTTP
    🐍 Python Videos
    • Python by Example
    🔆 Javascript Videos
    • Javascript by Example
    👾Discord Server / discord
    Become a Member
    / @hnasr
    Support me on PayPal
    bit.ly/33ENps4
    Become a Patreon
    / hnasr
    Stay Awesome,
    Hussein
  • Věda a technologie

Komentáře • 67

  • @theSDE2
    @theSDE2 Před 2 lety +2

    i just love how your one video connects to other and it starts making more sense. Beautiful concepts and amazing explanation

  • @tambolaking5383
    @tambolaking5383 Před 3 lety +1

    I've been following you since you had a few thousand subscribers. the journey from 0 to a few thousand must have been very difficult for you. But I am impressed with the quality you bring now. Congratulations on close to 50k subscribers

    • @hnasr
      @hnasr  Před 3 lety

      Thank you for being a long time sub and for all your feedback ❤️

  • @abhishekgehlot2647
    @abhishekgehlot2647 Před 3 lety

    Thank you so much for this.
    Thanks to youtube algorithm that I found your channel.
    You're doing a great job.
    Explaining in such a smart and funky way.
    Love from india.

  • @saggitt
    @saggitt Před 3 lety +3

    Great video, thank you! Suppose we do need raw UDP to quickly transfer game states from server to client. How would you structure that state, messages and their processing to minimize the effects of bad connection? Maybe you can point to some existing materials on this topic?

  • @TestAutomationTV
    @TestAutomationTV Před 3 lety +4

    IBM Aspera is a premium product built on UDP I guess. It is pretty expensive but fast. I work at a company that deals w large amounts of data. Good to know about the Quick protocol. I'll tell my manager about it. I am the test developer on the team, the ultimate decision will be in lead developer's hands and our manager's hands.
    Fun story, I teach TCP and UDP on Udemy so I am confident that I know some stuff about these. In a recent meeting our manager talked about building a desktop application for file transfer and maybe using TCP or UDP. I said nonchalantly "UDP is too unreliable for data transfer, yes it's fast but it'll screw up our files".
    The manager was so upset, I too gathered that my input was uncalled for and unwelcome. I reached him out after the meeting and said sorry.
    Not sharing links of my courses because I believe it will damage the purpose of posting this comment, want it to be pure haha.

  • @davidhsv2
    @davidhsv2 Před 3 lety +3

    Please don't forget the vulcain follow up. I'm tired of writing 5 endpoints for different representations of the same entity :( Love your work, cheers from Brazil

  • @bobby9568
    @bobby9568 Před 3 lety +1

    Just what I needed, thanx!

    • @hnasr
      @hnasr  Před 3 lety +1

      Your welcome 🙏

  • @norah5073
    @norah5073 Před 2 lety

    Your video always have fun :)
    Thank you for this video

  • @consistentlearners
    @consistentlearners Před rokem

    I am a great fan of you Hussein. I really appreciate your efforts in removing the idea of abstraction and making us how things work under the hood.
    I have been watching out your videos since 2021, I really loved your videos for focusing on the fundamentals instead of the fancy stuff.

  • @tahasaleh4697
    @tahasaleh4697 Před 3 lety +1

    Your videos are so good, you need your own subreddit!

    • @hnasr
      @hnasr  Před 3 lety

      Maybe one day!

  • @yodude2493
    @yodude2493 Před 2 lety

    Thanks man for videos

  • @andreytamelo1183
    @andreytamelo1183 Před 3 lety

    Super video! I applauded for $2.00 👏

  • @SachithNalakaMuhandiram

    one waited video, thanks for uploading...

    • @hnasr
      @hnasr  Před 3 lety +1

      Sure thing! Thanks for watching

  • @tonyramesh8184
    @tonyramesh8184 Před 3 lety +2

    thanks again ❤❤❤

  • @SachinDolta
    @SachinDolta Před 3 lety +10

    TCP-> foreplay
    Got it 👍

  • @vamsishankar2825
    @vamsishankar2825 Před 3 lety +3

    So UDP can be used for video streaming or voip like applications right? As there we can afford to lose some data while transmission

  • @AbdullahAyyash
    @AbdullahAyyash Před 3 lety

    Great video! I've seen two videos you did on QUIC in compression to HTTP2 and the possibility of using it to improve databases. Could you please make a video explaining QUIC in depth? How it works, when to use it and how to use it as an alternative to HTTP?

    • @hnasr
      @hnasr  Před 3 lety +3

      I still need to make that video yes! Still researching it but I think I am ready to make it 😊

  • @vasuudayar3691
    @vasuudayar3691 Před 3 lety

    u r helping many beginner backend engineers thanks a lot.

    • @hnasr
      @hnasr  Před 3 lety

      It's my pleasure (L)

  • @toekneema
    @toekneema Před 3 lety

    Great analogies

  • @viraj_singh
    @viraj_singh Před 3 lety +2

    Very informative 👍

    • @hnasr
      @hnasr  Před 3 lety

      Viraj Singh 🙏

  • @serhiihorun6298
    @serhiihorun6298 Před 3 lety

    Cool, thanks

  • @rajatsharma8147
    @rajatsharma8147 Před 3 lety +5

    Amazing video. You videos help me to get the concepts easily. Need a video on SQL vs NoSQL.

  • @EddyCaffrey
    @EddyCaffrey Před 3 lety +2

    Thanks 👍🏽. So HTTP/3 moving to UDP will come with some amazing improvement in efficiency 😉.

    • @hnasr
      @hnasr  Před 3 lety +2

      Yup killing this head of line blocking

  • @rajeshkishore7171
    @rajeshkishore7171 Před 3 lety

    excellent

  • @artieedwards
    @artieedwards Před 3 lety

    Brilliant, fucking beautiful lecture!!!

  • @johnalgozzini2165
    @johnalgozzini2165 Před rokem

    I'm trying to use my tcp/udp app to determine what server I'm on in a certain game on xbox. I can use this on my pc but, how do I use it on my xbox if I'm using a VPN router connected directly with my router and xbox?

  • @chandandey8271
    @chandandey8271 Před 2 lety +1

    Hi Hussein, Can you tell me why most of the databases are use TCP for communication. I heard the answer some of your video but forget. Can you tell me the answer one more time?

  • @TestAutomationTV
    @TestAutomationTV Před 3 lety

    Yah, still here bro! 😁

  • @rahuldeep4811
    @rahuldeep4811 Před 3 lety

    Hi @Naseer, How UDP server sends response back to Client? For example like in multpi player game, how Gaming server inform end game user that the building is destroyed?

    • @hnasr
      @hnasr  Před 3 lety

      The udp packet has a source ip address the server can use to send replies back

    • @asimarunava
      @asimarunava Před 3 lety

      @@hnasr it means the client will act as a server when recieving data. So client must run a udp server? Am i making sense with my question?

  • @hackwithharsha5228
    @hackwithharsha5228 Před 3 lety +1

    Thanks Hussein !! Some Noob questions
    1. If TCP is stateful, why HTTP is stateless which built on top of TCP ?
    2. Does our HTTP status code depends on the acknowdedgment that server sends to client in TCP ?

    • @hnasr
      @hnasr  Před 3 lety +3

      HackWithHarsha good questions
      1) HTTP is stateless and is built on TCP which is stateful. There is no state stored on the server at the application side for HTTP every request comes with all the information it needs. It just different design. HTTP always easier horizontal scalability, or if the server goes down and came back up the requests will still be served..
      Check out my stateless vs stateful video
      2) status codes have nothing to do with TCP its pure application level codes .

    • @hackwithharsha5228
      @hackwithharsha5228 Před 3 lety

      @@hnasr Got it, thanks.. I will check your stateless vs stateful video

    • @_SoundByte_
      @_SoundByte_ Před 3 lety +1

      TCP headers are tracked (seq numbers, error correction etc). Http headers are not tracked by the server. Hence stateless.

    • @hnasr
      @hnasr  Před 3 lety

      Yup 👍👍

  • @ravitejavankam2977
    @ravitejavankam2977 Před 3 lety

    UDP will be useful for logistics tracking

  • @justsaysharu
    @justsaysharu Před 3 lety

    So is QUIC just the best of both the worlds? I mean a combination of TCP and UDP features - by processing the ACKs of each channel/StreamID individually? But still, need an ACK for guarantees?

    • @hnasr
      @hnasr  Před 3 lety +1

      I wouldn’t go as far as say that QUIC is the best.. QUIC was designed to solve the limitation where a client need to send multiple requests to the same host in parallel specifically stateless requests.. web browsing is great for that.. does it fit all cases ? Maybe yes maybe no..
      QUIC comes with cost that people are still try to minimize.. nothing beats raw TCP/UDP so far as we know

    • @LordNementon
      @LordNementon Před 3 lety

      @@hnasr SCTP ? 🙃

  • @medilyesoudhini7411
    @medilyesoudhini7411 Před 3 lety +2

    14:50 low latency* not high latency

  • @waynewatson7970
    @waynewatson7970 Před 3 lety

    Hi Hussein, newbie here, can you post a video on hosting a basic website, which hosting platform. I get confused by all the options and I am trying to learn web dev on a budget. For example say I progress from hello world page to a node.js/mongodb/postgres page/app, how do I host that, where do I host that. It is very confusing. I want to be able to at some point in the future have my own website with multiple links to different projects, some of which may use leaflet.js and postgres or mongodb. I also would like to make sure once I set up a login page that the node server is secure etc. Can you shed some light, I ask you because I have enjoyed your video's and they help me understand things better. I know I could walk through all your videos and piece it together, but I am hoping for at least a general idea on what is important and what is not. Maybe I just go to AWS or Azure, but the last time I was with AWS and posted a simple website I was unsure of possibly getting charges I didn't understand. Thank you.

    • @hnasr
      @hnasr  Před 3 lety

      Hey Wayne I love to start from scratch and host the website on my own laptop so that people understand how things work before jumping to the cloud..
      You are right there are so many options out there so if you self host on your own machine you know exactly what you need to do the work
      See my caddy web server video its the easiest czcams.com/video/t4naLFSlBpQ/video.html

    • @waynewatson7970
      @waynewatson7970 Před 3 lety

      @@hnasr thank you sir, will look at video and see where I am at.
      :)

  • @markreyronolo1482
    @markreyronolo1482 Před 3 lety

    Hussein "Sent the dang packet" Nasser

  • @user-si5vk5cd9w
    @user-si5vk5cd9w Před 3 lety

    why vpn apps use UDP ?

    • @hnasr
      @hnasr  Před 3 lety

      Because otherwise the VPN will suffer from TCP meltdown.

  • @mmu200
    @mmu200 Před 3 lety

    Hahaha, Like your blaaaaaaa for describing UDP.

  • @rezmed1144
    @rezmed1144 Před 2 lety

    Amazing you're an arabic version of Lunduke

  • @_SoundByte_
    @_SoundByte_ Před 3 lety

    Nice haircut :P less distraction

    • @hnasr
      @hnasr  Před 3 lety

      For me too haha

  • @user-oy4kf5wr8l
    @user-oy4kf5wr8l Před 3 lety +7

    Tcp is like the first 3 years of ur marriage, u talk, ur wife listens. UDP is tge marriage after hahaha. U two just don't care whether the other one listens to u or not hhh.

    • @hnasr
      @hnasr  Před 3 lety

      采花大盗江南 😂😂

  • @tambolaking5383
    @tambolaking5383 Před 3 lety +1

    TCP makes sure your receive
    UDP just sends
    TCP is a good salesman. Follows up. UDP is an unmotivated employee. Ask it to send, it sends, nothing more, nothing less.

    • @hnasr
      @hnasr  Před 3 lety +2

      I am UDP always

  • @eccosabanovic1589
    @eccosabanovic1589 Před 3 lety

    ...so UDP is Alpha and TCP is simp..lol