You were saying wow. So unnecessary. Yeah. So and he's going to be late and he's going to do the final grading grading for all the projects. So let's do the same thing as last time. Why do we need apply this look at Enron strive to see how they handle various parts of the project. And then after that then we're going to go over best practices for how we handle those editors and reviewers missing on people. Are you guys up to date on what's happening with next week to. So I think the situation is Cancel class next week and then the following week I would normally be doing it again. You gotta guy Baja check would say he has he's going to take that class. So any and I will see you guys for four weeks I guess three weeks three weeks. Yes I think that's how it's gonna work. I don't think there's been any confrontation but we were all talking and that's the situation. Yeah sure. If if that is actually what it is and you will update when it comes So they think Hey brackets. Okay so it's a big mistake. I think I'll go try to address the seller to the index five traits authenticate. I get this error. So they traits like normally I can confirm that the cobra. Having tried googling the are you able to I guess. So for this particular problem. Undefined undefined. It looks like it's trying to reach out. To me CDPS. Address is trying to get to is undefined. So this is the object that's trying to get to this one here. Specify the rates have loss. You this I know I have this problem with my NACA. What did you just recently connected urine Turn off the Wi-Fi chip that I know that's a problem that I've had is like it says it's connected but like a page loading forever. I would honestly absolutely it because it's undefined for this hasn't been DNS lookup failed. 70 the canvas DNS servers. Out of a I just had to do I'm plugging in because E rm is fantastic all the time every day. Yes so everyone getting like groups of like three to five. Just find people around you talk about what she did show each other and talk about the web sockets how you handled the servers being on the same page because that's what we're going to go over today. And then he's going to talk about after this we'll have a break and we'll talk about Firebase and how you set up like full infrastructure using a Clouds writer Sarah Firebase it's good to know because if he ever built and 50.5% of time interviews with Firebase and then he's also going to go over I believe Google BigQuery which is like the Google data ingestion engine that can handle terabytes of data. Very easily Yeah yeah it is. Alright for plantae is horizontally scalable web sockets gray. And then I'm going to do serverless sacks and member functions. Next week we're not going to have glass. This is more or less because it's heavily. Alright And then Italy after we'll have I think a year civil swap orders were less so. So today any team projects how do you feel like okay who feel weird and a good way. Alright so then in earnest since nobody heals What what are the things that are holding you back and frustrating and send a health check aspects. A little. Oh. Yeah. Yeah. Yeah so getting VM to do writing this kind of over here in the office hours either as is And then making your image correct and getting that label Norway and whatever else and so on. We used process manager pm to make it so they don't like when I start up it's running right away or whatever else. But other other pain points. Leaving messages going. Yeah. Right right. So a storage database is not there. Okay alright. I think we said inspects them. There's a database that will fix that. I don't I don't think we expel sayings. But that's fine right but it's easy to horizontally scale with these Mongo. Pregnant change feeds. Agi is some database solutions and I can be a little bit last time. Because I thought there would be other pain points. I thought yeah Yeah we kinda drops down. Yeah. Yeah yeah yeah. Yeah I think that was maybe ambitious school re. Imagining a little further along. We use authentication role-based access control somewhere before we're done here it'll probably be in three weeks and he's engaged. So that's David authentication working Yeah yeah. Yeah yeah sir sir goal projects in a way is that this is an improvised classroom. We get a glass that has a very safe place to fail right basically domain. You're getting there. And you can get this done and check that box and a guy who I now know something very little scaling or whatever. And they say Hey Now the Bessemer. But so I thought maybe you know in JavaScript would be bullying people out because I don't know how I sense. It's a little bit creepy this bathroom popping out. On one of them is just being able to develop at all. And that's a fine on that. Because there's not really time. Here's a Muslim But then I forgot what you said being held. Okay was good constructive feedback. Because you're trying to Yeah. So I think that in a couple different layer one thing on ADD. But the other could be oh I got a socket. Number rapid connection or something like that. So I can roll your own LJ. Where is connecting the vein and say how many patients you have to do something. Which means that there's a connection to many many events like that. Or just a live album that they're young with a line. Or a four For some reason this does once said that the difference in CAD and manually change every server warfare is not a bad way. You'll engineering healthcare. Yet my or my hope nothing happens. I'll say hey DIY health check right there. Geysers involved with. Yeah yeah. Yeah. Yeah yeah. Yeah. So I had a business. He was a. He was a little place where startups are painless set in the VM. And then check from the mothership. Call me I could read it that way. A little obscure part of the documentation that I was wearing my office hours. And the one thing we're running into is we're getting the metadata back so fast that Google and assigned it an IPA theory like hardcoded it away right yes. And I remember having that nice during each IDS. Radicals like Curtis hundreds of comments away. Race conditions are all quiet last week. Oh I think our human **** there's when you create on the dot then there's you can listen for an event that says finished. And then on that that's what I call the metadata. Because when it's ready there's a difference between ready. Ready means like he ends up finished means like it's been assigned. Everything is connected. It's I think that's what it was is. It's not like part of the Cree is you can call other methods. Just listen. Yeah listen. Alright so and that's probably something that people may have been struggling. Event-based programming versus return base. Everything else in the school as return base. And Node.js is bound to event-based. Yeah most interestingly wafer. Yeah. So as the business just like the cloud. So that we're canceling class next week. What does it actually take nicely by asking them questions right so a mails or whatever else So 97% of the room feels anger as some sort of bottleneck point. Paragraph question like I met this boiling point for the people that have been emailing me like more or less consistently coming off. Because I've seen a lot of progress and so it was definitely in this. You're also maybe another ten minutes and do micro office hours now. And I guess data saying alright grew about memory Grupo and help each other through hurdles. All right how many of you are already in trouble with the hutch or biases a gray right how many of you are not and certainly without doubt. Alright. So how does that scale is not the way every way well maybe grassroot didn't go up Tell them about the problem that your article a little bit. This is with the way wrong. With you a little bit and jump around is awful but this understand rubber ducky coding debugging as where you have a rubber ducky yes and you explain rubber guy. What you were thinking what happened then was actually happening through line by line. He's laying on a share enough error that will help you figure out what went wrong. She's screaming curse. Words Yes yes. Whoever is totally Brazilian. Citizens tend to say okay I'm facing a problem or whatever else that talk through it with somebody else who's based in Zurich bowels. And you're all in the exact same problem cool Hannah. Grass. Holding ten minutes of interactive finishes. You'll face though. I think that's something that if you just say are wonderfully Look I can't my salary but I think last week or two weeks ago that you can show is that when you try to cyanobacteria because that's tied to them on a different response to it. I was watching the triangle the reasons. So you're saying like yeah right again centralist or that I would try it will be much satellite. Has done is actually try to mine. These passwords name such as Gmail. Yes. So these are definitely can harness et cetera. Yes I did it. This is basically. So using cross around silence. When you do the rest of the edges please check out what you want to do. Just that when you press already this one this is minus. So when you speed up your host CCI was revealed. And you notice that if I can be like this And just for a second the knowledge I don't like avoids kinda. Just go along with that we're going to be singing this eastward difference. So it's just for this. So now you're a rationalist Jim and sadly. Yes. Yes yes I should basically probably celebrities and agencies. And yeah so one thing I should change my sci-fi that I think it's like this is it says this guy's rapids. Now not only are all the other way around. I was like wow I listed as I'm saying that this is yes. Oh yes we centralize values. Obviously I knew I was running. And we're using those I'll say that since legalize Yes I think so. Somebody was supposed to graduate course. Given this fact especially those items like yes hearing I'm speaking quite. So it's policy away from your services. I'm just going to be. So unless wasn't just guess maybe for us. Yet I said well protected Yeah yeah. Seeing assessing the kind of master via. You guys have stress. Getting ca. Slash Take everything you've learned about as you're thinking about when it comes to express this. And this will just go in and copy that file and said this lady like consciousness That's right I'm able to just sit down and spins up here. So why are there so you can just drop these you can just be saying hello world whoever Aboriginal youth weren't housewives ice and then the name of the country. But you're just going to write stuff. That's your mouth. But I think you're right that always restarted. High-speed say that when you walk in a forest beforehand like settlers modify the code just like the person I always have a o or scream or I might want to call it the answer was yes. You absolutely certain that this has happened to me. Before I go to next APS handles we don't need this lens. Yeah. Yeah. Yeah. Before I like actually I mean I I smack here on Amazon planets I will just do nested brighter than silly. You wake up in the sky. Do you agree with me on this ESPN almost exactly by leaving everything in our director. Does thanks. I'll see you back here and then that list that you've now that's almost the same way that I think we read. Yeah. So so I might start now with a nice thing. There I the I am I decided enough I'm exaggerating. Yeah. Yeah. Yeah that's right. My husband said unless he's going to need accidents like there Mr. Bank will also tell us what is going to be lasers class. One class one. I don't necessarily want to make sure I got this. Definitely you might want to New York. And you do that. These families are saying Jeff Locker. Directed me said I just didn't like the jackals. Yeah. I feel like you just said yes he was invited human centered. Not just reminds us new packages. But yeah it's just like I just said. Yes absolutely. Yeah. Yeah yeah I'll check and see. Where we are Do you ever work yeah yeah that drove high channeling is presented. And how you can use that. First browser a 77 Yeah I don't use words like links to stuff over. Here you got the answer right so we've got one paper does VMs. You may have learned that. Absolutely. Yeah. Let's do that. Right we act as channels that sales process. So when it comes to the summation of this thing I want you to notice everything Per VM probably things like in perpetuity. So I'm going to ask that once he ends up working start the screen capture and show it to me working only for ways right but here's the thing. Here's me creating this thing checking out deleting destroying whatever blah blah blah and remember all optional. And then send it anyway just zip up any code that's interesting. And then it'll give you like the personal growth submission report. Now I will touch Canvas that's on my thing. So I'm sending email me this thing itself. Mindless Or I can get really honest having on people's apartments on VMs right so when you create the endings and destroys the service appraisal household file. At the time like your uncle or something. You got me like Google or other worried. Yeah I think wisely major outbreak. That's exactly right. So sense it is a big pain in this photo if you want to. But if it was actually very easy to push yourself very hard why don't you tell me about this thing that I really want to thank you learning. Works Good job interviewing Listen I know worthless. Thing. Again. Right here somebody. So here's where I think that issue is. Of course a mouse to surprise me. It was on. She's not like my students. You can flatten this waveform that waveform and everybody feel sleep deprived you wait for Yea running. That's it. This is dumb Asher right here. So if bn that wave or so it's like the zoned out VM and then eat that week right away and wait for we're probably so you're probably getting it in the provisioning stage and there's still a staging and then running Z. You probably want to wait for stopping. And when that event fires in the rest of the process equation then you get the metadata set the metadata. And as you know so do I think but notably degraded related here I'll send you. I'll drop this and chat. About what does a raft lunges your day I love the problems. Yeah this and it is another thing we didn't have this unit we'll just drop it. And this is the thing we're talking about with the time if a weight for weight yet. So you're you're probably trying to get data provisioning. Say he say yeah my sign. When I did my part tonight's lecture I'll show us all of this. I did this by waiting on ongoing environments. Somebody waiting on Firebase. Firebase says yes the doctor will the playing together. I actually like it more because it means that the node process It incorrectly and it's reporting through the Internet excuse me rather than you know like because the exact thing that caused you to be even in this is that you're trusting Google Google even faster than the IP address with you. If I get that through Firebase Of course a user can do something about the other things that aren't callback as a metadata objects. You may not even get metadata. Oh that's part of it. Might just click. I'm assuming it will give the metadata on running which that will be provisioning stage. You're probably calling it before provisioning finished because I bet if you do have one running and then the second part is metadata You can either IP that's cool. I've seen like data as your own dime network interfaces to access and plagues that opening things. Just young adults Jagger's progress there. Already take the computer to like AVI started. Certainly again. The first thing I would say probably the first if it's the first time it's been created or interest rate. Yeah okay so it has to be balanced credit thinking or worrying yeah exactly Andy. So daily on our on Alex and I stock sentiment but yet we're doing like 200 thousand writes and like 3 million reads to the fires or database. And we already have like a gig store it over just a few days. I shall bills are calculated and verify that. I am serious about turning that into a threat intel engine weekend. It's it's $0.18 per 100 thousand reads very sorry a 100 thousand writes. And there's no I don't think you get the cost for the reasons. I think it's just the network. Gossip is a 33 million reads a day. And I'm like 1200 thousand right today I thought. Okay I'll be back. Alright see you suddenly got 40 sensitized. Cool with historical time or probably ever topped out at like. It says. Wow Northern Ireland were destroying were absolutely. We calculated what the cost would be for an equivalent like Mongo Atlas instance and it was pathetic yet we assign more value to Firebase Well the real reason I would see going in Mongo if you either want to be cloud agnostic or if he didn't quotas pass fire store and you're like I can pay you any amount of money you need right give me 3.3 million read I awesome. All right now here's $30 thousand a month. Yeah like that. That gives a guy. But even then the tops out at four terabytes and Apple has a 146 terabytes in their Mongo cluster. Something like that. I would never I think databases the one thing each and ever host yourself. I would say out of all that republic. Even manage the databases the one thing you should host yourself. If you had to pick one thing that you'd put in the cloud. I would say database just because it's the most like you screw that up. Everything got. Any that to scale that and publish probably over y commute last presentation rubric. Why y'all that tendon is worthwhile Anchors your teacher questions please ask all email out the submission instructions now and by drop dead deadlines is heavily. By the way for Project Two because I figure we'll do two projects for project two. Here's kind of what I wanted to. Now for images that might be I think one of the when I talk to students who go out and end up working in companies or GE or architectures and things like that I say what did you want to learn it you didn't learn. They say basically like monitoring system. So and even we get to like the security aspect what I'd like to get you to do project two is have a make basically a monitoring dashboard so you can have your service your service from project one. And as users before give it even malicious payloads or try to ACA and or whatever. I want you to paying your or basically drop into one of these. What we call it a day of pipeline some sort of event and then have a dashboard that shows I events and how many connected users there are or whatever else or something like that. See look at your dashboard feel hot my cloud service running normally add or oh my concern is getting hit by all sorts of malicious attacks. And so this leaves something like Data Studio or Ivana to make pretty little graphics. But what we're really doing in the cloud side is that you you're going to end just like BigQuery or since we're like let's enter into a data pipeline is just like recording data stuff like that. That's an elk stack basically. Yeah. Yeah and a good way to do it. Think about like From the perspective of this project you know that from soccer the first thing you interact with is that socket that narrative that I owed on connection and unusual that a socket stuff I or that one connection is a perfect defense say someone connected that to the dashboard. So when that event yeah and and listen for a socket on discount up someone disconnected decrease account and stuff like that. So it's it's actually not that much more on top of this project. If you dislike Lay it on top of the foundation this project it's kind of like right now we take this product and make it really useful. And basically like you feel like addition because it'll be pretty but you didn't actually have to make them pretty stuff per se. And one of the goals I have every time I went to a class of any kind in this one in particular is is rapidly improvised. Is that you feel like you've got some sort of mastery like okay if I had to do this for real I can do it conceivably they get as Google or spend the next two weeks doing nothing. I can do it. And that you could possibly play the portfolio. So you go into a job interview and you're like hey I know this is entirely horizontal And the monitoring on everything else like that mean. Think that screenshot your beautiful dashboard is a light gas light thing. You're going to feel a ball or because like infographics just compel us as humans. And so nonetheless I think it's probably a good portfolio piece to do something like that. Right line cause. It's like. Yeah so basically we spent this whole projects. How do you figure out your own way to horizontally Love zombies by saying yeah right. One person thinks one server. One person to another server hadn't they talk to each other in real time. So basically hey cyclical saccades. That's how we make it horizontally scale. Well how do we go from say our little chat app where you have you know yourself and another tab talking to each other to like Apple where they have millions of users chatting in real time and i message and face time like that's a lot of data that says a lot of data terabytes per second. So how they send that across no matter where they are in the world in real time. So that's what we're going to go up. So first I want to describe why we use horizontal ceiling versus hurdles for web sockets and trying to make sense of what these two really mean if you're kinda just like horizontal I guess that just means more servers. It's not exactly that. So we'll give you like a wall of text really fast. Don't worry about reading it really. I'll read it out loud. And then we're going to go into like a real life example of horizontal versus vertical ceiling not related to computers. So just kinda explain horizontal. It's that's for microservices. So stuff that's like an instantaneous transaction web requests. It allows us to have high availability so we have a lot of surface area for multiple people hit us at once because we don't need a lot processing power to handle like a web request or a socket connection. Vertical seeing if anyone HPC endure with a doctor zinnias group right we run them together yet. So we admire because that's where that's where our vertical scaling it's perfect where you want a lot of compute power for something like machine learning for a task that's gonna take a really long time and you can speed up by having a lot of GPUs are really powerful GPUs Yeah you gotta think about science of horizontal. Stanley is for really short amounts of time when the compute instantaneous web request or connection or vertical thinking machine learning weather modeling AI. You know something that maybe a cluster could be used on but HPC clusters are pretty complicated. So now if you can just get one really powerful Virtual Machine run your machine learning on that simplifies lot of things is so powerful that for you want to go for a swim. So let's look at a real-life example. Imagine you're a business person and you have a hotel right and you want to expand it from your hotel to a lot of hotels because you only got one right so we gotta explain can't just charge more for hotel. The visited set is real life example of expanding hotel at a price that is grossly simplified. I just kind of envision this with me. So say you have a hotel that gay Hi it's nice asymmetric icon. But you want to expand your enterprise. Now you can either take this hotel this one property and make it really Paul said you've met a lot of people in the same building or you could build more paternalistic more properties build more hotels. So this is kind of the horizontal ceiling literally going horizontal versus vertical. So this is a pretty good analogy. Alright so let's talk about the pros and cons of building high vertical scaling this stays. So obviously it takes less space. You know you don't have to go buy one property is more or less a lattice based saved by shorted out. You can charge more for higher floors because you know people like to use. You can charge for firing less employees. You know you don't need to maintenance people for every building. Maybe you have three for one really follow that. But there's a lot of const model right Navy. In order to build this really tall building you have to first knock us down and then build a new one because he materials that were designed for really tall doing so they have to be lighter yet more structurally secure used to redesign the structure. So let's just say it cost 300 million. That's about what monarch resize skyscraper toss promote or are they just the good people at that age like I just asked Google Assistant. So also you have this many prices No one really wants to be on the bond. Let's return just has super cheap hotel and maybe you were a super cheap hotel at the inlet. Now these really tall or really high up rooms and you need to charge more for them because one you need to recoup your money from this really expensive construction unto. You probably made a nicer to compliment their NICUs. Yeah nationally and redesign the entire building. You can be in service while you're doing instruction. That's not possible with the hotel. Buildings that do usability wildlife construction is still happening Hadley And for deference and necessity. Since you building materials more expensive only so many people can be processed at the same time. You know maybe you have more people staffing the desk. Now maybe you have a bigger front desk but now you've got one only so many people can go to have the same sign. Fissile access some occasions think of that and the networking sense like how many people can go in and out single Ethernet port so cons list is very large unsure. Maybe I'm missing things. But let's look at building more on the horizontal scale. Right so back to you and more people operate. So you're going to have duplicates for every job because you need certain people certain job per building. Also if you have a problem in one building that was maybe a cause of design or construction. You probably have the same problem. Everything one-year notice out because it was something that was caused from something we didn't your building. And he also operational costs right because you know you're not going to save money by having one property or you're paying four times the property tax maybe you'll four lobbies instead of one. So now you're consuming four times electricity and lobby for higher duplicate employees across different buildings. So there's a lot of duplicated cos.. Well there's a lot of advantages right so say this was a 1 billion you had initially we built three more. Well there's no reason this machine. Yes sir. Well these are often takes a long time to make those kinds of buildings. So be able to operate well that construction is still going on. It was really beneficial so many nano service wire expanding. You can process more people simultaneously because now you have four inputs rather than one. And let's just say you know this small don't implement cost by new age. He built three of us it's 15 million maybe service the same and I upheaval as the tall building for 1.55% percent of cost. Something like that. You also have redundant services. So say electricity cuts out in your big hotel. No one in the building has electricity say electricity cuts out and wanting to smoke it sounds. Well aim would be civil to live every shift to your other assets. So there's redundancy narrative tell say for some reason you know inspection has to have in the rest of the yao. There's some sort of pests living there and are honest Biao. You can just move everyone to other hotels versus shutting down cooperation. And I'll say less physical access limitations. People are probably closer to essentially tell another one so they don't have to go as far additionally for parking lots for lobbyists even four times the operations. So why post hotels and we can see why you know normal hotels weren't that Paul. It's because horizontally salience kind of the obvious solution. You just want to handle people quickly because of hotels. They're only there for late night tonight. Do you want to process them night yeah now it's different from like Canada where you just build those things straight up So horizontal scaling is the obvious solution for web sockets. Now there's different methods. I think if you guys talk to each other we will find that there are many different methods that were used to horizontally scale the sockets. Because you initially think right Rob connect on the same server socket. So how do we get servers talking to each other well there's basically two models that are actually scalable to internet scale has a lot of people like to say and it just seems like no. Second like we can kind of just keep scaling as we add computers into the mix. First model I like to call the database got their hands on it. Why is this database got well your database is not only the database but now it's in charge of keeping everyone on the same page. So you and your clients say neural connected servers. The only way that these servers can talk to each other is through the database. So a good example of this would be something like MongoDB where you use a change heats. The Firebase Realtime Database fire store from Google Cloud platform. There's a lot of different products that do this similar change fees operation and the flow of power. This so client-centered message to their server over the left topic that might happen that server server that stores that message in the database. And then this database has it changed me. Now assess change that all the observers Dana fine they get the data a nascent. It's all their points four-step process and it just august spike through Davis. Now that's fine. If you're using like MongoDB Firebase fires or something that has since changed feeds. But what if you're using like MySQL post postgres SQL I'm I pronounce it. What if you're using another database you don't want to use that. So then we do make our solution abstracted from any specific kind of database because people use different databases for different class features. So in order to do that that's where the second method comes in. This is kinda the universally accepted method. It is called a publish and subscribe. And you'll see this is very similar to that standard web sockets explain basically keeping everybody up to date at the same time. So what does pumps up well you have a similar layout but now introduce something else called the broker. Clients all connected. The servers are all connect to a database. Servers are also methods. And the pub-sub brokers job is in charge of just exactly making sure everyone's on the same page. So BM says hey something happened of the burgers. There's okay ideally something happened. I myself everyone else something happened since like a website. And this is the flow right so quiet since it's the same game Yeah sir sores and messaging days since we're now. Also at the same time publish his message was hot. Way puffs up worse is you publish a message to its handling and then other people can subscribe to that topic. And me signing suddenly uses fry gets a events that says hey someone sends a message to establish hears that message. Broker would tell everybody. Subscribe said hey this is what had just happened. Maybe that includes the message that didn't happen go fetch it from the database. And then all the other servers you send clients. Let's hear these other means. They don't have to be the database they get that message. So it's completely independent of what database you use. Now reality would connect them to the database of baking getting data but for this flow it's not me. So you'll need to talk to the database to horizontally scale can emit this message to all the servers that have other class method. Now pub-sub uses a protocol called MQTT ensure HTTP as a protocol. Data transmission protocol MQTT was designed for talking like why is this stuff really really small. Like with HTTP you have all this data that you send back and forth every time web sockets. You only seen that once. But you certainly that initial large connection and HTTP is actually a lot of to process really slang. They pulled out basically every piece of data they codes make sure a web socket connection silver. And as a result it's Herve for 70 magazines satellite communications. So that's what's used. And we use pump syllabus software and different services Reyes Zheng. He Oh that guy you and then wildfires have variation Google has airliner as S and S which I think stands for simple notification service. And the way it works. Let me seven for a publisher. He kind of says message i. And then this is that sadly in his eyes he says writers CI right that's kind of a circular model. So some people's brains were circularly years. If your brain or inspire nearly publishers they sense. It tells us subscribers which has happened. See you can see how as we desire any amount of publishers publishing of a Saudi. And what's really great is Redis. For example hours really well Saya. Zombies nuance urea server and add these two eyes. And you just horizontally scalable web sockets. With these lies they made is you wire it effectively makes every namespace shape. So basically every instance of Ohio this they're all shifted version. So you and I do that Can I effectively do that iodine in every single server what's going to happen is is that there isn't a tell all the other servers. Hey I just submitted this. And they're gonna go. Okay clients this is what's just a minute. So it's really great to your second Redis. But going back you'd think alright well horizontally. We did this huge bottleneck right here. This is a 1 fed right well we can do multi-regional in cluster. So we get back to this. This is kind of the cloud-based clustering multiregional. So say for example we have people in New York City and you keep on Monday and repeat those same. And they all want to chat together. And we got to make sure that you know same for that's the other side of the earth right NYC that's going to be quite a delay going back and forth. So we want to make sure their servers and saint or as well that are also running pumps service so that we can bring everything close together and build multiple nodes so that we reduce that time. And this is where you get into why you pay cloud providers so much money. Do this for you. It's really easy if you sue cloud pumps or Amazon SNS or if you want to do a change they'd like thing and he's fire sort reminded me atlas. They do clustering you that database to which is really nice. I just ran this S from documentation on Google's Pub Sub on how they handle multiregional users and they said this is design SV and they italicize does not mean horizontally seal. Right cloud pulses load balancing mechanisms direct publishers traffics. So then nearest ECP days. And so they say I want someone publishes. We're going to find the nearest neighbor sang and push it to that. And when a subscriber request messages so when he makes that subscription it connects your server to dams. They all connect to them to our servers and has some handle sending messaging between the servers so they virtually make all those data centers one dataset for you. And they also store them as soon as you don't really have to worry about sewing. You obviously you want the database but you can go fetch historical pumps up stuff that interacting with the database which is really cool. So companies like Google and Amazon they candle the horizontal scale. But we can also do it ourselves. Mongodb is clusterable. Radius is clusterable rather than Q half of all the other ones I listed them all clusterable. It's kinda crazy to cluster them especially if you Google. And I'll actually do it after in the slides I'll show you what setting up your own cluster MongoDB looks like from their own written tutorial standpoint. It's like 60 pages long. I think if you like didn't like a print of the webpage converted its actual pages. So with all this technology you should effectively be able to scale anything right because with MongoDB clusters or just using a cloud providers pub sub model You just add servers on connectance that post. And they're just another piece that clients can connect to. You need to spin up more processing power or are you getting users in South Africa spin up a server in South Africa have connect to the nearest data center and now you just added really low latency access to your platform. Like puffs that drives the world. It's crazy. And we look at the quotas and limits on the cloud providers websites for like how much data you can pass through pops up and really how to feed to us. That's how everything runs Can you open up the dialogue about this because if you open up our course notes they've disrupted the link. Has a vanilla JavaScript local implementation pumps which comes more from the like classic design pattern idea known as needed just chat out laying out maybe some of the possibilities here when you go to like it. Because you know one of the thing You're saying it's kind of like your version of absorptive. Let's call it the industry version of the word but the word actually has an older narrative. Anyway. Example yeah I'll do in a second but first I just want to show you like Services Mongoose tutorial. And this is probably the best tutorial here and a lot of the closet. So this is before sharding and replica sets. It's like this long and then that's just like setting up multiple servers that run Mongo and they're talking to each other. Now you've got a set of sharding so that you distribute the data across them. So that's all this. And then that doesn't even handle redundancy. So one server gets smacked database it's gone. So you gotta make replica sets. So now you got to think yes. This is why we got invited one AU this stuff and they give us like 99.999999% uptime. In fact some of the Amazon services and there was a huge deal. The other day Amazon's DNS went down for like an hour. I think it was eight hours on their DNS service promised a 100% uptime so everyone can sue them there is great. So that'd be a class action lawsuit on Amazon were suddenly go up. If people get mad So this is this is done in the style of the original way design patterns book. Here this is just old-fashioned object-oriented code. This object is counting these objects subscribe to this object's number counter and they react whenever their favorite number wherever this is a multiple of their favorite number So this one's react every other times all the even numbers the sum will react with my three numbers. Multiples of three models by multiples of seven. That just means say like this also pattern which is little more complex than it really has to be because it's not it's an link old-fashioned vanilla JavaScript. It's more or less. You make your Hub. You've got your listeners. And when you go to subscribers gonna take it a callback and when the event happens you go to callbacks us. Right that's the essence of an entire pump something. So I want. Now To do this scattered across databases or like now let us do that. So I just want to also you probably still at this point what is the difference between Web sockets and pub-sub Web Sockets is more like real time updates between you and the server. So a really good example would be like getting a real-time count of people willing and diamonds. Whoa this is where I was sleeping sir in real time. So there's something stuck on time or not reloading. I think if we right-click Inspect Element network tab we can see that. And I reload it doesn't record. They must be using non Trinity probably you're not going to have 1 but this is just talking to the server and starting to whatever database they haven't. Real-time. Pub sub is two people connecting to a pub sub broker and they want to talk time. So the difference is server client. We want this in real time. That's websocket. It's always prefixed with ws protocols. Ws colon slash slash like you'd see. Http. Slash slash. Pumps is more like this is the broker. And these are the clients. And they want to talk to each other. But you know I'm sure you've encountered this when you're spinning up and creating VMs. I create a new VM Now how did the other ones know to talk to this guy we have to tell them that he's created but then it's like okay let me also tell him that he died and stuff. No we don't we don't do this. We have them all talk to this guy to be assumed never dies. Because we pay quite a lot of money to make a math guy and they all just tell him and he tells everyone else's connectedness. So the pump's obviously keeping Enron same page. Web sockets is more for keeping you and server on the same page. I think that's just a good analogy of when you should use pumps out versus usually when you should use web sockets and we traditionally is Pub 17 backend web sockets on the front end because web socket runs over the same protocol that everything else runs over runs over HTTP. So it's the same technology that we didn't have to change. I don't think that that time is anything different. Right like if I had three lines connected to the socket and be the exact same diagram. Right but that so that's yeah that's kind of web socket is primarily life So I'm just thinking the case I acid right we have. So if we have two phones connected there obviously web socket to the server but the idea is like your texting server and the server tells the rest. That's because we want to use this specific protocol like we want specifically use IM message. This is like I just want to let everyone know what I'm doing. It's hard it's really hard and I'm sure this is not the best example. I can think of popes that was done in the backend Web sockets is done when you're talking to the front and that's pretty much when you use either or you'll never use posssible They don't support like there's no IOS library for pumps out. Thank You have to use web sockets but there's a million ways the web sockets. Firebase you can do whatever. Amazon version. That is you could just do a web socket connection. You can get web socket libraries from NPM. So I actually think it's just that the arrows are one way in pups. So you hooking once and then after that you are now listening for a thing to happen with the coffee. So the reason I brought up my number example we can pull that up and then if you scroll down. Yeah I scroll down further. Celebrate. Another fans going to listen to the counter four and event. 235 or seven scroll a little bit too. They have celebrate function. So when they celebrated they said there's the happy. They actually are dropping messages in the console this whole time and they go back to neutral after 2.5th. So that so I think the essence of this thing is that every integral receive a payload from the back and this is what happens here is I think it's just that. And the reason it can work at scale is that anybody who's registered now I can do all the same stuff. I want to database sharding or whatever be like alright these are all people in the world and want to listen to this thing and I can distribute that. However I see fit and get like you're going to be connected to the broker that's closest to you or whatever else or something like that and make it even and say OK broadcast event fires off a function to fire here a function barrier function. One of the reasons perhaps that you use MQTT is because MQTT is a one-way socket where web sockets is forced to wet right I think that's the actual length. Now you can be a publisher and subscriber but you have to initialize twice. You have to say Publish and subscribe with website and you're like I'm always publishing and subscribing. Like we have like one of those like Wong at like you think of like a paper towel roll just like along one of those you're staring at each other right so tense consistency fellows Machines. Yeah that's one thing. Mqtt was designed for was higher liability It works really hard to make sure stuffs in order and that guarantees delivery. And I think that has less to do with MCAT distributed databases yellow. Yeah I think that's more on like specific implementations of pub-sub. So I kinda cloud providers try to making there's better than just running pub-sub on your own. Or like why. For example Rabbit MQ Are we going to do a hands on the keyboard I decided not to for it because it's just like a lot of cold faces watching me code. But like MQTT You can. You can like pained to support your own thing like you pay for free software because they make it so advanced. So yeah it's a lot of like personal implementation of MQTT. Mqtt built-in has a lot of great stuff has their own.org. It's an ISO standard z node serious edges. Yes small footprint. Yeah. Yeah that that's basically when you do like Google for example Google Cloud IoT. It's basically a library for linking into pumps up. Because when you look at some of the flows that they'd give you four in. Iot core to pop some like IoT Core is like we connected to Google Cloud Platform and paint universe runs through pulse. So it's it's definitely used for IoT. And I think IoT Core is used by LA. Philips Hue. Maybe they're using Amazon alone. I know one of the big lighting guys uses one of the cloud providers. Aws studies Because an interesting target for us and aka the keyboard maybe Google Checkout surgery. Like the reasons the valuable thing to pay attention to. I'm going to use this to clients when another version is called cuing. So you want to have a bunch of workers. And when you have a process come in have the next eventful worker handle it. And I say hey I'm burger one I've got it. And important would fail after a while you're like hey what are you still alive until you get to the next one comes in worker three grabs it. And then it clears that he would think like that. So as a body of an acute paradigm. So he wonders services or products and top-left SMS. Yeah yeah that's Amazon's version person and an end but they have a whole lot like. I've got a different web pages news split testing. I just never used in. No it's fine but they had a five there and his family. So they've got like Amazon services. Here all of these events bridge and you Essen The US I don't know is that he got this. Peg it almost feel safer work but. So maybe Washington demo videos civil services and go Simple Queue Service is probably marshal a cloud tasking. Yep. Spencer. Thanks bases on. Yeah yeah. Somebody centrality Google. Why I'm saying all right this may be a little bit on the passive side for us. To know that the paradigm is there we say okay I'm importantly services are really people or over hundreds of my own VMs that are spawned out forever because they're good at that now. And you want to have your VMs in line too like I know crack hashed password hash password fired off your VMs. There's cracking or whatever else is easy. Right okay and this goes back to that the event-driven stuff like we handle events not returns There's their big Charts. Google loves to make like I got to like zoom out to see it. Google loves themes was just like oh yes this is a polygon. The CLR whatever IoT devices IoT core every history books which then feed flow is basically their data engines you can manipulate data from different sources to look the same way. I'm kind of a muscle a staggered Mz and say hi I'm always like a 100 messages and then send it once and then weights like a 100 and send that all at once a big table. They have these things about data warehouses now. So there's there's or data warehouses Warehouses data warehouse. I'll take you guys through this part and that part of the data warehouse is basically a database. It's like pure reason to have this database is when I add the Analyze Data Warehouse exists on half of the database and it's like just against an analytics. So it's like you have a set of analytics from the database. And when you make something like reanalysis A protocol a data lake. I think I've heard that too. But I actually don't know if anybody. So cesspool of data. So that's just raw data. So you see yellow it's like it's like Data Warehouse without is under where else is this warehouse in my analysis basswood stuff like big tables for you guys it's been about an hour. Yeah yeah and it's been an hour and a half Memory and I feel like that it goes to passive the attorney your questions and it's like oh so that's one-way communication with the posts that database given. It's also listened well. So for the model like you hook in once and now you're passive person. So for this model of the VM the server would be in charge of both coalition and up to this. But you can also in theory databases living on a virtual machine that database can also be used. Unless the VMs talk directly to the English to the broker and the receiver. I mean bi-directional vacation right. Now because this doesn't Traveler he says publishers. So this guy as a publisher publishes server and he says as subscribers here. Now he does nasa subscribe. So he is here as it could be it could be two arrows anywhere they can give to. Somebody to classical model was the New York Times. You could say I would like to subscribe to the New York Times and now tomorrow and New York Times publishes you get copied as signing to you retain and when you cancel your subscription there's still going to keep on doing their thing but you stop eating your crop. But you could conceivably be also a writer or whatever and they're like hey I want to add some content what you put out there as possible for the VMs or changing the world. Yeah I think that it's a little bit pedantic relate with semantic labeling side so I can say I'm going to wear my hat where all I'm doing is listening for a thing to happen and you're saying we could also have a different had it where it's just like I'm going to need SIGIR of stuff and sell them and publish and how everybody. I miss. So Gaelic virtually separate that out. Either save me. I'm doing it. I don't really care. If the VM has the capability of publishing the New York Times that's just an important VM. Or you could also write. I'm the editor and the subscriber residents with websites your force can both behalf like. So for example I say to my city of your good what do we get more NB just yeah it's like it's like you're one or the other or both. Uri there's choose music. Okay push and that's why cities for IT because for IoT devices that never get updates from the server all I have to do is push out like cry honoring stuff and pushing out. And yeah how does just listening for they write it like this could totally be a sensor that's being up spin. So that Keith do they not directly communicate. Or is that like oh you started with a red arrow. Yeah I guess I guess what I'm saying is like the only way for me to write to that will lead to being a publisher broker or is that like eight documentation now so that the database is going to be completely out again. So it just somebody said if you were to take this column and duplicate it and then kill the cell phone and make it that database and make that red arrow. That would be fine with me Where I'm going to it's also subscriber that writes to do basically is it's not even what we do send messages over it but messages from IoT devices early Tang though never a kilobyte. It's like a number like this was my number for like how moist soil is that's like a few bytes. Conceivably you wanted. We would want to do is you want to use the pubs or broker is hey this was updated in the database like this was the spot in the database that was updated. If I dislike pasted a picture in you know maybe it's a couple of megabytes. I want to send that over pumps out because that's a huge chunk of data. You think you have a hose and just take a rock through the hose. It's not going to go Wellesley inducing cell service Hey and just paste in the new image. Data is go get and it'll say please. So pub-sub it's like an advent thing where I think and maybe that's another distinction pumps up is more designed for like sending events happening back and forth where web sockets is like you send data. So you wouldn't send a picture over pub-sub but you send a picture of a web sockets. And it's very soul distinct. Yes it's definitely very subtle but it's so important when you go at scale. So celebrate and yeah I wrote down 20 different words are things that I thought would be interesting to teach you in this passer teaches a strong word. Expose you to love the diagrams. So on my list of words I include the word IOT and probably won't do it but you can totally talk me until like IoT stuff being part of this class Really yeah or maybe even two were together after this. Let's reconvene in 07 sure. Yes every time I look at my phone there's notifications. Kugler. True. Yeah I probably muddied that have okay Oh yeah I got no problem okay because political class things and stuff. And so if you've got a real thing it's a real product and that's where it's useful Mm-hm already So I will do the exact opposite of the ****** lecture will have no pretty you know pretty content. But you will be nothing but hands on the keyboard. It's very wants allow pause. Okay so I'm going to teach you my favorite stack. And if you've had this in classes before you never quite this way. So I do teach this document with app security. But what I wanted to do cloud wise is basically the following link. I wanted to get you to the layout level of like microservices. So this is yet another type of architecture. By the way I'm going along to a debate conversation with the hashtag about goals and class records are bad and accountable that you know wiggly wobbly twisty tourney. And and I think one of the things that I'm passionate about and I think I agree like we both shared entrepreneurial Heart which is that most of the jewelry glasses and ********. And most of what matters is can you build ship and mass and use it and get it to evolve and improve their lives rightly improving lives doing. And and so like one of the things he said in that vein because he's worked in slightly larger companies and I have started with companies like 01 and you know my company's name via figures each grade as fine as huge as an actual full-time employee. Like today I had five fires to put out over lunchtime or whatever. It's like. Whatever like that small business but whether you're a bigger team and you have different goals and pick that I'm babbling but curiously entire adversely energetic But when he satisfied we do teach in the code which only asking for anything. We feel like the only role as an architect and not about to give more of that. But the reality is there's a million other roles out there that are meaningful like us engineer whose job is to listen to people and hear the pain points me like Hey when he did this what do you think you will something be here. Let's try it this way. Split testing analytics like like there's a million other roles or curriculum than getting already touching any of those things. Peck were Computer Engineering. Why is it that we're the ones doing this on computer science but our eye care. So I do it. This is a sign from from conversations about like what we could do in this class there's a million little roles you gotta do if you're going to make a successful web company including marketing and really business ideas or things like that or else and needle or architectures is when half of it. But this is a completely new architecture and I'll call it circles back. And and people will make fun of the word serverless back because it's like serverless stack is serverless like. We re bedroom browsers huh requires lesser Uruguay's a sheet semester. They play these massive numbers of servers. It's ridiculous to call a surrealist stack. The only thing that a serverless is that provisioning servers. So this is this is a way for you to not touch any DNS and how you can make yourself work. And to some extent it's it's such an interesting idea and it's relatively new Select the conference serverless architecture and you're just starting to spin up and things like that. I would've harassed and it's not. Basically I love it because as a small business dude I can start a company over a weekend get it up and running for free hosted nice way of domain knowledge things like that little ball service by first three clients would pay nothing. And then if all of a sudden the product takes off then once they start getting lots of people hitting that service maybe I start having to pay something that correlates extremely well with the actual probability of thing. Right this just tracks it but you're always in the Black Right and I like to do things that are always in the black because I hate having BC and it was something else that will machine or something I do it right like so if I want to build my company from scratch and have it scale with me whoever else is my favorite way to do it. Alright here's something I needed. In what we gave a form or provisioning VMs and things like that. That is going to help you be like massively scale. This is kind of the opposite. Where that one we added costs you $5 a month that like hurts my heart out. It'll pay $5 a month to pay a penny if that. And so what we're gonna do is have Little back-end servers that spin up into existence on-demand four milliseconds. And then I'm going to pay for the number of milliseconds that server is up and running and it'll dissipate into nothingness. So we will wake up like me sees. You guys tell me cease from moiety. Sorry. Don't expose him. Yes Brazil as a pocket discreetly existence. I say helped me open my mayonnaise jar the creature opens a mayonnaise jar and then it disappears for. That's a that's a micro service. So what news thing because one QTL URLs is made to last a 100 millisecond. And when you push which I've done and you say hey my mic and I want to live for tendencies and it just starts losing its shape. The whole system crashes. It's not made for that. It's made for a 100 milliseconds. That's a long and want to exist. On the microservices read it the banner was Mr. music. Oh yeah. It's so great. What a microservices. Yeah I've I've felt this in real life for real clients. Anyway so here we go. In the process is repeated scientist. Firebase stack raised by storage and identity my classes before. I've never actually used fires or cross I built. It isn't surprised that I have but not products that I built myself. And and basically here's what's great. Here's my goal. You guys can have a baby Twitter. Super ****** little baby Twitter that will exist served on a CDN a content delivery network distributed to 20. These are low with your own domain SSL cert in everything. You're going to have a real-time database database or you can store all the tweets every time a new tweet comes in everybody gets alerted and they update their screen without refreshing and whatever else and things like that. And then micro service backend so that every time a new tweet comes in you do some analytics on it and save it with something and then it goes away. Alright that's my goal for the time we've got together. Let's go. Head to firebase dot google.com or on a different link. Alright at firebase dot google.com I want you to go to console maker project storm a baby. I'm gonna do me six as service I think there wouldn't be the first uppercase S it'll just be Missy. That's Software as a Service. Nice mystics as a service fine. I'm not going to turn on Google Analytics. I totally could. Maybe I'm like machine learning inside their AB testing or you want to build like a crack app doesn't really crack and crack meaning like people who like to pay you money because you've tickled sudden instinctual lizard brain part of their need to level off. Which I say as if like other people have that but not me but I totally have a need to level up my little hero and pay the paid away and it's fine fine. Alright. This exists now you'll probably have a window that looks kinda like this on the side. Click develop database. And we're going to create a cloud fire store database in test mode. You just open yourself to be part of the Russian bought army. Sorry US east four does not have Cloud Functions Groans US East One It is are enough force. Once Virginia offered to do they don't emphasize it. Realized fire stores. They forced or source. I had five or is very engineered Firebase used to become Freebase. Got acquired by Google cleaned up its act a little bit. Anyhow. Tourism is really my favorite thing in the world. Yeah. This is like a secret sauce. I'm gonna go live. And Billy's while having a little baby four hour workweek causes the Muses web company that just makes you money passively in the background and this is your ticket. Just do one every weekend until something works. My wife and I to this side I quit normal academic path started companies until they started to work. Once he started to work I came back to academia on my own terms I would say **** you grants. I'm going to do what I think matters you know. It was young and naive and it's fine grants are great. Ok. Did you guys get this far mistakes as a service database here we go Fire store. How many people actually call it and they go in there It's a good name to get the right fire paternal. And I'm gonna make my directory called 10X. Six. You will have to install the Firebase tools. If if you're on a Windows device you've not been SSH setup correctly or whatever else or something like that Go to Firebase terminal available for Windows users which will give you a little Dockery thing that will not suck. Is that across button it should be. I don't know. That's right. You know like I think at this stage as a professor I probably should have a bunch of different laptops and just think testing my notes on every laptop. I can do VMs. I think I need a stronger laptop to run more VMs better. Rub this probably more course. Work works. Well C and E are path whose PowerShell. Powershell as they go A local agency because it does it. There were two as o. And from here there's nothing that is a surrealist paintings or anything. You might want to practice this with node.js install. Oh yes you don't have node.js install. Hmm. I've read about these family. I hear today's idea that or one summer summer. I can only keep HIV habits for one semester. It's very diverse swans. And in our case this has gotta be any Sacramento PowerShell PowerShell. Yeah Yeah. Well why should we be love you can do it for some other server. If you're going to do it from a virtual server it gets even CDR. Let me give you a link. This is not bad because it is the Firebase login and it works. But let me give you. You. If you've got a website that profit ninja slash class 13 these are instructions for doing it on a place where you don't have like a GUI Firebase log and it's gonna make a Huffman browser where I log in with my Google account. If you don't have that then you need to do which I don't know. I think I think if you get the Windows Firebase terminal budget says callback. Here I would almost rather you just install the Windows Firebase CLI than than go already. Or did you try to PowerShell line Firebase partners on privacy bargain. Today ampersand. Powershell. Cmd o like an Xcode terminal. Okay that's cool. That Xcode is the Mac product. Through G DO term helped me you know I mean yes Visual Studio or only Got it. Got it. But I want everybody to really humans right at some level. Okay. So this CFD after I think installing NPM from the power. Oh oh yeah. That's fair. That's fair. Yeah single-page atmosphere Has everybody got to the stage where they can see a list of their projects need some help getting their install Firebase login. Yes based on race. Probably you have no power. Now let's get. This guy had a permissions problem. In his permissions problem was solved if putting dash dash user in there like this. That command it'll do the job. That you're asking for more trouble later. Actually yes. Made that trouble. That's the cloud guy. Vms are cheap. Yes I saw that the minus one vulnerability ******* crazy. I I have it in my daily alerts. The SU two minus one vulnerability. Rose from 2017 Wait a minute. Performances making headlines recently. There's another one right below it. I was. Like yeah it's basically that. Yeah. Yeah. Yeah Here if you specify your user ID is negative one or kind of one off the overflow. Then it automatically resolves to you being rude. Okay. Okay okay Now everybody got cool. So make a directory jump into the directory and you and you make a directory like I did that by MQTT or whatever and then CD whatever 0.8 CDSS. Yeah so there must be some probably the last bit is probably oh yeah yeah yeah. Now type Firebase in it. You should try. Yeah oh yeah. Right minus one visa via store functions and hosting Storage is a free ESRI my pathway but through using the Mac and it is a little fudges the functionalist one it's hard on the back and yeah use the Google Cloud one you build your own. Yep yep yep. There's no silver bullet. Yeah this is if you don't have a back and use the fires if you'd like security rules and he's. So my goal is to have to pay $5 that's cool. About Google is my god. That's crazy. You will see how to turn this on and off the menu spacebar. Now select the project that you made earlier mine it is mass. And then I'm just going to bam hit enter a bunch. If it fails there it's because you didn't make the fire store database first. Now this is what happens when near me. I just hit enter booleq. Okay now I have something that looks like this and I'm all done. There. Yes this thing is Cool excellent. Okay so now to Firebase deploy. So we get a three in this micro lecture cool there's no. Everyone is free web hosting. Your welcome. Alright. Here is your first URL although you can point as many URLs so that as you would like My first terrible webpage here is this one right here. And that's a nice seeks as a service one a1b0 five dot firebaseio.com everybody's favorite domain then. I think they also bought like web app. So I think I'm good at hosting. Yeah they also have web app. So that's pretty cool. So I also have this domain name. Okay Cool but I set up domain names for these things all the time there and you just connected domain drop in some things prove that you own it and know that SSL provision you and all that stuff. So there you go that's on a CDN. Congrats you're welcome. Okay. Now the first thing we'll do is we'll go over to index.html. And honestly let's just kill it all. Drop in the crap I was making that made me ten minutes late. And then deployed. There is you're a terrible Twitter. I'll be guessed 123. This is my tweet. Tweet. Okay fine. Alright. Don't pack it yet. Don't totally hackable. That's not this lesson. Steal the database. In case you didn't have enough free fire store databases of your own. Now you can have mine Poland you got me I believe Brad's right okay so now I'm here is part number two. So free gift number two which is awesome is when your tweet thing bronze and you've got your own little URL and do your thing. You can go into your database and you'll see that you have a collection of tweets and each NOW tweet each new tweet has a little document associated with it with the crazy ID. And here's the thing. Okay you now have a fairly scalable. Database is Kind of sockets built in let me show you how this is pretty slick. They call it they are almost realtime database. This is the interesting part. So let's say this real quick why 49 This is me connecting to my fire store. By the way this is executing JavaScript right so the thing that you might consider you really IDE you would put a big red X next to line 29 within your head say Firebase is not defined That's fair fine. Part of the code I paste it in here was these three lines. When you are hosted on the Firebase Hosting they'll kind of automatically give you access to all the Firebase JavaScript libraries and the slick little on your glory way cool including an initialization function which will just initialize app. You can do this without this underscore business. If your host it somewhere else but you're going to have like longer URLs that point to some CDN. And then you have some extra aren't really initialized. Okay fine. There's other services you can reason is service use and another line like this or at least fires or with author Database or storage or whatever the other thing it is you're doing including messaging Pete. I don't ever use their messaging library is for like it's kind of like I bet it's pumps one of his design for notifications. So you can't you have to in order to use it you have to enable notifications all advice or let's just say you have to name browser right when Google bought Firebase they pivoted it from being a serverless architecture to being the mobile architecture. And so the idea is if you're gonna build a mobile app you're going use Firebase is your database and you're going to like push configuration changes. And so they have all this stuff centered around notifications and analytics as mobile backend which is cool I still use it the web way so you can't use their pumps pumps. Which sucks. Alright so let me show you the whole process of how this thing worked on line 30 is kind of my database handler. I don't I don't have. We written me. Dan wrote some code in lecture one that talks to an SQLite database. Name is Rhonda did and you did logo yeah you did long ago. You did the SQLite. I'm doing fire store Have any of our students connecting to database on their own but not in this class. So if you have it in other lessons You can actually database typically we're going to do is really point the database and you use some sort of hand right my handlers there online theory. So this is my tweet Sandler and it's going to be my final numerics and appointed the collection of tweets. And if you look in your database now that didn't exist right the first time executed this database was empty so I just invented the collection here in the JavaScript for the first time. Why 32 is the listeners. So this is my event. Listeners is kind of my income my web socket. You can call it something you could call it my callback register. For whatever tweets changes in a way. I'll give you a snapshot of the database. Yeah I watched a video on fire store that was in their documentation today. And they made it seem clear to me that while I get this snapshot it has everything in that entire collection databases. What was actually transferred from the cloud servers was just the changes and the rest of the write locally and hydrated needs art collection. So it actually does not take a lot of bandwidth. You ever ask them to be excited because like one time you hit it and then everything else after that if deltas which is pretty slick with them. Protecting us against ourselves great. This is the line that's interesting here. This is going to go through every single document in that collection of tweets. And for each one I'm going to take the JSON object I agree. And I think this is actually a security vulnerability here. Now XSS vulnerable as soon as I've said that my site is now being actively by people in the room. Right if you visit my site there's a good chance you are mining Bitcoin or something like that. Or at least an annoying alert box I hesitate to go back. Ok so far so good. That's fine. I'll sell facts just to. I'll say style background-color XSS verified. Ok. Take my morning class to figure out one Nexo. Here's a click listener button. I'm going to be amusingly. And this is just saying that same database handler before. And it's going to add to the collection this new object username tweet Cool. That's it. That's my entire database structure. You do this yourself you say good questions. And then intellection document a new question that document whatever. Okay so cool thing. Number two of three. You now have a web socket in database. There's exceptionally robust high up time We're going to lose your data from it. Along with free hosting all free you're well. Alright. Go build me Uber busy. Okay. So cool parts Realtime Database CDN hosting. Okay this is the part I actually wanted to say. So for the cloud passes the part that I think is most interesting. Because if you really internalize it as Walk homes and I ponder your life and what you're doing with it. You should bend Oh ****. Well I think I can do it break the Mona Lisa now like you should feel that way right so here's the serverless architecture. Part. Look go inside your functions. So CD out of public. Oop go into functions. Vi index.js delete everything. So it is carbon-based this function functions. We'll just replace index.js with this stuff. Now if you look the index.js before I made this change it had like a demo example. You can do this totally as a rest API also it will give you like an HTTP endpoint and you can hit it and it will have like a micro express server. They can just route the request and do whatever it is you want and then go away like an E6 it's just an ES6 Express server handle this request request handle die. And that's it. But this is the one that I will do. And then Firebase deploy. Exactly. Does this package functions or uploading of IRR function say little bit login Z Boy. If you guys have heard of lambda This is the Google Cloud version of that actually is the Firebase version of that. So I think identity has been whisk or something like that. Yeah opened with AWS land Firebase functions and Google Cloud functions called Azure functions. So Atlanta had advice like you know a temporary function that exists in line just-in-time pool. Hey it's Thursday night football. While I wait Thank you. Thank you. Alright I'm finally employed. When I go back over to my database and I take a look at the functions I'll see now that it has this check me function triggered by creation inside of the tweets whatever is illustrated on the right magic entry ID database k. I can click logs. Now I go to my Firebase app. Chartreuse yellow sin Excellent. Now I'm just going to tweet something else. Hi there tweet. Okay off error could not refresh access token. Let's double-check it worked anyway. Yes it did OK.. Notice the difference. So this one this one which was handled by my function now has size N1 Okay so not the most interesting thing per se but none of these other set of timestamp that one got a timestamp. Alright let me take a look at the code that did that. This one here is saying the oceans thing that was important at Firebase functions into fires whoever I wanted to open up this documents into each slashed VIE and listen for creative. Probably the strict documentation somewhere. I mean snapshot of the new tweets. It's where ID. Yeah absolutely fine sand which is just like saying since January first 1970 milliseconds whatever is sweet and reset. So I'm going to rewrite the whole thing with my anytime soon. By the way you do not have it on right instead of OnCreate would have created an infinite loops that would then be hey stop it and shut it down because you'd be writing which triggered the writing writing writing writing. That would go So if I want to share something that already exists or whatever I'm not here on Create essentially to avoid that instead for experience. Oh yeah. In fact right now I feel like a Google say hey we sat down. And I thought like well do I check the event and see what it was before and after and see whether we exist or something like that it MSU library. That's fine. Ok. But here is what that has done. This micro function that's going to take a look at it right if you've done your own tweeting on your own thing for now then you will have a couple of tweets in there with some timestamps and you go look at your functions. And you can even go to the little hamburger menu in view detailed usage stats. And you could see this function has been triggered a few times lately. I'm great. And you can look at the source and you can see what's causing into trigger and things like that. And what I want to see is how long does it last May off there. They even use a lambda token here. Shame on them. Alright adding timestamp function execution started at 0.0353 and ended at 3.2. So that ran for like 1.65 or 0.165 seconds in the Firebase console tells you oh. Good assumptions. A long time. Now on the right at 0100265 mils and skip. So this first line they had some series. Looking at my billing account. My money. It's a great. Okay so the way the billing on this works is that basically take your $5 a month for a fancy server and you say how much does this $5 a month translate into for a 100 milliseconds and that's the month that cost me which say just gives me for free. I'm injuries here great month. They'll just not do it too often. If stuff happens to us. Okay cool. I just ran one of these with Firebase functions for the client and tons and tons of people like logging in and doing stuff or whatever else Total Cost music tendons and she's not a whole lot of clients. Okay alright so Now let's talk for a second. Why should that made you think that you can go and paint the Mona Lisa now right so to speak like the equivalent of why do I call this now serverless that say I don't have a provision server. What does that function do for me well let me let me give you this next little task. Here's my steam valve. Make a profanity filter for me. So that if OR heck make a thing that's letting me know if somebody's trying to Acme. They're putting executable stuff you know and and locking. So adjust your filter there. That's not the right way to block. X is F my wife. But I want to know anyway triggered events started happening. So if I did this to make a profanity filter that means the what I've got now play like where my servers and it was asked earlier what do I SSH into enough nothingness decisions what I do I deploy static files. The static files were hosted publicly. All over the world is CDN may give a magic URL pointing to. Okay those are the static files. We may users go. They think that satisfy the static file listens in a saccade way for game days when there's changes in the database they get updates which they use to rerender the screen inside the sack while. I'm managing my database I that's distributed. Conceivably obviously it's in US East One. But in theory could be distributed. Then I want to have some service that's decides whether or not somebody is allowed to do something or maybe I want to decide. Hey don't use the F word of my tweet server buddy. And because they're trying to tweak the F word. And so normally I think I have sir they receive that message and parses it Or something like that. Well I don't want to run the server anymore. Just limits comes in. I'm going to wake up one of these little functions received the check or the upward and then replace the F word back. Okay so go ahead and pivot that to make it profanity filter and put it in place. And again think like okay now basically I'm going to pay for a 100 milliseconds of compute time every time somebody tweet some idle terrible tweet at 100 milliseconds time cross. Ask Python five divided by 30 times 24 times 60 times 60 times 1000. No. It's this right. Yes times ten. It cost me that much money. 101 it isn't in dollars. So two times two times ten to the negative seven $200 million so one ten millionth of a dollar to ten millionth of a dollar per Tweet. Okay sweet but that's cool. All right. So this is awesome and you could do your micro service. You can have inside this micro service an HTTP trigger. So you want to have a rest API and people can use to get access to your database in some way. You want to do is like Hawaii or whatever there's security rules you can throw in place. You can now go to work on building a serverless architecture so that your bill should be 0 until you have clients. This is what I would do if I were you and I am essentially you building small companies from scratch. I build my serverless architecture. Hey my $0.10 a month. If that and then go charge my clients make my cache. And if I get more and more and more points and I fully ramp up. I will obviously be able to keep pace with these costs. Okay fine. So it's the opposite of what we've been doing the rest of the class which is okay you're right Johnnie institution. You've got a 100 million clients and you have to support that kind of architecture fine. But this is another way to use the cloud for like your personal startup. If you're going to start out we're going to use the stack more or less right okay I want to build me my profanity filter like for him. Let's go. I'm done. Did you all gets the point of actually having your tweets go through times. When somebody goes this way entity may capitalize then i summation way at the end of it we will call it augmented. Batman just colors because he doesn't wanna get shot. So why is Robin wear bright colors He had another brick and mortar reference mix it up. So it's crystal. Yeah oh I will say that typically when I teach this kind of lecture I used the Realtime Database because it's what I cut my teeth with. Hearing fire Store there's no guarantee that database you're going in the correct order. So it's your job to order your stuff. The IDs are not monotonically increasing which they are in the real-time database. So that's why I made this other steam valve you sort it by the timestamp that I added What creates our amongst artists started to hire oh. So a fail if Hitler were a barista. Everything would be different. I wouldn't make as good of a show as the one that they did make high high high castle yeah man and I canceled man. Yeah I don't see any really from your keyboard Usa pastel anything. Yeah. Yeah yeah. Yeah. So I guess if anybody else I was probably actually the client had this problem today. He's going to this link and it's still showing the original one that we this is caching. So. And it can be annoying Here are the all the ways that I bust cash and I had to like walk me through on the phone and doing this while I was having lunch today cuz they're like I deployed some changes for a Firebase hosted CDN product. And they're like I'm it's a blank screen now and like Gosh I really hold on. So here's a combustor cash. If you open up your Firebase tools at all like if you open up your console you can right-click and empty cache hardware Firebase console. You can get. I like Firebase lunch. You can right-click an empty cache and hard reload. Another thing you can do that Have under network disable class time that costs me a little bit of performance in times or whatever but I push my thing all the time test performance or websites every lets correct. Another thing you can do that just happened to walk through this with somebody. You can go to settings. Advanced clear browsing data and clear in the last hour or cached images and files or whatever else and then go click. On that. You can make it just the file sooner and keep your cookies I'll say this right so it's one of the things I was about to say well Dan was talking to is that when you think about databases you want to think about basically these four trees. So the reason why the caching problem CNN's environment and you just stick this out. I've got file by file says hello world. And it's clearly my website and all of that. And I put it out to a CDN so it's going to go to New York City. It's going to go to Los Angeles. And he go to Singapore. It's going to go to London and it's going to go to Tokyo and you go to Brazil. So may end up with copies of helloworld file all over the place. Now I say oh my gosh I'm so sorry I didn't mean for it to say whoa whoa I wanted to say them all. Ok. So change the bottle. At what point do all those data centers decide to look back and see that it should be modular model instead of hello world. They didn't just grab this thing is a free service. Where did not like my static file it's in hello world where they go invalidate the cache And furthermore it's a CDN it's made for high-speed delivery. So all of your browser's cache right hey go to this URL and get this thing. And the server's configuration tells me the browser. And this is really not often changing things and just cache it forever. You're cool very. And so my caches. Hello worlds. I push on it. It's not going to go everywhere the same thing's true in your database right so we talk about these pups are patterns and all this stuff like value everywhere else. What's going on is that you can't have all of these things slave. There's CIA is the other database acronym consistency integrity and availability. You add to every visit. But like you can't be a distributed database all across the world now and it's gotta be that somebody updates the Singapore it's going to take a while for that update becomes available that personally Los Angeles. If you've got like replicated versions of the database anywhere which allows for high availability. Fast. Yeah I can have integrity. Conceivably if there's only one record each if I had spread out records like what we do in our CDN. I can't have pure integrity. I think what I want to change but actually there's different versions that are in series. Basically I'll probably wait for my integrity to catch up. I can have or I guess I would call it maybe more consistency. I. If something makes it change somewhere I had probably seen anywhere else and that any every gases really quickly. Just like the tradeoffs you have your shard data across the world. That's true. This is true. So cash envelop like somebody says there's only two hard problems computer scientists very blaming and cache invalidation. That's it. Everything else is breathe. So I take it to say there's just some rubs it. You gotta get used to I find that Google does a great job of making it easy to use but that's it. Your assignment is like. Think up how you would build Uber this architecture. What are like what can't you do with the serverless architecture imagined at all you could use it for IoT coordination. Where L Yeah. So we've given you many many options enjoy. Ya'll in three weeks. Yeah. Yeah. Yeah. Yeah. Yeah When I went to the citizen hundreds which quickly or slowly let to democratic values that we have to do. Julia you felt power. I'm doing. Now off-the-shelf everyone else. My play. Just because yes yes right you've got new employees that we do something with a lot of really angry
cpeg473-010-20191024-183001.mp4
From Andrew Novocin October 25, 2019
11 plays
11
0 comments
0
You unliked the media.