Main

Cookie and Token Authentication

Aditya Baxla POD: Okay, the service that filters and pushes the events to Consumer to call Produce it but producers will be the so ...

MAD II

Streamed 13 days ago

yeah today we have a session planned for you basically for authentication cookie as well as token based authentication we'll be looking at but before that let me ask do you have any doubts any wants to clear anything this topic is of week eight yeah this is of week eight also this is very important for your projects as well that's why I wanted to take time to cover this as well and apart from that the later on weeks we just salary as well as redus remaining so which content we work uh will be to
day today it's we content based on week eight so next assignment deadline is today right for week n yeah so if you look yeah so week n we all the activity practice questions as well as practice questions all are based on Theory itself so I think you might be able to do it yourself because there's nothing much to explain uh on those things regarding the Concepts that is right but this token based authentication sir has covered in Saturday's session token authentication right we did cover it is it
authentication right with the database and everything for storing the uh hashing the password okay hashing salting everything you have covered right so that was what I had prepared you with so discuss something about week n yeah week n uh okay we can do that and also we can look a little bit of what I had prepared as well so let's do both then let's do week n uh little bit on this Activity questions as well as little bit on how like the I think you might have done in detail right the all the to
ken based as well as cookie based authentication token based we did okay so we'll just look at cookie based authentication and then let's do the this week n AQ thanq all right okay so uh I want to ask one thing so in your session so the front end and the back end were done differently or was it like together so in the back end only were you serving the web page or you were connecting the front end as well as back end okay let's go and then uh let me just show you sir one uh one out of this uh th
ing question yeah actually how do you run this uh any program here okay so I mean running that Local Host uh terminal whenever I try to run it it just goes to the local file not that as a server live live server what how you run right mostly this is live server so what setting you have to do for that live server setting sir so live Ser what we use yeah just click on run yeah maybe some yeah yeah live server something so I generally use this live server extension what when you do it like make HTM
L here and run it on right click open with live server you don't run like that run on the command that run window is there which command no no the top run menu right menu is there right yeah this one yeah here also we have okay this is for directly executing a script so suppose you have a python script so to directly execute that this is that okay okay yes than actually sir I had uh uh doubts not I mean not exactly I don't have confidence in the mutations and everything right I just know theory
part and only I I try to execute the codes in my machine uh but I mean I was not able to run the way you guys are running here so kind of you're not confident in that part anyway I I'll bring it to you afterwards okay not now yeah thank you so let me just uh show you a little bit about cookie authentication a very rudimentary form of uh this cookie authentication okay all right so I'll just make a so just in case uh any customer they use some certificates instead of this token and everything so
can we Implement certificate also in this thing yeah there is certification right but I'm not sure how to implement it so you'll have to go search how to do it but there is where okay and o also is there o yeah o yeah o is like third party authentication so when you see login with Google login with YouTube uh sorry login with Facebook and all those things are using o so that is basically handing over the authentication to Google or any other third party that you handle authentication we don't wa
nt to so we can in the URL from here also from our application sir those URL those URL mean I mean the the third party Ur like is talking about so launch not directly you have to embed that code into your program and then you can use that login with Google login with Facebook okay okay okay thank you yeah so let's uh just quickly make a VNV and then let me run this okay so sometimes what happens is Microsoft does not allow this script to run so for that you'll have to set the execution policy an
d then now you can run the script and that means p uh flask right so yeah here we have let's make a app Pi so what we uh what I want to do here is basically have some Roots like login SL login and slash something else like restricted or maybe let's have movies so this movies will be restricted unless you are logged in and this thing will be handled by a cookie all right so you did U did you do JWT J web tokens or did you do it using FL security to we used FL security to make like tokens and toke
n okay all right so that is mostly what we you will be following in your projects okay this is you installed only flask yeah right only flask so this is only through cookies I'm doing okay so we'll need last I also need this request and make a response okay make a app and then have some Roots so let's have a home root in which you have a get method okay so here I'm just returning some this is home the stateus code of 200 so this is the this is unrestricted basically so anyone can view this and t
hen we'll have a login as well as log out okay so let me name this Lo so what we'll be doing here is grabbing the username and password from the form which was submitted from the front end username will be so we need request here request do forms. submit form. submit uh dot yeah get and then we'll get the username so this is dependent on what the name of the form is submitting so we'll make that form as well as well as a password so we grabbing this and then we are checking if this password I'll
make a user list users in users and users at add the current username equal to password so I need to make this so instead of doing it in uh in a database I'm just making it here as a dictionary make it T1 and P1 okay so let's make a response in which we can say log in okay and then the main thing here is response. set cookie so what we are doing here is whatever response we're giving we are setting a cookie here so this cookie ideally should be a string of like a basically like a token a random
character which has some authentication built in but since we are doing a very rudimentary form of this authentication uh I'll just name it user okay so the key will be username and the pass uh the value will be the username itself so you can understand how bad this is so anyone can set their own cookie to a username and then check so this is a very bad form uh right now how we have implemented here so never do this is just for demonstration purposes and then if this is the case and then we'll
return the response and if if we did not get the username correct then we'll return something else incorrect password or username and then a status code 401 or 403 okay so this is a login uh let me make the log out as well so the log out will have similarly make a response response is logged out and uh status p of 20 200 that is correct and then the main thing here is we are setting the cookie to empty so this will empty out the cookie and then we'll return this response so we have a login log o
ut and we just need to make some restricted data so that will be our movies okay so let me here also make a me methods so login will have only the post method okay and then we'll have def get movies it should have some D some data so I'll just make it as a as a list okay here so we'll just check if this cookie is present or not otherwise we will say that this uh it's unauthorized okay so it's simple username we grab the username uh from cookie so request. cookies has the list of has the dictiona
ry of all the cookies key values so we can get the user name from here and then if this this username is in users then we'll send this data so I need to import this as well yes ify the movies database movies okay else we'll say it's unauthorized and a status of 403 okay uh did I run it no F name equal to main then let's run after run with dbug you can you show the key value pairs which one which key values the the user one user has just one you one people okay simple enough the only thing we did
here was response. set cookies we set cookie from the server site and to get the cookie we had so cookies are sent with every request okay so these cookies you'll get so you can have do get and then whatever the key of the cookie you wanted let me R it so somewhere I wrote method instead of methods okay H login Lo sorry uh Slash SL okay yeah and you can just go here so of course home we can see so let me go to movies so you can see right now it's unauthorized because of of course unless we have
the username in the cookies so that will be unauthorized so uh here we need some some way to submit a form so there are certain methods you can use so one method is using Postman but right now it's very simple so I'll just make a index okay and here let's have a form some action so action will be submitting to this and login so since it's a post request we need some method to send a post because directly we can't access the post method using the browser so I'm using this form and uh next up we
need some input the first will be a text type with the placeholder with username and name as well name of username as well s next we have password placeholder will also be password and type will also be password that it automatically start the inputs then we have a button let's name it login and then have type will be submit okay so I don't even need to open it using live server I can just directly open it U but let me just open it live server so user name let me just put a random username on on
e so okay it says this okay I did not send the uh I sent the type as uh the string query parameters I need to send it as post let me go back submit it yeah so it says incorrect username or password and next up yeah so when we put the proper username U1 and T1 as a login password so now it says logged in also I'll show you the cookies here so I opened up this applications tab inside Dev tools and the inside the cookies you can say this username has been set as U1 we said that we'll set up this us
ername as where is it yeah so using the response we set the username as the current username whatever was the username so here you can see we set the username as you want so this is going with every request it will send this cookies to the server so if I then go to it's very small how do I click on this second control l so if I go to this Local Host SL movies now you can see this Json data has been sent okay and if I wasn't logged in so let me just remove this I deleted this so now if I go to th
is uh I just use the keyboard okay delete button so now you can see it's unauthorized again you can just login okay you can directly go to login on 5500 okay so yeah in this again I'm logging it would do you have to change the form yeah what what would we have to change the form if the UR has changed this is running differently than the app. okay so this is form is like having the action of this the URL of the action yeah action is going to this app dop this is this URL is running anyways this o
n the bottom you can see it's running here interes so now you can see it's loged 10 now if I go to uh movies right movies we already saw let's see log out so when we do log out now we can't access the movies so all our functions are done but this is a very basic way of doing this so it's never expected you to do this kind of cookie based authentication so cookie based authentication itself is not bad there are trade-offs between cookie based as well as GWT GWT is being used a lot these days beca
use of Spas it has a lot more functionality but inherently uh that's not the problem the way we implemented was a problem so usually what you see is when you store the pass passwords so you put in Sol and then hashing and everything and then you check if the secret key matches or not then only you authorize it so even here you can do this also one more thing I wanted to touch upon is uh so this whatever we are doing is in HTTP right so HTTP is not a secure platform so all the data can is visible
over the Internet so if anyone wants to see this data it's on plan text okay so what happens if someone intercepts this data is all your cookies all your passwords everything is compromised so that's why currently we use SSL technology so that is https wherever you see that has secure security layer on top of it so that encrypts the data okay so this is uh very simple cookie based authentication and show you so next up let's get to aqq okay uh anyone has any doubts about that so so that was a s
imple cookie based authentication that information gets stored in the if this is in the local storage yeah it will be in the cookie but basically in the local storage only yeah so when we say like cookie dot then like store this data uh how does the like how is it managed like for example if any random person could post to your uh URL yeah this one you saying set cookie yeah set cookie like right now the server is sending it to the user but if any random person just replays it or like since thei
r own response to us like how does the browser just is the browser responsible for making sure it's secure that yeah so typically when you're using this cookie as authentication method so what you will have is a token being sent so similar to that JWT only but the thing is it will be encrypted using a security key of the server so if that if uh so know something yeah you did hashing last time right so using hashing you can set some salts right yeah so if the salt is different then it will have a
different hash value see but like what if something uh kind of uh took the cookies which are in our browser and then use those cookies to access as us yeah that happens that's uh it's called cross site request fory so that is why that csrf token thing error which we get that is what yeah so that's why some like there are certain methods that you have to follow using this cookie Bas the security doc says that it is like immune to csrf not sure exactly what it me right so when they make these lib
raries and all so they take care of all those things that's why it's typically better to have libraries instead of implementing your own login so even if you make a pretty big login it's just better to use uh someone else's already tried and tested methods of login right anything else why have we kept after username empty stream okay we are just clearing out this cookie yes wearing out but you okay wearing out as in removing the information yeah so we are removing this username from this key use
rname key so previously it have been U1 so it just cleared out that and in the above case we set the user value I mean response. make response do set this one right yeah yeah yes so this is the key and value PA right I mean yeah this will be key value pairs if you see it inside the browser so let me just go here yeah so here if you see it's like username is the key and the value here and then cookies has some extra things as well so it will just tell you what domain it was from the path as well
so you can mention what paths is this cookie valued in okay do yeah so if you give the root value so it will be valued across all the domain of this current domain otherwise if you give slash movies only so it will be valued only in that movies and inside that and you can also set expiration date so that's one benefit of cookies and even in JWT you can do that but that is handled by the server this directly expires in the client side itself this additional information we didn't add it in the we
did not add yeah so when it was uh when it was set it automatically got added okay so right now it's session session means if you close the browser this cookie will expire you can also have a Time based cookie expiration I think we did that sometime list um so you want to do the aqqs now yes so flask uh the default mode of this is we right yeah so default mode with flash server so basically what happens is uh in a server you can have many requests coming in right so let me just put it up yeah so
this is my back end so back end I have a back end and then you have certain requests coming from here and then multiple requests coming up so I'm talking about what is threaded versus non-threaded okay so what happens is this one request this takes sometimes it might take some time to process this right it's not just immediately it got and then came back it might do some computations on the back end and then give it response so until that time if it was single threaded non-threaded here it will
be this another request won't be able to this back end won't be able to accept any other request okay so that's why we typically prefer multi-threaded uh backend so it can have multiple requests being sent to it and then it can process it so by default uh you can specify what what you want so by default flask runs in a threaded mode so it can have like multiple it can accept multiple requests from different uh mult it can basically have multiple request at the same time accept multiple requests
all right so now we have which are the correct statements hello why option C can't bect first question first question credit mode and config cannot be changed no we can change the mode of uh this flash server config here means uh um config is basically what like we can change the config in order to change it to threaded or non-threaded okay so in non-threaded mode it will until it process is the full like until it gives the response it won't accept any other request in thread dead mode so is ma
king a web server threaded threaded as simple as just changing the config or we have to do anything else no nothing else is as simple as that okay also if the load is too much then we have other methods as well like like message cues and all which you have later on here yeah so next up we have uh question number two so concurrency is achieved using context switching in single core environment okay so anyone has any idea what this is saying what concurrency is achieved using context switching yes
sir so what happens uh context searching is it's like you do one task and then you do another task yeah exactly so first you're using doing this task and then you're doing another task doing doing third tasks tasks so that is concurrency and parallelism is basically doing everything at once so you have to have physical CES in order to do parallelism for concurrency you can only uh you might even uh do it using one thread so so even in one thread you can do one task at one timey is basically the
appearance of doing multiple things but then parallelism is actually actually doing the multiple things right exactly so in concurrency what happens it it does not complete the full thread it just goes a little bit of the first task then second task third task so that goes on so the second option is false in parallelism multiple threads can be executed at the same time on Multi processors uh next up which of the following statements hold true for asynchron asynchronous task in the back end so f
irst option we have they are usually used for to run asynchronous computationally intensive tasks yeah so asynchronous tasks on the back so what ha what happens is uh like you have used Fetch and all used JavaScript asynchronous see right so what happens it it offloads the task is something else so it won't block the main thread similarly holds true for backend as well so yeah so what happens is if there is something very computationally intensive you what you can do is when a request comes in t
hen you can handle it over to uh INR call and then that whenever that thing is synchronously completes then you give the resolve the promise promise or uh the response here so that is how you compute a very heavy task okay so second option first option is true it is usually used to run as synness computational intensive task uh it is possible to have one front end server and computation interest task are handled handed over to the task server and notified is in yeah so this is how you do by one
method so you have give it to this task server that is specifically made to handle this asynchronous task and then whenever the task is completed you notify the client okay so third option is the user clients only gets response back after the task is completed so does it make any sense this like so if if the user only gets response after the task is completed then the user won't know that your response that users response is actually processed or not is it working or not so the user might even s
end multiple requests thinking that the work is not yet started so what it happens what happens is uh this when the user gives uh request it immediately receives a response that this task is being worked on and on the back end this task gets worked on and then when this gets completed then the user gets notified okay like that email example Sor like when we when we send email it just goes to the queue and it is seeing sending when it gets sent then we yeah right nice example yeah so whenever sen
t email we immediately get a notification okay sent but actually some somewhere else that processing happens and it takes its own time right uh the next is web server and task server need to be implemented in the same language so basically these things are totally independent it only they interact through apis so basically HTTP calls they interact over so they don't need to be in any particular languages they can be in whatever language Imes they want there are certain end points the end points
are basically URL links where we interact with these either servers okay so these two are false these above are true next up we have what are the potential challenges of a distributed system so distributed systems are U like you might have seen that in classes so there is one distributed system okay so what happens is they uh they behave both as clients as well as servers so typically what we have here is a client server model typically in a client server model we have a client and a server the
server gives the responses the client sends the request so this is only like a oneway communication not a oneway communication as such but the client gives request and the server gives out responses so in a distributed system it happens uh both ways so even one distributed system can give responses and then have requests both ways so have you heard about torens you might have used it right you said some mov to distributions you can only download using toorent yeah so th that's a example of distr
ibuted system so sometimes what happens in Torrance is your once you download it or even while you're downloading torren so you actually what torent right right yes yeah so while you're down downloading as well as when you have downloaded you have option to seed the download so other other uh other clients that will be clients for you will get data from you while you're getting data joke on this right like be be a good citizen or something like Tor yes C and similarly that happens here as well y
eah so so what can be the challenges of distributed systems so Deadlocks I have not explained what deadlock is so what happens is let me just this so what happens is if if this distributed system number one this is dependent on some response from two but this two is itself depending on the response of one you're getting some sometimes this this thing happens and it's not very trible to figure out so even in in a huge communication this one is depending on some response from two and two is depend
ing on some response from one so both will be deadlocked so no one can go any further because this is waiting for two is waiting for one one is waiting for two that is a Deadlock yeah so that is deadlock uh this handling failures in real time distributed systems yeah so you can imagine in uh distributed systems things get complicated because sometimes your server itself can the one can act as a server and another time it can act as a client and then data is traveling all throughout from one to i
t's like a full web so it's harder to actually pinpoint as well as handle failures and distributed system and security is also uh an impact because like uh in a typical server client setup you can have a server which has a secret key and then like things like that you can have certain things that are not visible to others but in distributed systems you'll have to have more uh like more in involved there in order to do the same things so certain things that are given like we can have a secret key
in in the server so such things can't directly be done in a distributed system unless and until some different way of doing the same thing is done so a security is also a potential challenge of distributed system uh got it right yes sir uh deadlock like a wouldn't deadlock depend on the implementation yes yes it definitely depends the thing is it's not very easy to figure out where the Deadlocks are sometimes you just Implement a Distributive system and then a deadlock happens but uh it's not t
ypically like what I showed here it's like a whole web of things it's dependent on on depend on number 100 something even real life there are a lot of deadlocks like for for a shop you have to have a establishment certificate and for establishment certificate you need to like have a bank account so it's like for a bank company account you need the establishment certificate for the establishment certificate you need the bank account so like what do you do chicken and egg story so same thing with
deadlocks in the servers right or also it's not easy to figure out where the Deadlocks are in the system what about security sir security is like like typically you uh expect the server to have certain restrictions right so Ser server will have certain data that will be restricted from the client so suppose suppose uh your are Facebook you have a Facebook server right so in the Facebook server there's data of millions of people right so what happens if one person wants to access someone else's y
ou the server will handle it right it will say okay you are not authorized to access the second person's data but in distributed systems so uh what happens is if you're having a distributed system suppose uh I'm like I'm something into blockchain itself so let me talk about ethereum okay so ethereum is a example of distributed system the blockchain ethereum okay so what happens our data is stored in every each and every every machine so how do you actually make sure that data the person who has
actual access who has actual authorization to access that data that only gets the proper data so that is the challenge that uh some systems do solve it but it's typically harder to solve than a client server model in the client Ser model you understand the client will have certain uh like will not have the all the access to all the data but in a distributed system typically they have access to all the data but you have to have certain different different Provisions in order to lock that data dow
n to partical Clans understood yes so right everything's correct next up so next up we have message cues I'll just briefly explain what message cues are okay so what happens what happens so we have a client okay let's take this client only we have a client let's make it bigger Okay so client has a limited amount of resources maybe like 2 GHz processor I don't know how to write G okay suppose whatever um maybe four course it's not like a normal system okay so if it gets some computationally inten
sive tasks by multiple servers so these four cores will be blocked right so at like a Time 12: a.m. suppose at 12 a.m you have so many servers so many uh sorry I did the opposite okay these are clients and the bottom one is the server okay so you're getting at a particular time you're getting so much traffic here and this ser can only handle four course or has limited amount of resources so what happens is in that scenario you can have a message Q so what happens a message Q is another parallel
server this will be a message que so this will instead of directly interacting the server this client will tell the message Q okay I have this request so this message Q will hold on this all these requests so maybe this is a request yeah so this by given by client one this was the request okay and by client to the another request was there okay so what happens is the server can handle this request one and then it can give to what whenever the processing happens and then next up according to it c
lient to will get its request processed so what happens it it doesn't need to handle all the requests at once so it can have a message cue that can handle the like quick burst of requests so it will have it will basically be a queue first in first out it will go to the server and then handle it accordingly right understood the main uh main Mark of messageq Sir is it you is the setup used in production as well yes it's used is like I'm observing in Banks a lot of banks are complaining that uh I I
just went to a bank so they were complaining that the system is hanging because badge processes are running because of March closing so it's like even the the technology we have today is not able to handle the data which is in process right also the nft payment you know like they have 30 30 minutes batch processing every time that's why when you do any F payments it happens in 30 minutes intervals matches so those things are used very commonly and this message Q is a really good concept you can
have handle quick bursts of request and then handle it accordingly the main concept here is the message Q uh basically two of the concepts are very important so this Pro uh this processing of data should not take more time like it should uh this processing of data should take more time than actually going to the message Q otherwise it will be redundant right if you can actually process the data in the same time as you have uh went to message so why would you directly go to messageq why not just
go to the server and then get it processed so this the server processing must take more time than going through the message Q next up is the Q has to empty certain time like uh the it should not be like all the time the message Cas is filled it should have a certain lway that it goes and then empty at a certain time so basically to handle quick wor that's the main H here and message CES can handle any number of request messages right yeah it depends on how you're handling nothing has like unlim
ited requests of overow all that problem is still there right yeah overflows will be there but typically you will have it more like it will have more Q space to do that that is messaging Q so it follows last in first out approach right so oh sorry first and first out not last and first out so this is false yeah understood this is the first in first out right the first the client sent it it'll be here second client send it that'll be here yeah so it will go in that order only last and first uh fi
rst and first out that's why it's called a que next up sending of messages decoupled from processing of messages so that is the main gist of it so sending of messages should be decou from processing message the processing happens here and the sending of messages is happening other ways okay so the communication can't be synchronous here because you you giving it to messageq then message Q might take time right so what happens is the message Q tells the server okay when the thing tells the client
sorry tells the client whenever this message is processed we'll notify you similar to tasking okay so it can't be synchronous only sending of messages decoupled from processing of messages that's the correct one so next what is the benefits of uh messageq is scalability a benefit what do you understand the scalability first anyone answer increasing our capacity just every every parameter right so making it table to handle more request or more yeah more request at the time yeah just not more but
less also so scalability actually happens both side you can increase the capability to handle more requests more users as well as down as well so like Amazon has most of the servers these days have those benefits that you can when lots of requests come in you can actually handle it and then when the traffic dies down your server capacity also decreases so that is one benefit scalability so scalability how can message Q help in scalability so message Q yeah so more requests are coming so that uh
it can messageq can handle without increasing the server number of servers so that is helping in scalability Bat processing we already looked at like and all they do a lot of batch processing Suppose there are like this this message K filled and after a while all these messages get cleared and then batch processing happens and easy monitoring as well because you can see what uh what's the status of the queue how much the queue is filled what is the current status everything you can see in messa
ge is Q so basically all of them are the benefits here yeah so next up we have Pub sub messaging publish And subscribe yeah so it is known as publish subscribe messaging so next up we have we basically in this in this lecture we had different kinds of servers Sy systems so we looked at ask cues message cues Pub sub systems and then I forgot something yeah other things as well so in this we have uh known as Public Sub publish as subscribe messaging what happens is uh basically as you can see in i
t evident here so public publish And subscribe so what happens is there is a broadcaster which uh publishes all the data and the subscribers uh will like it's basically like a broadcast like a TV broadcast or dur dasan and all okay so what happens is the the publisher like gives out all the messages and the subscriber who wants to take the message those will take the message okay so what here what happens is the message filtering is possible on the subscriber so the publisher will publish whatev
er message they want the subscriber has the logic there that they want to take the message or not so filtering happens on the subscribers end so and the publisher need not be aware of the subscribers yeah so Publishers are generally not aware of what the subscribers are their only job is to publish the data you can have a lot of analogy between like radios and all so similar similar to that radio towers give out all the audio audio signals whoever wants to listen it they can have just an antena
and then have a listen to whatever was there in the radio channels so it's similar to that up sub model okay so next up we have certain questions what is Advan message queuing protocol amqp is uh Advanced messaging queing protocol even I forgot what exactly was it so you might have to look the messaging que only but then the protocol used for that that is okay they use custom protocols right I remember so in instead of using HTTP protocol that we usually use in the internet we uh this Advanced m
essaging Q protocol use a different protocol where you can have both way communication right so there are certain different things right now as well web sockets that's more standardized these days for two-way Communications yeah suppose like just like we are in uh Google meet that uses websockets for 2way communication so actually the old internet as in HTTP wasn't made for this two-way communication it was just made for this client server model that's why we need different protocols in order to
achieve the current state of uh internet that we have okay that's the for Server level Communication web soet are used yeah it opens up a basically it opens up a socket and then you can have both way bidirectional communication it standardizes messaging uh using producer broker and consumer what does it mean by it I think they mean this Advanced messaging amq amqp only so I'm trusty about this one not sure what the this means so it standardizes messaging using producer broker and consumer okay
let's so rabbit mq is the implementation of Advan messaging queuing protocol yeah that's correct so rabbit mq is one of the implementations of that so this was also correct it's standardized messaging using producer broker so these are most like theoretical based questions you won't be asked to actually solve questions on implementing these you just have to remember what these things are how what are the different types of models Pub sub task Q message Q distributed systems all these different k
inds of protols right uh any other doubts so sir are we done with the conceptual discussion like every week we discuss you know concept part part like VX and you know routers so I wanted to explain as with the questions itself so okay so like salary and that concept has been discussed or what just one no celery has not been discussed celery will discuss later on even I have not prepared celery so celery will be uh basically we'll be doing the whole coding part with celery that is more important
okay so that's pending yeah okay that will be done in the coming we celery and redis celer and redis so redis is an celery is an implementation of redis okay fair enough thank you yeah the celer and redus is the important things here right as well as Theory questions also you'll be asked those as well don't think that is not important yeah because it seems that 9 10 and 11 are more Theory oriented right right so these are more Theory oriented yeah contents are released yeah so can we say that VX
was still week only right right other weeks yeah other week we just have salary red as well as some security so so they they are not part of VX right no they are not part of from week three to week vux right week five no week three week three week three was normal view is no I'm not saying VX I'm saying that entire view view concept that started from week three right right week three to week view part has been care right yes yeah thank you sir you can continue yeah okay so we'll be more going t
o python as well as backend in these chapters 9 10 11 12 12 is nothing much 12 is mostly security and Theory based yeah do we have 12 sir revision right yeah we'll be doing later on some new Concepts are discussed there are certain New Concept but mostly Theory based uh none of the programming questions as such even in this week n also Theory week n this redus and celery is important especially considering in your in your projects you'll be using radius as V so here we have which of the followin
g is true regarding Point too messaging so Point too messaging there is one correspondence between messager send and messager receiver so correspondence uh one to one correspondence right so basically Sending message receiving message has to be a one to one correspondence so that is point point to point messaging you can you have these days everywhere WhatsApp Twitter Facebook so you can relate to it so one to one correspondences you send one message uh you send message you the other will receiv
e a message that is uh one to one correspondence each message is cons consumed only once right so each message will be consumed only once uh it's processed multiple times if it's consumed only once it doesn't uh it won't be processed multiple times the so consumed only on meaning like sent yeah like if you're thinking about uh like a client server yeah so as a server it's sent only once as a client it's only received once so basically consumed only once yeah uh and it's not processed multiple ti
mes uh next up the message sender must know the receiver that's right for Point too communication we need to know the receiver who is it right so this the only third option is false so next up we have redis modules so redis has lots of modules uh basically let's talk what exactly is redis first it is I can explain you without even this redis is a very high performance database basically so what happens is usually the databas is in your drive right your hard drive or ssds that's where your databa
se lies so what this R is people thought why not use Ram as a Ram or memory as a database so what this does is it makes uh the lookup very very fast right Ram is typically orders of magnitude faster than storage right so so the only not the only one of the downsides is so this memory what happens is if it's volatile right so if you lose power or lose some data so it won't it will be lost that is one downside of this in memory database but what you can do is have a layer of caching on top so just
using instead why not use like a redish database on top in memory on top of a normal database okay so this is like a hard disk suppose it's a hard disk so when you actually access you access data so this is your let's suppose this is your back end not back end let's call it so be full only let's call it controller maybe so controller instead of going to the database instead of going to the database it goes to memory U redis which is stored in the memory memory means Ram okay so if it finds that
the data is there itself it will quickly process the data it can quickly find the data and then give it to the client and if there is a certain like there are certain techniques through which this red dis versus database this in state happens so basically they have to be in state means they have to be certain level like have to be in the same state also what you can do is instead of storing the whole database in redish you can uh have certain data certain data that is more frequently visited su
ppose your homepage is very frequently so you you can have your homepage in memory so it can easily go to you can your clients can easily access that and then when they want an individual access then it goes through the database okay understood what redis is it's a very fast database which is stored in in memory so it's a it's like a proper database is is it like a dictionary or is it like a property it's a actually a key value pair but there are modules through which you can have relational map
pings even in redis on a very rudimentary form it's a key value pair that's it but uh you can have lots of modules on top of it to make it a actual database okay uh anything else about so as you can see here radius has yeah you were saying something so so does red function similarly as a as a regular database which we have in our uh local storage I mean in in our systems when we try to create a database you can but what you typically do is storage is uh like memory is expensive right so you woul
d have like 8 or 12 even in your computers you'll have 8 or 12 gigabytes of memory RAM and then hard disk you you would have one terabyte maybe more so of course memory is expensive so what people do is have the most used things inside redis and when uh there are things that are not much used that will stay in the database so redis makes a copy of the most used things in in the database so that can be easily served to the clients that is a typical use case of red is but you can use it as a datab
ase itself so that that is not a restriction so not every data gets stored in the red right yeah all the database but everything depends on implementation but that is how you typically use it if we want to store all the data in redis same as database then can it replace the original database yes it can uh there are modules and uh like softwares that do that i I don't recall which ones exactly do that but that will have to be uh memory should be large enough to store yeah one more thing is that m
emory is volatile so it's not a long-term storage so certain action certain like a power SE something happens then me memory would get wiped out so that is one problem of redis using full redis as in as a database so but for normal usage mostly Red Data would be the cach data right yeah right anything else no sir yeah so radius modules are all these things if you go through the lectures you will know so basically all these are radius modules radius time series radius AI graph SQL okay what are t
he different purposes of which redis can be used so you can answer that now cash obious example yes and then uh no SQL no SQL is not only SQL right so is it like SQL is also possible with this so it's actually a key value pair so not a structured database as such that's why we are saying newq database okay but if you find the implementations I'm sure someone would have figured out how to have structured database inside r as well so message broker even as a message broker you can use that so what
does red stand for it's a remote yeah remote dictionary server so it's like a dictionary key value P that's why it's called remote dictionary so next up so yeah so pull cues yeah so and I'm hard to recall P cues so pull cues are basically what happens even in P cues is typically I explained you how the message cues worked right you so you push data into the messageq and when the server has it it actually goes to the server in pull cues things happen a little differently what happens is the serv
er itself at a certain intervals it says okay now give me all the data you have inside your queue okay so that is the most uh difference between this message ke as well as p q so this uh yeah so we talked about this NF transactions that is an example of pull Q at every at 30 minutes interval it says okay I'll process all this data so all the data inside the queue goes in and then gets processed so this it's used for batch task together thousands and thousands of task will hand be handled togethe
r so that also increases the efficiency as well so my understanding of batch tasks is that we just have like uh tasks batched up in groups and then we do it really quickly in different like batches right is that right yeah that is correct why is that actually like preferred over just continuously doing tasks there can be multiple things uh one thing are the top of the I can say like suppose you uh yeah you can like group things together right so basically if you want to send some data to a parti
cular area you can group uh related tasks together so like deliveries gu yeah yeah so something like that but yeah so I think that is one of the benefits as well as I think other other benefits are also there so one other thing I can think of is like money transfers not exactly in this scenario I'm thinking of a blockchain scenario uh yes I've been doing a bit of blockchain right so what happens is there there's a concept so y we just go through it it's really interesting so suppose Alice is her
e Bob is here so I'm sending some money from Alice to work so this in the context of pull cues right I'm just explaining how can bat transfers be beneficial okay this is actually like an example of what badge task you explaining yeah so I'm just explaining how this badge task can be beneficial so here you're sending Alice to V Alis to some else Charly and then this guy uh again sends back to Alice in in like the same interval almost like maybe 10 minutes interval so suppose Alis sent um 10 Rupee
s Charlie send back five rupees you're getting my point so instead of computing Alice sending to Charlie 10 Rupees and Charlie sending to Charlie sending to Alice 5 rupes you can directly compute Alice sending Charlie 5 rupees so that is how things happen in uh in a based blockchain based transaction so so those transactions happen in uh like 10 minutes interval or something in Bitcoin so that happens so you can uh batch all these transactions together and then so so sir why can't we say just fi
ve Rupees is sent from Al is to Charlie exactly example of yeah 10 and five I mean yeah that was the example like instead of sending 10 Rupees from here to here and then 5 rupees here on our Ledger we can directly write Alis five to Charlie right so that makes the processing less like two-way processing is reduced ler yeah yeah that is just an example how things can be faster less processing yeah so all of the above are true for this p q what is the default Port used by ready server even I don't
remember what is the exact server let's check I'm guessing that 6, because everything else we used okay right 8080 and then 5,000 next up we have yeah so next option is which of the statements are true it's not possible to achieve concurrency without parallelism false this is false so concurrency can be achieved yeah so single thread we saw an example right it can have concurrency using single thread as well uh it is not possible to write a synchronous program in JavaScript language false false
we always so many times we have used a synchronous code a process can lead to the creation of multiple threads that could be true can you give an example so like even like we are meing something right or the process could have like multiple fetch apis being called that on the back end might have you know multiple threads yeah so the simplest example is like every time we use async sorry every time yeah so every time where promises so the main thread goes on and the other thread is handled by so
mething else so when it comes back the main thread executes things so JavaScript itself is single threaded but when it runs on browser browser handles the threads so One Promise any promises are handled by another threads if they have another next disadvantage of point to point many to many communication between servers what are the disadvantage of point to point or many to many communication many connections that is true like n Square connections right scaling becomes very difficult in search a
rchitecture anytime you have a lot of interaction between different servers it will obviously become so scaling scaling might be difficult because like you have to handle all the requests from every server a of respect for Facebook after learning all of this right once you actually develop certain softwares you'll understand more yeah so there are many connections which are never used at all if you have different Communications so this is not true right this will also be true because if if a con
nection is being established between client and server then there has to be some point right I mean it must it might be used to send message or rece it might be but uh a lot of times false connection how can you create in know in the many to many communication false connection yeah you have a point actually yeah because if it is never used at all then U then that that will just increase the load on the server okay okay not sure about this one let's see yeah just the second one is definitely not
true right yeah that is there are too many connections is I guess just a bit too vague the question itself is a little vague they're asking dis advantag of both point to point or many to many Communications I guess we could take WhatsApp like person to person person to group then be right question seems a little vag though scaling yeah it's like typically better to scale in like a client server single uh single point server manner it's easier to scale in that it's mostly the load becomes more be
cause of so many connections that's the thing I can think of right now any other inputs not completely sure course we could have like point to point bya like uh you could do point to point via server or like maybe mesh network of some kind I feel like they are asking uh like an open connection like direct from right they saying between servers right yeah isn't like it's like torrent right no they're saying like directly like if you did like a TCP from the socket to that is that correct feels lik
e it I also thought that if it's like a local network and we are having they also mentioned between server see you than anyways feels a little wi let's see I think might have all of the above that I'm not very sure but it should be let's go for the next one which of the following statement is false redis uses rest protocol between client and server uh R you know so even in R say rest is a binary protocol that uses control sequences encoded an asky what is the full form of this radi relation prot
ocol it's the r itself is resp it's true yes I did not know R Us this protocol comm c server red server uses the port by default we already saw that this was true R was primary designed to be a message CU this was actually false yeah so it was primary designed to be a caching server okay next up we have which of the following are good in terms of better user experences the use of blocking non-threaded web servers of course blocking is bad because until one request gets completed you can't have a
ny other request it won't the server won't accept any other request so that is bad user experience right so this won't be true use of threaded service this is true do right next up the use of separate dedicated Machines of Performing is Computing intens tasks that is also good because you'll get the from the client side of you you'll get the uh confirmation immediately that your whatever data you wanted to send to the server has been sent now you'll get whatever notification later on that's such
so that is also true which of the following are general principles of task Q task Q looked at task Q pushing a task into a que should be faster than executing the yeah this was what I was mentioning yeah so if if the pushing of task was slower than executing the task then why not directly go to the server and execute the task there was no point in causing unnecessary over right next up there there need not be enough worker resources to empty the queue eventually yeah so this is one of the thing
s it has to have some like resource to empty the que eventually otherwise what is the difference between directly going to the server and waiting for it that is that overflow thing was being stated yeah like if you do not empty the queue then what's the point of the you will start losing information yes so this is false the it should be used for tasks which do not require immediate response yeah that is also true that's require immediate response so next we have regarding message cues it allows
different Paths of distributed applications to process message asynchronously any inputs on this you think it is true I mean message Q would not process the message but it allows the message message Q by the way of message Q you are having that a processing I mean it depends on what they mean by process they mean by process as like holding it in the queue then it would make sense but actually processing the message and finding the response that do not if it has mentioned asynchronously then I th
ink yeah it does the answer is correct like this is correct regarding message yeah that is the benefit like you can have asynchronous processing using different servers so are they meaning like we could have different like uh process servers behind and then this will just shuffle all the tasks to it through a load balancer I don't think about Lo I'm pretty sure it means uh directly is holding the messages and then like using different parts like different servers in order to uh process the messa
ge so it's just like a place where all the messes one message q and then having different task act on that different servers act on this okay that makes sense so there are different parts of message cues so have gone through the lectures or have heard about message cues so so the Q part are called processors what is yeah so the parts that cue the messages are called producers the parts that do Que messages are called conss Simple enough next up event driven architecture and event driven architec
ture uses events to trigger communication between decoupled Services all are basically Theory based only so if you have gone through the lecture you just L yeah so even I'm not sure about even D AR and I not seen the lecture but just by the sentence it looks right the first one looks right so trigger communication between deer services so what happens it's an event and then you when some event happens said drives JS we are doing that only right yeah for interacting with dom yes are decoupled ser
vices so when a trigger happens the communication happens basically so if you think about as an event queue and all so when the the call stack empty is the event queue pushes the next task similar to that the service that publish the event is called producer makes sense if it publishes have option three and four okay the service that filters and pushes the events to Consumer call producer producers will be the ones who publish the event uh service that filters and purchase events to Consumers th
at the producer will only be the ones who produce even I guess the router one makes more sense for filter and push filters and push called router this makes sense then we have Pub sub yeah so each message can be consumed by so publisher subscriber I told you right the publisher is like a broadcaster and subscribers so subscribers uh subscriber have the ability to filter out whatever messages they want so each message can be consumed by multiple receivers so that is true broadcaster the publisher
will broadcast messages and that can be consumed by multiple right so that one is true uh can only be consumed by one receiver that is false message sender may not know the receivers yeah that is the whole motto behind public publisher subscribers so messenger won't know may not know what the receive is and yet they can broadcast the messages I think one we did wrong yeah so in here we have like the point to point point to point or many to many communication all the so basically it's all of the
above I'll just check and clarify what exactly this question means other than that any other doubts there's like some accounts on Facebook are dment right and yeah if if I'm adding a friend and I connected to an account which is a friend on my list but it is dant their mutual friends will get updated right but it's not actually much use if that account is like not going to be used ever again so yeah makes sense if you think of it like that I guess here they mean more of they have to manage the
connection between these servers maybe yeah you'll have to manage as well as scaling like every time you're scaling one you will have to have more points of connection so if you're increasing The Connection by one also then you have to have end connections to that scaling comes very difficult Mak sense maybe connections which are never used at all yeah okay anything else no yeah so one General doubt yeah like I install WSL uh on my laptop okay okay yeah one thing please install WSL red salary wi
ll need WS I just installed because getting bored like anyhow uh when I was uh playing with the WSL yeah I noticed that it is having a different file system all together and even I can navigate I think to Windows things but everything I I think uh so is it that that whatever uh project I am using WSL for I should have it inside of the WSL F system not necessarily so let me see if I have WSL or not so I don't have right now but I'll just I can open the terminal of WSL from vs code but I'm not ver
y sure if the commands yeah so what happens is you can access your normal Windows File system as well so it's under mount uh so M so SL MNT and then slash your Drive name so just share your screen I'll tell you uh one thing I'll just share first please install WSL so that will be just go to CMD could you give a demo of yeah install say this even works in Powers shell but in administrator mode okay just type this to install I mean this will only install okay the font size is smaller I can't inclu
de it so uh it will be WSL double hph install yes so if you share your screen I'll just show you where the is so then are we supposed to install that VMware all those things also like virtu no if if you are installing WSL there's no need of VMware VMware or malware those are not needed no malware is different VMware you don't okay malware is definitely not needed right yes

Comments