Stateful vs Stateless Applications (Explained by Example)

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 ส.ค. 2024
  • If you ever wondered the difference between stateless and stateful applications, REST, horizontal scaling versus vertical scaling? We tackle those in a small example. Hope you guys enjoy this quick video. We explain the advantages and disadvantages of each application.
    0:00 Intro
    1:14 Stateful Application
    8:40 Stateless Application
    Online diagram tool used in this video: Http://www.gliffy.com
    Checkout the rest of the content for more software engineering topics by example.
    🏭 Software Architecture Videos
    • Software Architecture
    💾 Database Engineering Videos
    • Database Engineering
    🛰 Network Engineering Videos
    • Network Engineering
    🏰 Load Balancing and Proxies Videos
    • Proxies
    🐘 Postgres Videos
    • PostgresSQL
    🧮 Programming Pattern Videos
    • Programming Patterns
    🛡 Web Security Videos
    • Web Security
    🦠 HTTP Videos
    • HTTP
    🐍 Python Videos
    • Python by Example
    🔆 Javascript Videos
    • Javascript by Example
    Stay Awesome
    -Hussein Nasser
    www.husseinnasser.com
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 315

  • @nikhilbalwani5556
    @nikhilbalwani5556 4 ปีที่แล้ว +156

    If you were my professor, I would be ready to sit in your lecture for hours. Beautiful explanation

    • @hnasr
      @hnasr  4 ปีที่แล้ว +9

      Nikhil Balwani im humbled ❤️ thanks

    • @ShoeibShargo
      @ShoeibShargo 2 ปีที่แล้ว +4

      If he were my professor, I would be sitting at FAANG now.

    • @adamgontiersa78
      @adamgontiersa78 ปีที่แล้ว

      And you would land any job you want, he exolains concerts with simplicity and efficiency

  • @hnasr
    @hnasr  5 ปีที่แล้ว

    Check out my new video about stateful apps th-cam.com/video/EKCM1oQQrCM/w-d-xo.html

  • @hnasr
    @hnasr  5 ปีที่แล้ว +4

    Watch the new 2019 video Stateless vs Stateful python 🐍 application code examples th-cam.com/video/nhwZn6v5vT0/w-d-xo.html

  • @zencollector
    @zencollector 3 ปีที่แล้ว +10

    Even 3 years later this explanation is one of the best on the web. Thanks a bunch mate!

  • @vishwaskaupvijayananda3900
    @vishwaskaupvijayananda3900 4 ปีที่แล้ว +8

    This video makes a lot of other web app concepts so much more clearer. Thanks a mil!

  • @anonymous.youtuber
    @anonymous.youtuber 4 ปีที่แล้ว +24

    Man am I glad I found someone that really knows how to really explain something. Great video ! 👍🙋‍♀️

    • @hnasr
      @hnasr  4 ปีที่แล้ว +4

      Thank you Claire 🙏 I am glad you enjoyed the content and found it helpful

  • @matthewspiteri482
    @matthewspiteri482 5 ปีที่แล้ว +58

    I work full time as a software developer, I stumbled across this while doing some research, and what can I say? you have an amazing character. Well explained :)

    • @hnasr
      @hnasr  5 ปีที่แล้ว +7

      Matthew Spiteri Thank you so much for your wonderful comment. Glad to see fellow software developers here. Best of luck !

  • @hnasr
    @hnasr  2 ปีที่แล้ว

    Check out my udemy Introduction to Database Engineering course
    database.husseinnasser.com
    Learn the fundamentals of database systems to understand and build performant backend apps

  • @John845
    @John845 3 ปีที่แล้ว +3

    Been programming over a year and never realized the correlation between REST and Stateless. Mind = blown. THANK YOU.

  • @mollycrime
    @mollycrime 5 ปีที่แล้ว +6

    nice video! i really appreciate videos like this that talk about real concepts/use cases in a simple way that you can watch on down time. keep at it cause it looks like the videos you're making are really cool!

    • @hnasr
      @hnasr  4 ปีที่แล้ว +1

      mollycrime Thanks! I try to give examples where I can from my personal experience working with a technology. Appreciate it!

  • @shreysom2060
    @shreysom2060 3 ปีที่แล้ว +1

    I am hooked to your videos and as a junior back end developer i am learning a lot seeing things from different perspectives in my job. Thankyou so much

  • @staj
    @staj 4 ปีที่แล้ว +2

    Brilliantly and Concisely explained! Thanks a Lot HN!

  • @ruixue6955
    @ruixue6955 4 ปีที่แล้ว +54

    2:44
    4:41 introduction to the problem of stateful application
    5:50 problem: impossible to scale up
    6:10
    6:51 stateful with load balancer
    8:36 stateless example
    8:52 Alice is using REST, State transfer
    11:14 server sends Alice a *token*
    11:34 then Alice will send request always with the token

    • @deepak3303
      @deepak3303 3 ปีที่แล้ว

      wow, indented sub-chapters. TH-cam should support MD for comments. 🔥🔥

  • @claushellsing
    @claushellsing 4 ปีที่แล้ว +3

    I'm on a marathon of your videos man. Awesome content

    • @hnasr
      @hnasr  4 ปีที่แล้ว

      Enjoy 😊

  • @potomskazhu
    @potomskazhu 2 ปีที่แล้ว

    dude just thanks, really helped to quickly get a grasp of it

  • @hnasr
    @hnasr  6 ปีที่แล้ว +27

    Stateful Example: 1:10
    Stateless Example: 8:30
    Stateless vs Stateful pros and cons: 13:30

    • @sasg87962
      @sasg87962 5 ปีที่แล้ว

      ونعم ابوعلي

  • @srinidhikulkarni1962
    @srinidhikulkarni1962 2 ปีที่แล้ว

    This was amazing man!! Loved the way you impart things to the viewers!! High Five!

  • @JS-rz5gx
    @JS-rz5gx 2 ปีที่แล้ว

    Brilliant explanation champ! I've watch about 3 or other videos (each being 2 or 3 times longer) and NOT ONE of them came close to explaining it this comprehensively! Well don and a sub from me!

  • @ack377
    @ack377 3 ปีที่แล้ว

    God bless you sir, when no one could explain me this thing...u did it in such a simple way. And yeah that accent of ur's its awesome....I can listen to your lectures for hours

  • @stephaniecrispin674
    @stephaniecrispin674 ปีที่แล้ว

    This is the best tutorial I have ever seen in my life. I'm awed!.

  • @potaraju92
    @potaraju92 4 หลายเดือนก่อน

    I can listen to on any topic you teach, I love your teaching style and voice. I am so glad I came across this channel.

  • @subramanian121
    @subramanian121 2 ปีที่แล้ว +1

    Great video Hussein. Thanks for the example.

  • @samuelshoyemi3751
    @samuelshoyemi3751 3 ปีที่แล้ว

    Plain and simple. Thanks Hussein

  • @romanleca4969
    @romanleca4969 5 ปีที่แล้ว +6

    This is outrageously good. Thank you, mate!

  • @tranphunguyen7044
    @tranphunguyen7044 2 ปีที่แล้ว

    very clear and easy to understand by the excellent explanation. Thank you so much.

  • @ducdatnguyen9251
    @ducdatnguyen9251 4 ปีที่แล้ว +1

    very well explaining, thank you man !

  • @mariusm5187
    @mariusm5187 4 ปีที่แล้ว +1

    Very helpful video, thank you!

  • @Xardas_
    @Xardas_ 2 ปีที่แล้ว

    It's no longer over my head. Thanks

  • @shubhambatham49
    @shubhambatham49 4 ปีที่แล้ว +10

    Sending a long ass token of appreciation all the way from India !! Great & Interesting explanation.Thank you !!

    • @hnasr
      @hnasr  4 ปีที่แล้ว +12

      Shubham Batham sending a signed and time-stamped response token of love to all my subscribers in india ❤️ passcode to decrypt “stay awesome” thanks for your comment!!

  • @harrygeorgiou8518
    @harrygeorgiou8518 3 ปีที่แล้ว +1

    Very well explained! keep the videos coming!

  • @cw5948
    @cw5948 4 ปีที่แล้ว +1

    Excellent explanation! Good job.

  • @0xRei
    @0xRei 3 ปีที่แล้ว

    just learned about load balancers too bless you ser!!!!!!!!

  • @viniciosantos
    @viniciosantos 2 ปีที่แล้ว

    I finally understand this! Thank you

  • @noranhany8213
    @noranhany8213 2 ปีที่แล้ว

    Thank you for simple explanation

  • @TexAli
    @TexAli 5 ปีที่แล้ว +1

    Thank you for a great explanation

  • @onlyamitava
    @onlyamitava 3 ปีที่แล้ว +1

    You explained nicely.. Thanks a lot.

  • @verma-kunal
    @verma-kunal 2 ปีที่แล้ว

    Really beautiful explanation !! Thank you so much

  • @masonthompson8332
    @masonthompson8332 4 ปีที่แล้ว

    Nice work, appreciate the overview.

  • @migueljurado6783
    @migueljurado6783 2 ปีที่แล้ว

    Just amazing explanation bro!

  • @natalieschulz7896
    @natalieschulz7896 6 ปีที่แล้ว +11

    Awesome Video ! Glad I found this - I am VERY NEW to Web Dev and this broke this complex subject down easily :) THANKS

    • @hnasr
      @hnasr  6 ปีที่แล้ว +1

      Natalie Schulz Glad you find was useful, checkout the rest of the content in the channel where we explain other software engineering topics by example. Cheers :)

  • @EnochMaheshsilva
    @EnochMaheshsilva 2 ปีที่แล้ว

    Wow ! Simply an amazing explanation, now only I understand what it means 'State Transfer' in ReST, thanks, keep explaining.

  • @mukeshsinghrawat474
    @mukeshsinghrawat474 4 ปีที่แล้ว +1

    loved it. You made it clear to me. Thanks and yes, I subscribed.

    • @hnasr
      @hnasr  4 ปีที่แล้ว

      Mukesh Singh Rawat thanks Mukesh! Glad I could help and welcome to the community!! Enjoy the content

  • @sarvesh81s
    @sarvesh81s 6 ปีที่แล้ว +1

    Good Explanation..Thank you

  • @parvezmulla3324
    @parvezmulla3324 3 ปีที่แล้ว +1

    your channel is a gem!

  • @vidyakrishnan1757
    @vidyakrishnan1757 2 ปีที่แล้ว

    15 mins of awesome ! Thank you !

  • @ayazahamed8254
    @ayazahamed8254 ปีที่แล้ว

    Very well explained. Good Job Bro. It clears my concept for stateful and stateless 🌹

  • @romantsyupryk3009
    @romantsyupryk3009 4 ปีที่แล้ว

    Thanks so much for this video tutorial.

  • @mukulrana1616
    @mukulrana1616 2 ปีที่แล้ว

    This is the best explaination on youtube

  • @priyamvashi2187
    @priyamvashi2187 5 ปีที่แล้ว +1

    Nice explanation ..Thank you

  • @aminegh8725
    @aminegh8725 2 หลายเดือนก่อน

    Thank you very much for your videos , I dare anyone to watch you explaining a concept whatever the complexity of the concept and not understand it ❤❤❤

  • @mohinimadavi5870
    @mohinimadavi5870 3 ปีที่แล้ว +1

    Thanks a lot! It was crystal and clear explanation. Easy to understand. Subscribing you!

    • @hnasr
      @hnasr  3 ปีที่แล้ว

      Thanks for the sub! appreciate you dear enjoy the content

  • @joshuawalker7375
    @joshuawalker7375 2 ปีที่แล้ว

    Very well made. Thanks for the explanation.

  • @fajartris
    @fajartris 3 ปีที่แล้ว

    I enjoyed it, simple and clear explanation.,

  • @NAVNEET549
    @NAVNEET549 2 ปีที่แล้ว

    That's some cool explanation.

  • @lolokj6848
    @lolokj6848 4 ปีที่แล้ว +1

    Best explain ever..Many thanks

    • @hnasr
      @hnasr  4 ปีที่แล้ว

      🙏

  • @batoolal-sulh2165
    @batoolal-sulh2165 4 ปีที่แล้ว +1

    thank you so much that's so helpful

  • @sumitsharma5537
    @sumitsharma5537 5 ปีที่แล้ว +1

    Interesting explanation!

  • @othmaneibrahimi6026
    @othmaneibrahimi6026 3 ปีที่แล้ว

    Very well explained, thank you ;)

  • @muhammadinshal6216
    @muhammadinshal6216 3 ปีที่แล้ว

    Just logged in to comment a word of appreciation. Glad I found this channel. Beautiful content

    • @hnasr
      @hnasr  3 ปีที่แล้ว

      Appreciate it ❤️❤️

  • @souravskr
    @souravskr 3 ปีที่แล้ว

    It is worthy of investing 14 minutes of your life. Thanks Hussein

  • @tuck582
    @tuck582 5 ปีที่แล้ว

    Doesn't something like "Reliable Collections" solve the scaling issue for stateful (at least for Service Fabric devs)?

  • @denishsubedi3180
    @denishsubedi3180 2 ปีที่แล้ว

    Very good explanation, i want you to teach a whole class of everything i want to learn!!!!

  • @emjaytripleo
    @emjaytripleo 2 ปีที่แล้ว

    But in a stateful app, the server still has to use cookies to authenticate or recognize the user, and when you meant we have to hit the db every time to query for the token, it sounds pretty bad, but isn't that information also cached somewhere to tie in with the cookie expiry, because if were to really look at it sometime a single page might send around 20 to 30 requests to get different information from a stateless backend(REST) but it cannot afford to authenticate the user 20 times right ?

  • @girishtiwari79
    @girishtiwari79 4 ปีที่แล้ว +1

    Wonderful explanation

  • @JoseBlanquicetM
    @JoseBlanquicetM 3 ปีที่แล้ว

    Hi Hussein, thanks for your channel. I really appreciate the work you are doing on this.
    For this video, I would like to know if in the case of stateful app, is it possible to use an "intelligent" LB such that the requests for a given user go always to the same server. In this way we can also have a cache into the servers for their users given that we know they will always use the same one? Something like consistent hashing?
    Thanks!

  • @vinayaksharma-ys3ip
    @vinayaksharma-ys3ip 2 ปีที่แล้ว

    Great video!!! Thanks a ton Sir!

  • @psstream889
    @psstream889 ปีที่แล้ว

    Your explanation is far more better than my college lecturer

  • @harshad.j3216
    @harshad.j3216 4 ปีที่แล้ว

    Nicely explained in simple way... with real time login application use case scenario.....

    • @hnasr
      @hnasr  4 ปีที่แล้ว

      Glad you enjoyed it! I made another video about how Amazon Alexa is stateless maybe you will enjoy that as well th-cam.com/video/zhwMv5RxGew/w-d-xo.html

  • @solracthegreat1002
    @solracthegreat1002 3 ปีที่แล้ว

    You are a great teacher many thanks!

    • @hnasr
      @hnasr  3 ปีที่แล้ว

      I try! thank you so much for your lovely comment

  • @KrishAgrawal
    @KrishAgrawal 4 ปีที่แล้ว +6

    Sir, you really explained well. I am a 9th-grade student and I was completely able to understand what you meant.

  • @stevenhumam2589
    @stevenhumam2589 5 ปีที่แล้ว +1

    Great Vids and Great explanation , Love From Indonesia

    • @hnasr
      @hnasr  5 ปีที่แล้ว +1

      Steven Humam thanks! Much love to all my Indonesian subs you guys rock!

  • @kevinmontalvoflores6614
    @kevinmontalvoflores6614 5 ปีที่แล้ว +3

    Awesome video, I understand most of the good points of stateless, I guess making a web application whether a session is an important concern but not important at scaling we probably would use php session as a way to maintain the session or any other programming that gives us this set of tools. but regarding the we wouldn't scale horizontal, thanks man

    • @hnasr
      @hnasr  5 ปีที่แล้ว +1

      Kevin Montalvo Flores exactly well said. It is a trade off that you as a software engineer/architect make.

  • @mukulkopulwar
    @mukulkopulwar ปีที่แล้ว

    Thank you for this

  • @sagarshekhar6296
    @sagarshekhar6296 5 ปีที่แล้ว

    Excellent explanation Hussein.....

  • @ore_bear8045
    @ore_bear8045 3 ปีที่แล้ว

    very good explanation, thanks

    • @hnasr
      @hnasr  3 ปีที่แล้ว

      ❤️

  • @zenkindo4144
    @zenkindo4144 2 ปีที่แล้ว

    best teacher man.

  • @naderreda2020
    @naderreda2020 2 ปีที่แล้ว

    Great..... Thank you

  • @sg7809
    @sg7809 6 ปีที่แล้ว

    love it..explain so clear

    • @hnasr
      @hnasr  6 ปีที่แล้ว

      Santosh G glad it was clear to understand! Thanks for your comment

  • @emadelhori496
    @emadelhori496 2 ปีที่แล้ว

    this is amazing channel

  • @arioafrashteh6767
    @arioafrashteh6767 ปีที่แล้ว

    If you replacte the DB and using the same DB replications for the same Microservice replication the statefull-problem will be solved?

  • @NagendraBabutoecrusher
    @NagendraBabutoecrusher 6 ปีที่แล้ว +2

    Good Explanation.. keep up the good work :)

    • @hnasr
      @hnasr  6 ปีที่แล้ว

      Nagendra Babu thanks dude! Appreciate it

  • @user-dd2ux8wb4c
    @user-dd2ux8wb4c 2 ปีที่แล้ว

    What if we just store the stateful session info in a common distributed cache (in the first example)?

  • @OhWord88
    @OhWord88 4 ปีที่แล้ว +1

    Your explanation made me feel really "cool" and "lit" because I was able to understand this 😂 Definitely giving this video a like! 👍

    • @hnasr
      @hnasr  4 ปีที่แล้ว

      Jordan Theisen Jordan you are cool and definitely lit 🔥 thanks for your comment!

  • @jksharma7
    @jksharma7 6 ปีที่แล้ว +1

    Great..... friend your teaching is very GOOD..... Thanks.

    • @hnasr
      @hnasr  6 ปีที่แล้ว

      Jk Sharma :) :) glad You like it! Thanks!!

  • @WaldoTheWombat
    @WaldoTheWombat 2 หลายเดือนก่อน

    so state vs stateless is just session vs token? What's does the "state transfer" in REST have to do with it though?

  • @ChHammadVEVO
    @ChHammadVEVO 3 ปีที่แล้ว +1

    Oh, man...Wonderful!

  • @gabriel-quintiliano
    @gabriel-quintiliano 5 หลายเดือนก่อน

    Great video!

  • @tkannab1
    @tkannab1 6 ปีที่แล้ว

    Great video! Thanks

    • @hnasr
      @hnasr  6 ปีที่แล้ว

      Toufik Kannab :)

  • @hantzleyaudate7697
    @hantzleyaudate7697 6 ปีที่แล้ว +5

    You’re the man! Great video my dude, the examples were spot on. Are you independent or do you work at a software company?

    • @hnasr
      @hnasr  6 ปีที่แล้ว +2

      Hantzley Audate thanks buddy for the nice comment! I work at a software company called Esri. I do these videos on the side :) glad you like the content!

  • @CoolBishop1997
    @CoolBishop1997 5 ปีที่แล้ว +1

    outrageously good l:D like it ! best way to spend my component afternoon at work on something ludicrous lol

    • @hnasr
      @hnasr  5 ปีที่แล้ว

      Imad Amahmid haha glad I could provide education and entertainment thanks for watching

  • @mostafahamza2228
    @mostafahamza2228 3 ปีที่แล้ว

    Thanks very much you are amazing

  • @sarcaastech
    @sarcaastech ปีที่แล้ว

    Done ✔️ thanks for knowledge 🙏

  • @josephvictory9536
    @josephvictory9536 17 วันที่ผ่านมา

    Well explained. Just watched another video on stateless v stateful and this was my exact question: Wouldnt the ideal be tokenization with API? It seems like a cache has the same issue unless the cache itself is just another word for intermediate database. Thank you for clarifying that this is exactly the case and how this can be accomplished scalably.

  • @gauravvijan03
    @gauravvijan03 5 ปีที่แล้ว

    Very nicely explained thankyou...

    • @hnasr
      @hnasr  5 ปีที่แล้ว

      gaurav vijan thanks for your nice comment sir! Glad you enjoyed the video

  • @ademtepe2855
    @ademtepe2855 3 ปีที่แล้ว

    I know stateful but I'm new to stateless concept. I have a question:
    What if I keep session data in a shared service (like Redis) and all of the servers can reach it?
    Is it possible and if it is, isn't stateful a better choice than stateless?

  • @aatifnazar8203
    @aatifnazar8203 3 ปีที่แล้ว

    Somebody please help me understand this concept. If we have a stateful application and are using load balancing with consistent hashing then that would solve the problem of failed viewProfile request or not?

  • @syedshahzaibzafar2422
    @syedshahzaibzafar2422 ปีที่แล้ว

    great explanation

  • @Saurabhandsonu1994
    @Saurabhandsonu1994 5 ปีที่แล้ว +1

    Correct me if i am wrong; if use jwt for session authentication(secrets on server itself) i wouldn't have to make so many calls to db(as when using session keys), making it nearly as efficient as stateful?

    • @hnasr
      @hnasr  5 ปีที่แล้ว +2

      Saurabh Agrawal that is correct. JWT is better than session keys, JWTs has signature in them allowing server to quickly verify it Without hitting the db. They are also still stateless because the client sends the jwt with each request. So you can restart the server and the client can hit completely a different server and still be served .
      With session keys (what we explained in this video we have to verify the key by hitting the db)
      Good question

    • @hnasr
      @hnasr  4 ปีที่แล้ว

      Check out my JWT video JSON Web Token with NodeJS & Postgres Crash Course
      th-cam.com/video/T0k-3Ze4NLo/w-d-xo.html

  • @mdarifhossen
    @mdarifhossen 5 ปีที่แล้ว

    Excellent!!!!

  • @pswalia2u
    @pswalia2u 3 ปีที่แล้ว +1

    Great explanatio I think nowadays JWT solved the problem of querying db each time we make request.🤔