Stateful vs Stateless Applications (Explained by Example)

Поділитися
Вставка
  • Опубліковано 15 гру 2024

КОМЕНТАРІ • 316

  • @nikhilbalwani5556
    @nikhilbalwani5556 5 років тому +160

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

    • @hnasr
      @hnasr  5 років тому +9

      Nikhil Balwani im humbled ❤️ thanks

    • @ShoeibShargo
      @ShoeibShargo 2 роки тому +4

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

    • @adamgontiersa78
      @adamgontiersa78 2 роки тому

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

  • @zencollector
    @zencollector 3 роки тому +11

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

  • @souravskr
    @souravskr 3 роки тому +3

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

  • @ruixue6955
    @ruixue6955 5 років тому +56

    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. UA-cam should support MD for comments. 🔥🔥

  • @John845
    @John845 3 роки тому +4

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

  • @hnasr
    @hnasr  6 років тому +28

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

    • @sasg87962
      @sasg87962 5 років тому

      ونعم ابوعلي

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

    JWT changed the world!

  • @matthewspiteri482
    @matthewspiteri482 6 років тому +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  6 років тому +7

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

  • @anonymous.youtuber
    @anonymous.youtuber 4 роки тому +25

    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

  • @vishwaskaupvijayananda3900
    @vishwaskaupvijayananda3900 4 роки тому +8

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

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

    with stateless you can read the token with your secret token in server to get basic info no need to search in db or any temporary db in each requests

  • @JungJ1ung
    @JungJ1ung 7 місяців тому +1

    stateful : 세션변수 이용/ 서버에 저장
    stateless: 토큰 사용

  • @shubhambatham49
    @shubhambatham49 5 років тому +13

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

    • @hnasr
      @hnasr  5 років тому +13

      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!!

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

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

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

    Your explanation is far more better than my college lecturer

  • @raghuvardhansaripalli9636
    @raghuvardhansaripalli9636 4 роки тому +1

    Hey Nasser, your video is simply superb. Hatsoff. As your voice is BOLD and STRONG, one thing i visualised you as you will look like "Vin Diesel". By seeing your DP, then i realise you. Take a Bow.God bless you....:-)

    • @hnasr
      @hnasr  4 роки тому

      Raghu Vardhan Saripalli Raghu 😍😍 thanks my friend

  • @shreysom2060
    @shreysom2060 4 роки тому +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

  • @claushellsing
    @claushellsing 4 роки тому +4

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

    • @hnasr
      @hnasr  4 роки тому

      Enjoy 😊

  • @ack377
    @ack377 4 роки тому

    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

  • @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  5 років тому +1

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

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

    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.

  • @mukulrana1616
    @mukulrana1616 2 роки тому

    This is the best explaination on youtube

  • @nageshsingh2330
    @nageshsingh2330 2 роки тому

    I am from Electrical background still understand it, nice explanation with diagram.

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

    Great video Hussein. Thanks for the example.

  • @muhammadinshal6216
    @muhammadinshal6216 3 роки тому

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

    • @hnasr
      @hnasr  3 роки тому

      Appreciate it ❤️❤️

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

    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 ❤❤❤

  • @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.

  • @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!

  • @parvezmulla3324
    @parvezmulla3324 3 роки тому +1

    your channel is a gem!

  • @Barrosy
    @Barrosy 3 роки тому

    TL;DR: Stateful is basically keeping track of the state a user might find itself in (good example would be whether it is logged in or not). Stateless is using an alternative solution (for example using a token response solution) instead of keeping track of the state of the user to keep things scalable (especially useful for example when running a load balancer set-up). The latter often goes in hand with a lot of caching on the back-end side of the app.

  • @pswalia2u
    @pswalia2u 4 роки тому +1

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

  • @potomskazhu
    @potomskazhu 3 роки тому

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

  • @Xardas_
    @Xardas_ 2 роки тому

    It's no longer over my head. Thanks

  • @alexanderkinyanjui3339
    @alexanderkinyanjui3339 3 роки тому +1

    15 minutes ago I couldn't properly articulate the difference between stateful and stateless. Now? I might upload a course on Udemy. :))

  • @samuelshoyemi3751
    @samuelshoyemi3751 3 роки тому

    Plain and simple. Thanks Hussein

  • @BehzodSabirov
    @BehzodSabirov 4 роки тому +3

    Nice explanation, but I'd add that stateless apps can be less costing if some caching is implemented between the DB and app servers.

    • @hnasr
      @hnasr  4 роки тому +3

      Correct! Just make sure to add logic to invalidate the cache

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

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

  • @EnochMaheshsilva
    @EnochMaheshsilva 2 роки тому

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

  • @0x37rays
    @0x37rays 3 роки тому

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

  • @denishsubedi3180
    @denishsubedi3180 2 роки тому

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

  • @onlyamitava
    @onlyamitava 3 роки тому +1

    You explained nicely.. Thanks a lot.

  • @srinidhikulkarni1962
    @srinidhikulkarni1962 3 роки тому

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

  • @lolokj6848
    @lolokj6848 4 роки тому +1

    Best explain ever..Many thanks

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

    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.

  • @OhWord88
    @OhWord88 5 років тому +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  5 років тому

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

  • @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.

  • @mohinimadavi5870
    @mohinimadavi5870 4 роки тому +1

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

    • @hnasr
      @hnasr  4 роки тому

      Thanks for the sub! appreciate you dear enjoy the content

  • @abdelrhmanahmed1378
    @abdelrhmanahmed1378 4 роки тому +1

    great video as useful but i know that LB use algorithm like Consistent hashing to ensure that the same user will enter the same server to get benefit of stored data in the cash rather than resend all the info again > iam right ?

    • @hnasr
      @hnasr  4 роки тому +1

      That is Correct if your app is stateful that it requires al requests from client to go to it then yes LB can use sticky session algo or iphash to make sure all requests go the server

  • @harrygeorgiou8518
    @harrygeorgiou8518 3 роки тому +1

    Very well explained! keep the videos coming!

  • @noranhany8213
    @noranhany8213 3 роки тому

    Thank you for simple explanation

  • @tranphunguyen7044
    @tranphunguyen7044 3 роки тому

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

  • @girishtiwari79
    @girishtiwari79 4 роки тому +1

    Wonderful explanation

  • @romanleca4969
    @romanleca4969 5 років тому +6

    This is outrageously good. Thank you, mate!

  • @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 :)

  • @hnasr
    @hnasr  3 роки тому

    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

  • @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
      ua-cam.com/video/T0k-3Ze4NLo/v-deo.html

  • @franciscogaxiola9450
    @franciscogaxiola9450 4 роки тому

    Good. I think the same way a token is stored in the DB and queried by all instances of system, a sessionID (localStorage of any kind of native app local storage) can be used with the same results in computing cost. The main PROs of using stateless is regarding to JWT, a way to validate tokens by the information it contains itself and not by querying the DB. Sessions ID and Tokens can be managed the same in backend and frontend, but for exposure to any client/platform, JWT is the way to go right now also because its granularity about granting specific permissions. Thank you.

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

    Such a great explanation! Thanks

  • @rohitrai6261
    @rohitrai6261 3 роки тому

    good info. but it is actually possible to scale horizontally with stateful applications. I have done this in the past using a load balancer and sticky sessions. You can use sticky sessions to redirect the user requests to the same server that already has the session for the user.

    • @hnasr
      @hnasr  3 роки тому

      Correct, you can scale stateful apps for sure with clever logic. However if that server to which the sticky session is locked on is restarted the application breaks.

  • @augustonapuri3152
    @augustonapuri3152 4 роки тому

    What if we use Sticky connections in the load balancer ? Could it work properly if we scale Stateful applications horizontally ? Putting aside eventually crashes on servers that may not occur frequently.

    • @hnasr
      @hnasr  4 роки тому +1

      Augusto Napuri that would work and would scale nicely. As you said if the server crash the client will have to login again since they will hit a new server.
      Another disadvantage is if the server is overloaded and latency dropped as a result its difficult to move client to another server in a smooth manner.

  • @migueljurado6783
    @migueljurado6783 3 роки тому

    Just amazing explanation bro!

  • @luls9000
    @luls9000 5 років тому +1

    But how do you store Alice's token without changing state? Wouldn't the difference be that the state changes on the client instead of the server?

    • @hnasr
      @hnasr  5 років тому +1

      luls good question! The client is transferring the state (token) all the time with each request and the server does not hold the state it merely connects to the database to check if the token is ok.
      So if you truly think about it our entire system is still stateful by the way because we are storing the token (state) in the database but our application (hosted on server1/2) is stateless. The client is of course stateful because it holds the token.
      Any layer that holds a state in its memory or disk is called stateful. While our backend app doesnt hold anything so if you restart it we can still work just fine because the client will always send the state to us. Thus the state transfer in REST.
      Hope that helps :)

  • @zacnetic3103
    @zacnetic3103 6 років тому +1

    Sir, I am just about to start my second year at university, with an assignment to develop a web application and, after watching your videos, I believe I have a higher status than God. XD Jokes aside, honestly, thank you so much!!!

    • @hnasr
      @hnasr  6 років тому +1

      Zacharias King thanks Zach for the love and comment! Best of luck in your assignment!! Take a look at the other content of the channel, more cool stuff for you! Cheers

  • @fajartris
    @fajartris 4 роки тому

    I enjoyed it, simple and clear explanation.,

  • @MelbourneSamurai
    @MelbourneSamurai 3 роки тому

    Man, you are a perfectionist! Prepare the slides beforehand! It drove me crazy, watching you constantly resizing and moving stuff around!!!

  • @emjaytripleo
    @emjaytripleo 3 роки тому

    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 ?

  • @vidyakrishnan1757
    @vidyakrishnan1757 3 роки тому

    15 mins of awesome ! Thank you !

  • @jingao1383
    @jingao1383 3 роки тому +1

    It looks like the only difference is: Stateful: save the session info in service. Stateless: save the session info in 3rd party component, say database

  • @user-dd2ux8wb4c
    @user-dd2ux8wb4c 3 роки тому

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

  • @georgesmith3022
    @georgesmith3022 4 роки тому +1

    Load Balancers can redirect the user to the same server usually by using a cookie, otherwise LB would be useless

  • @mukeshsinghrawat474
    @mukeshsinghrawat474 5 років тому +1

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

    • @hnasr
      @hnasr  5 років тому

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

  • @viniciosantos
    @viniciosantos 2 роки тому

    I finally understand this! Thank you

  • @harshad.j3216
    @harshad.j3216 5 років тому

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

    • @hnasr
      @hnasr  5 років тому

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

  • @ylu423
    @ylu423 4 роки тому

    For the stateful example, if the client uses a cookie and the server stores a session token in DB, I think we can solve the problem of horizontal expansion?

    • @hnasr
      @hnasr  4 роки тому

      Thanks Yuan, yeah if you kept the session in the server memory and also stored it in DB you will be able to scale.
      I am assuming you will validate the session again the server memory first? (Some sort of cached data structure that tells you who is the user )
      If the session id doesn’t exist in the server you can hit the DB and cache, if it does than all good.
      sure works, the only limitations now is that if the session is now invalided (manually removed from the database) you need to also write some logic to invalidate the session from each server that cached the session. There are ways to solve that but you just need to be aware.. another stateless approach is to use JWT (check out my video on JWT if you are interested to learn more on the topic)

    • @ylu423
      @ylu423 4 роки тому

      @@hnasr Got it. Thanks for the detailed explanation! And also thanks for all the videos, I surely learned a lot!

  • @minhajkhan504
    @minhajkhan504 16 днів тому

    Geniussssssssssssssssssssssssss! Excellent Explanation Hussien, the best! Thank you so so much :)

  • @WaldoTheWombat
    @WaldoTheWombat 6 місяців тому

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

  • @joshuawalker7375
    @joshuawalker7375 2 роки тому

    Very well made. Thanks for the explanation.

  • @ducdatnguyen9251
    @ducdatnguyen9251 4 роки тому +1

    very well explaining, thank you man !

  • @sagartyagi2450
    @sagartyagi2450 3 роки тому

    Amaaaaaaaazzzzziiiiiiinnnnngg. I think we can also use some cache like Redis, to do this soft authentication.

  • @swapnilshingote8773
    @swapnilshingote8773 3 роки тому

    I mean what part, those 203 people disliked this awesome video , did not understand... Loosers

  • @vinny142
    @vinny142 4 роки тому

    Authentication is an excellent example of just how silly webdev can get.
    In a statefull application you logon to server 1, that server checks your credentials, records your loggerd-in status and you get a cookie that refers to that state. This is considered bad because server-2 needs to share some storage with server-1 to know if the cookie is valid and who it belongs to.
    In "stateless" application you logon to server-1, that server checks your credentials and gives you a cookie that that server-2 can also verify as being authentic (like a JWT). The problem is that the state that is received by server-2 *MUST* be verified against the same database that server-1 used to create it, for the simple reason that the user may have been denied access since the token was created. You *MUST* verify.
    So, statelessness does not really change anything from a serverload perspective,it just sneds bigger tokens because you need to use something like JWT. The hardware on the server side is identical, withidenticalproblems that, let's face it, are not really problems at all. Replicating data among databases is not an issueunless you are a gigantic websitewith hundreds of servers but by then you will have heard of sharding.

  • @mcuve105
    @mcuve105 4 роки тому

    What about storing the session in redis, and all the server instances reaching looking for the session. I mean redis is a cache as well but it can persists

    • @hnasr
      @hnasr  4 роки тому +1

      Sure that works, in that case your app will be stateless but the whole system remains stateful

  • @joaorsalgado
    @joaorsalgado 6 років тому +1

    Cool video. But got me thinking a bit. I am not sure I am completely with you in here. Please correct me if this is wrong: the difference in your examples is only the fact that in the 1st example you cache the value in server1 while on the 2nd example you don't cache the values, you always check the token against the db. Isn't a more 'stateless' example a scenario where you can rely on the information on the token to do the validation (jwt)?

    • @hnasr
      @hnasr  6 років тому +2

      João Salgado that is correct, when I mention stateless and stateful in the video I was referring to the application that is hosted on the servers. So in the first case my application is stateful (cant scale) and in the second case my application is stateless. However the entire system still has a state which as you mentioned its in a database. Building a real stateless “system” is very hard because most of the time you probably need to store your state somewhere. Thanks for your comment!

  • @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!

  • @MASTERISHABH
    @MASTERISHABH 4 роки тому

    What about using JWT to avoid DB calls at every request for validating the token?
    This keeps the stateless architecture intact by also covering its downsides. Doesn't it?

    • @hnasr
      @hnasr  4 роки тому

      True saves you couple of db hits but there are limitations to JWT that I talked about here
      ua-cam.com/video/T0k-3Ze4NLo/v-deo.html

  • @tdias25
    @tdias25 5 років тому

    i think i got it, in a nutshel, stateful means that the server store information about that "session", but in the stateless the token doesnt have to be saved also? gonna read more about it, great video btw!

    • @hnasr
      @hnasr  5 років тому

      Thiago Dias That make sense, you can watch the new video about the same topic with examples. ua-cam.com/video/nhwZn6v5vT0/v-deo.html thanks for your comment

  • @cw5948
    @cw5948 5 років тому +1

    Excellent explanation! Good job.

  • @zenkindo4144
    @zenkindo4144 3 роки тому

    best teacher man.

  • @slim617
    @slim617 3 роки тому

    this video is best played at 1.5x speed to make him sound like he's talking regularly.

  • @Hammadshaukat-w5p
    @Hammadshaukat-w5p 3 роки тому +1

    Oh, man...Wonderful!

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

    why store the token in the database? isn't the point so that you can decrypt it using some secret stored in an environment variable so that you can verify that the token came from you (and not tampered with) and thus you don't have to query the database to give access to protected resources?

  • @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?

  • @NAVNEET549
    @NAVNEET549 3 роки тому

    That's some cool explanation.

  • @zzzzzzzzzzsh
    @zzzzzzzzzzsh 3 роки тому

    You are one of the best I've ever followed but I think you've missed something in this video.
    The matter is not about where to store the data (in memory or in DB or in a file or whatever the place is) !! It's all about, DO YOU STORE IT OR NOT for next requests handling purposes?
    If the server can process a request without relying on an earlier request then it's STATELESS. If the server needs information from previous requests to be stored (in memory or DB) in order to process the current request then it's STATEFUL.
    REST would help to understand that since it's stateless. It sends the STATE of RESOURCE (which could be a USER) within the request every time without saying: "Why I should send it every time. why not just set it in a DB and things will be fine and stateless! 😅"
    I think, as a monolith application, no way to not be stateful but as a microservice, you could have one service that is stateful (for authentication and authorization) and other services are just stateless (pure business logic and the state of that logic will be sent through REST or whatever).
    What do you think? Do I have a point of view?

  • @MrPkmonster
    @MrPkmonster 4 роки тому

    Hi, I still don't understand the stateless application. At first, the user sends a request to Load Balancer. This request may be passed into server 1. Server 1 sends back a token to the client. However, how can the server 2 still understand the request from the client? The server 2 doesn't know the token that belongs to a certain client?. Correct me If I am wrong. Could you explain this process again. Thank you

    • @hnasr
      @hnasr  4 роки тому +2

      Because Server 2 will query the database to understand if the token is valid. so the application doesn't store the state in itself but is stored somewhere else (the database) that is why we say the application is stateless but the system remain stateful.

    • @MrPkmonster
      @MrPkmonster 4 роки тому

      @@hnasr Thank you so much for your great explanation. Now I fully understand the stateful and stateless system. In summary, the stateful means the Server stores the information of the user by itself. Stateless means the server doesn't store the information of the user, but I still can understand the request is valid or not based on the token (which is saved somewhere).

  • @verma-kunal
    @verma-kunal 3 роки тому

    Really beautiful explanation !! Thank you so much

  • @solracthegreat1002
    @solracthegreat1002 4 роки тому

    You are a great teacher many thanks!

    • @hnasr
      @hnasr  4 роки тому

      I try! thank you so much for your lovely comment

  • @sagarsawant3955
    @sagarsawant3955 4 роки тому

    Hello Sir, I am fan of your video. I have one question if I have to use the stateful service there is multiple servers how do we sync the information across different machines?

    • @hnasr
      @hnasr  4 роки тому +1

      Sagar Sawant good question, the common architecture pattern is to use a centralized caching node such ad redis

    • @sagarsawant3955
      @sagarsawant3955 4 роки тому

      @@hnasr thank you for prompt response. I am big fan of your video's

  • @NickelCityPixels
    @NickelCityPixels 2 роки тому

    What's the difference between a token and a cookie? Why is a cookie considered stateful and a token stateless? Is there no record of the token server side? By what process is it authenticated then?

  • @sivanagajyotsna
    @sivanagajyotsna 6 років тому +4

    Explanation is good. Thank you .. Would you mind clarifying my doubt ? is this concept used only for a Web applications ? or any Services ? Sorry if its a dumb question.. As I am new to the dev, curious to know. :)

    • @hnasr
      @hnasr  6 років тому +2

      Jyotsna Doddi good question! No it applies to any kind of service that is consumed by many clients. Whether this is on HTTP or raw TCP or any other protocol. As long as the service is consumed via a client, each request should be treated independently from previous requests.. hope that helps :)

    • @sivanagajyotsna
      @sivanagajyotsna 6 років тому +1

      IGeometry wow you are quick in responding ... thank you for clarifying...

    • @hnasr
      @hnasr  6 років тому +1

      Jyotsna Doddi :) i try my best ! Checkout the other content in this channel if your new software engineer