Building Serverless Apps with MongoDB Atlas on Google Cloud Platform

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
yeah so I want to thank everyone for the time here today as I said you know we're gonna be building sort of a serverless application here and what you've seen here is sort of a cheeky title putting the world back in the hello world with MongoDB Atlas on Google cloud platform so cheeky is cheeky is you know that doesn't quite make sense what does that mean so obviously gonna be doing a hello world application of a pairing with MongoDB Atlas as a back-end with a Google Cloud product and putting the world back in it's actually a low latency hello world it's actually the best I've seen clearly I'm biased I've made it but basically based on our use case here we're going to be spinning up multiple nodes across the world so we do our hello world we're really gonna have a low latency application that we're gonna try to build within 45 minutes live so when I say we it's primarily gonna be me but there's a caveat at the end here but this is gonna be a live demo right so a lot of demos are fun we do have Murphy's Law I will try my best to to make sure this goes smoothly but with that said let's sort of jump in here so I know I got a quick introduction there you know in terms of Who am I this guy on stage Ken Smith with Google Cloud based out of New York custom engineer I work with some of the largest enterprise companies out there in terms of their transition path for wherever they may be that could be on Prem of the cloud providers hybrid to their sort of cloud journey and help them sort of bridge these gaps so I've been with Google a little bit over three years now and going on for years I've been inside the cloud industry as an engineer for that seven to eight years I'm part of that I've been in infrastructure for roughly the last eight eleven years or so so that's a little bit about me and sort of my credentials here so as you guys probably imagine at a MongoDB Atlas you know once again the story is gonna be about Google Cloud and MongoDB Atlas and and sort of our use case sort of takes us into this so what is our use case here okay so let's say that we work at the same company here it's a large enterprise comp and we're being tasked to develop a global web-based application with the majority of our users in the US and it's slightly smaller percentage of our users in a UK and Australia now if root is a pause right there I can tell you that that's somewhat concerning as a cloud engineer right because once you start dealing with applications serving a global basis that immediately sort of gives me chills them back of my neck in terms of latency concerns and so it opens you up so if we move on to the rest I'll use case here we need to have something with native scaling capabilities great so we're not doing lift and shift not moving existing one that's actually great to hear for me it's gonna pay dividends down the road here that's going to allow us to spend less of time managing infrastructure more time adding new features and capabilities you heard that sort of touched on briefly during the keynote but that really is very important because we say native scaling capabilities we don't want to be managing servers on a one by one basis adding servers as demand spikes up if you even can do it quick enough maybe low balances of what not even those need to be configured and then also needs to sort of scale down when these when we don't really need the application that much you know you don't you shouldn't really have a call so you don't really need it and you should really do that and so that time savings we have let's say it's easily sort of double-digit percentages is gonna allow us to go ahead and make better use of our 40 hour work week and hopefully our work week is 40 hours and I mean that's less time getting ahead of your competition more job security so on and so forth move on here we have a requirement for a document store database here for our back-end so you're very not relational multi-region support once again probably because of the first bullet point there in terms of where users are located and data security is key because of the time in which we live in in terms of security breaches of what not just specifically calling out here the the why user base latency yep we got it already identified and lastly here is that the direction given to us and our team here bar CTO is he needs a proof of concept before he signs off commits architecture hours up X towards a surgeon suggested architecture which makes sense so this demo is as if we're sort of doing a PLC sort of proving what is possible here right in terms of meeting our needs and our use case so you guys are sitting in a MongoDB conference big surprise for the document store we're choosing MongoDB Atlas probably caught no one off-guard here but there are some key things that sort of call out here about why we're sort of choosing this so just real briefly here in an encryption TLS sll always on an occasion dedicated clusters row base I am they can also do multi region clusters which we're going to sort of see here in a moment but that's going to be very important because of this wide this is why use a base that we call it out here inside of our use case now if we actually are applications very successful which I hope so there's an opportunity to go ahead and scale this up in that list without bringing down time using something like charting and high throughput for M 30s and up switch once again I think was called out during the keynote here and then of course if we just wanted to play with sort of a POC slightly different use case here which I'll tell you about in a moment but we did just announced our free tier of mommy-to-be Atlas on Google cloud platform that's great but you know that's just a data base what we then actually use for our front end here Google Cloud product Google cloud platform has roughly 70 80 plus products and growing an app engine is sort of one of these natural fits this is one of our first products we actually brought the market it's probably one of our most features it's part of our platform as a service as part of our service offerings here what's really great about this is that it actually will scale up and scale down by itself we will have those go ahead and call out where our primary region is but it will take advantage of Google's Network and do edge caching globally for you you do not need to configure that it will scale up and scale down in real time as needed well you have enough focus on it so I'm not going to go through the bullet points here but I will call out that at engin flexible which is actually what we're going to be using here allows us to use a third-party database like MongoDB Atlas so in terms of basic building blocks I think we're gonna choose mom going to be Atlas and App Engine flexible environment to get going here so I'm gonna try to keep the the slides here at least I've made a conscious effort to do the bare minimum I'm not trying to blow anyone to sleep here the majority of our time is going to be spent actually spinning up a demo here okay so what are we doing in the demo I gave you a brief set up here hello we're application I'm going to be using no GS here with App Engine flexible and at a super high level the steps were going to be doing is creating configuring MongoDB Atlas multi-regional cluster and vc p we then going to configure a Google cloud platform account for that engine flexible environment to go and accept the API our calls are going to be making here we're going to configure a node.js application and spin up a Debian VM inside of GCE and we're going to push our application to App Engine using those api's and then from there that application will be spun up it will be live any sort of web enabled terminal would be able to access this once again is going to have the low latency giving how we're gonna build this out so that's it let's just jump right into the demo and see how are we actually gonna piece this together so I don't know how many guys in the audience have already sort of played around with MongoDB Atlas I think they came close Andrew Davison did in the keynote I'm showing you this but what we're gonna try to do here quickly is is act as if we're building this out from scratch here so once again pretty ambitious here this is all live even though we do have a little bit of code in a text editor copy and paste once again for the sake of time trying to prevent sort of fat fingering this so please excuse me if I'm not very mobile here but I'm kind of gonna have to work at the keyboard here so if you haven't already signed up please sign up for MongoDB Atlas here with your first sign in you're going to see something like this if he knows here and says we do not have any clusters right makes sense we just start it we're gonna build something out here gonna use a Google cloud platform once again these are three regions where free tier is available but the free tiers with M 0 which is sort of a shared cluster we will not be using that because actually to use the the clusters crawled multiple regions as you see here we need to do in 10 and up so we're gonna have to pay for this given the fact that this is sort of a wide install base but it also will be a dedicated cluster for us so we're gonna skip the free tier on this route and we're gonna go all-in when we're gonna configure this m0 here straight to an m10 so yep shared and 0 free yeah yeah yeah dedicated development cluster m10 yep this is the bare minimum we need to get going so we go up here about do we want to configure this on multiple regions answer its course yes there we go down here and he's notice here our default is in the US which matches up with our use case with a primary of our users here which is great three noes here for sort of redundancy and backup within the US ok but for the other regions we're just going to add a read replica once again based on our use case that's gonna be one in the UK actually going to see London and then one in Australia just so those guys can have pretty quick reads so here is Sydney one node I'm gonna try to keep this cost-effective then we couldn't go ahead and do London well clearly I can go ahead and add more if I wanted to but I think just to prove a point I think that's pretty good so yep this looks good we have our m10 we'll take these defaults here this all looks good to me plus a name we wouldn't keep close to 0 sounds good crate cluster so this cluster is being created now in the backend it says please wait is being created here it's going to take roughly seven to ten minutes it's gonna be five nodes so it's actually making call to you in the backend of our different GCP regions in these in these different areas and actually spinning up the infrastructure pushing out the code and making it as if it's one large cluster so I'm going to be Atlas is doing a lot of the heavy lifting for us but while we're waiting for this and it gives you a little status update of what it's doing up here we're gonna go ahead and start configuring our security so we're gonna go down with two security here we need to add a user go down here and add a user it's going to be admin I'm going to give it a password make sure you write that down we're going to select Atlas admin we need full rights here just what we're doing to make sure we don't have any issues added users and just like that we have an admin user here that can connect to our database by default no one can connect to your MongoDB Atlas cluster without so explicitly allowing IP addresses which makes sense so this is secured by default once they add IP address now ideally you want to enter serve our site or block for like your work address of where you might be trying to access this if you're small developer this might be something like your personal terminal there's actually a handy box here that says your current IP address purpose that I demo was this going to allow from anywhere I mean obviously this is a security risk but this is just to make sure we don't have any issues now we're sort of stack the cards in our favor great so from there we've added our user we've added our IP whitelist here and the reality is though is that for the sake of the the 40 or 45 minutes we have here we're actually not going to wait for this to spin up because it would probably take too long but I will show you what the end result looks like over here so we're gonna do a little bit of a cooking show trick and say that you know once our cake is done baking this is similar what you're gonna see here as you notice here there are 3-3 nodes here inside of the us as we selected an hour to read regions here to read replicas inside of London and then Sydney here it looks like they're just sort of humming along here now then go once we sort of create a new database here is that we want to go ahead and get a accents drink this Connexus ring is what we're going to put an application in the moment that goes and says we're our sort of database is what is a user the users credentials that we actually gonna use a connect to it so I selected the connect button I'm gonna say connect to my application great I'm using three point four earlier and we're just gonna copy copy and paste this and notice that you know this is actually where you stick your password here that's highlighted password here then it goes on and tell you how to use this right but for our purposes we already have this copied down and our connection string is right here so from that point our database is live it has a user it knows where to accept connections from and is ready to be ridden to insert serving and returning requests right on the global basis with low latency but we still don't have that front end yet so that said we're going to hop inside of Google Cloud and then we're gonna go ahead and crate we're going to configure our Google Cloud account for App Engine so if you haven't signed up for Google Cloud it's a cloud app Google calm you can try it free here for 300 credit no you can sign in on the top right if you already have an account so once you get into your account here Defenders new is to look slightly different but this is sort of the main sort of URL here so I'm kind of already in the account that we want to use to start spinning things up but just for demonstration purposes if you want to know how to sort of create a new project use it just like I drop down new project I mean pretty much spin this up from scratch here so let's call this Atlas Google demo 2018 note here that the project ID can't be changed if you want to I mean after the fact if you want to change it you can change it now this would be part of the URL that makes sense in a moment if I hit create you'll see this little icon here sort of spin to say it's doing something and it says it's creating this project so this project would only take roughly ten seconds or so to sort of create will give it a moment and then once this is ready we'll be able to select it over again the left side sort of drop down here so right now when demo Atlas App Engine - which is actually we want to be so you notice it's just complete it which pretty much took no time so just to switch between projects here I can choose the drop down here and to create this Atlas Google demo as he sees this change and there's a whole different level of resources so this is how we do sort of isolation here between projects and resources and clients by default is that we use different sort of projects so we actually don't care about this one so we will just leave him alone just to show us how we spin things up and now we're back to the main page great so now let's go ahead and enable a couple of api's so once we spin up our instance here it would be ready or I'm gonna do that inversely let's go ahead and spin up our Debbie in the instance now we're gonna use so I went on a left-side menu chose compute the instances yep it looks like this is getting ready so we'll give it a moment here so this is an able and compute engine on this projects and this is sort of new for us that's ready wouldn't try to duplicate this and go to enable our API is here so we're gonna go on the left side here and go down to api's and services dashboards as you notice there's nothing here that says App Engine or App Engine flexible or admin so we're gonna enable those and once there are they should show up here so just tells me all the api's we have here so since I know when I'm looking for App Engine flexible yep this is what we want here looks good we're gonna enable this API since we needed to be able to talk to this project for our code it's gonna go ahead and do that and back in I'm also going to go ahead and do our second one just to speed things up here you also want to go ahead and look for api's dry pack floor you could also just type in what you're looking for at the top box API Explorer yep great and then we're going to choose our admin one super yep and let's enable this too okay so these two guys are enabling for our project we'll let them just go ahead and cook here this says it's so getting compute engine ready we're just refresh this guy great so now it's enabled compute engine for this project here and now we can get started with spinning up our actual sort of Debian instance yep we'll keep instance one's a name that's fine we'll keep us east one for our region we can definitely do this in one quarter not an issue but we want to make sure that this is kind of fast so I'm kind of greedy I'm just going to choose eight cores here so we can move along but we're also going to allow the compute engine default service account to have access to all cloud API so the two API we just enabled I've gonna make sure that it's not gonna have an issue talking with those because I default we do not enable all api's and this is a Debian nine looks good to me and let's go ahead and spin this up here so you notice that once we click spinning up by instance here see it's creating we actually spin up Linux instances really really fast this is a core box I think it might be roughly so in order of 10 30 seconds so in a moment as you see it's done already creating so that is live and it's up is it ready sorted to take requests which is awesome so before we click on that SSH we're just going to make sure that our API is here enable yep this one says I disabled for App Engine flexible which means it's good and this one's the same good so we have API is we have an instance so to make it easy all we gonna do is click the ssh button and the panthéon platform in Google Cloud we're all automatically handle exchanging the keys and we'll be SSH in into our debian instance and then we can move on to the scripting so we configured our cluster and MongoDB is ready to accept connections we have configured a Google cloud account from scratch enabling to api's pretty quickly here now we're on to actually writing our code and we're in great so let's see here so as I said before just to make sure things go smoothly here we're just going to copy and paste here some of the updates we're going to do here so let's go ahead and update this instance for the requirements we need so we did get this moving here so we're just going to do a sudo app update here on this let's again pacing not the fat finger it it's working it's done from here we're going to go ahead and do a few more configuration steps great and then we're going to go ahead and make sure that we can do our build essentials in nodejs here and we need our JavaScript package manager' npm install in comp once this is finished yep not too worried about the warnings I think we're okay and let's go ahead and initialize NPM great so let's get this package a name I'm going to name it test take this versioning 1.0.0 description then with a blank entry point we're going to say the change to server dot GS you know I said I wasn't gonna fat-finger this but I guess I like pushing my luck and we'll just take the rest of the defaults through here we got what we needed yep this is okay okay that's part done great now we're using MongoDB two two three three it's going to go ahead and pass it along just installed super now we're going to go ahead and write this server JS file inside of our text editor Nano super so see so this is a code we're actually going to use for a note our server J s here at a high level we're actually going to connect to a MongoDB Atlas cluster here using our connection string so we can go back in the MongoDB we did copy that over you'll see in a moment here we'll paste that in here and then if you go down here once it makes that sort of connection we're going to go ahead and open up a database collection called messages from there we're going to tell the application to write hello world plus a time date stamp I then pass along to MongoDB and the server back in the loop so at a high level that's what this code is doing at in the demo you guys are have an opportunity to look at this for yourself but it's for the sake of brevity we're gonna sort of keep this moving here so since we didn't quite wait for the first one to finish here we're just gonna switch over to one that's already up this is a connection string we copied over with my password so just keep that between me and you for now but all seriousness this will be blown away very shortly here this is no other way really to sort of do this here so what we were going to end up doing is is that we're going to take our connection string which is here this is what you get I think we already showed this once you hit connect we'll copy this and then it's gonna say putting your password here paths of 10 we're gonna grab this whole block here we're gonna paste it between the lines that say paste password here we should be here so we know this is good our code our connection string or password and a copy of this great I'm going to move over here to our server dodgy asphalt gonna face set in just gonna go up just to make sure that it looks happy yep looks good to me we're gonna go ahead and exit and save out here yes save yep server EGS looks good to me super so now this is from here let's see if we can go ahead and start this and possibly see if we can spin this up on our debian instance locally just to make sure it works before we try to push this damage all right what that looks like a good sign as you see here it says started web process okay from here we're going to go ahead and say alright let's take a look at this guy and if they were and we're successful we need to open up an incense as we're successful we should see return hello world here but it's just going to be locally for now we'll have to do a little bit more configuration here so let's open up a second shht window once again it's handling these credentials who SSH in the backend it makes a lot easier for us it knows who we are since you're logged into the console super I think I didn't copy something over yep listen to see here hey hello world okay so this is a good place to be right now it basically means that our hello world application is at least working on the server itself so this is a web application this is essentially just an HTTP server that is doing what it's asked to do right now but we're gonna have to go ahead and then push this to App Engine and we've already started on that configuration here so to do App Engine flexible we're gonna go inside a text editor we're going to creep an app that yellow foul I didn't tell it the application languages and what do we needed to do here and I'm thinking about it we didn't actually enabled App Engine which is great because we caught it before you ran into it so let's go back over here set a Google cloud platform App Engine your very first app great so we're gonna select a language or use an ODS so it will serve this globally but basically it's saying were the primary of your users in terms of where it's gonna try to concentrate the servers here so based on our use case that's in the u.s. US central looks good to me billing is already taken care of and it's basically going to spin up the App Engine services so it's going to be responsive when we try to push our code to it so we just give it a moment here since it's preparing this normally takes just a couple minutes here so should be moving here in a moment so once this is done here a little bit longer than normal there we go it's gonna try to say like do you want to go to a two Turturro to get started it no because we kind of know what we're doing great so it's gonna be receptive to our requests here so that's good we caught that before it's an issue now let's go ahead and write this app that EML file before we push it here so if we're just saying that the runtimes would be no js' an environment is gonna be the flexible environment super simple app dot llamo we're gonna save this great yep let's write that that that yellow file is created and then from there we're actually going to push this app to app engine tell there's it start returning yep this looks good to me continue yes all right so what it's doing right now is it's pushing a code to App Engine and App Engine is spinning up instances inside of your Google Cloud account to sort of serve your project okay this process here to get App Engine started from scratch for the first time takes roughly seven to ten minutes that is more time than we're going to be able to wait here but once again while this is sort of completing here we have our the project where we already did this okay so the end result here we're done you're going to be given an HTTP URL to go ahead and access your your application well actually we have to do brows but be able to access your App Engine application it's comprised of your project ID app spot Google which is a Google owned domain where we can we can go ahead and view this from any web terminal in the world include mobile devices once again with low latency so let's go ahead and see this and then then maybe we can peek behind the covers in GCP and see what does that look like and then maybe inside of MongoDB to see kind of what we see here so I think I pasted that in the wrong helpmeet missing an s kind of makes a difference you don't say the right protocol super hello world so this is the hello world that if you were in Australia a UK we have low latency now his textile sell imagine it wouldn't be that big anyway but the point is though is that this is just the art of what's possible so you can imagine your application on top of this right it's really going to allow you to unlock these really wide user bases and give you a back-end in a UI that is truly sort of serverless so if you're curious and I think we might have the time here we can go ahead and peek in and see sort of what does that look like and serve our client environment here so let's see that's not the one I want this is it so if you go to compute engine you should be we should be able to see that there are a couple more instances than the one we created at Debian one two-factor authentication all right and this is actually for this guy great so let's see this is a right one great so here's our instance one that we created it's so sort of humming along but interest in the Z stood weird once it's sitting here inside of central and 1b okay so App Engine has automatically spun this up for us based on this server we're doing clearly it's pretty low load so it doesn't really didn't need to do much but the beautiful thing is though is that if we went ahead and we did a Twitter announcement during sort of the Super Bowl and our application got a lot of demand all of a sudden a huge spike you will automatically see this sort of populating with 5 10 15 20 whatever it thinks it needs is where to serve that traffic and then once that spike is done and sort of has a subsided that would go back down we're not specifying what sort of done here and then you open the hood underneath App Engine there's metrics from sort of what it's doing some of the instances here services spikes things like that this is currently loading yep and there's our two guises hanging out there and there's other sort of metrics as you sort of expect here so we were going to go back inside atlas and say okay that's great you know what are you actually doing here let's see I think this is our the right one so let's go ahead and click on one of these guys in collections let's look at what data we put in here from my application yep so here's tests because the message is we create it here's a data here that from the several times we made it hello world received on this date that date and that date we're gonna modify scan it this shows that we were actually writing data at a data base it was retrieving it and it was returning these sort of results here so well that said I think that this shows that it's possible we were sort of move along here now that we managed to sort of do them possible made a difficulty in 25 minutes and we made a low latency sort of hello app so let's just take a moment take a step back so that was successful and and talk about this right so and approximately 30 minutes here we created a new GCP project from scratch we configured that new project to accept API calls we spun up a new sort of VM instance from scratch a Debian on instance waited for it to boot we named a couple api's what else did we do Oh created a MongoDB cluster we configured the cluster we did firewall rules we did a row based authentication and then we SSH in and pushed our code to our application so those are a lot of steps we just completed and under 30 minutes sort of live here so I think that that is a pretty impressive here time check how much time do we have that's it okay so we have a demo here that you guys can go ahead and you guys want to try this this is made into datura form for free to take a screenshot all the code is live here I'm sort of getting the hook here give you guys a moment so this is live right now so you know I wasn't pulling a fast one feel free to stop by our booth here a team's here I'm going to be Atlas 300 all it's free credit to get started special shout out the Abhijit for helping for the code I cheat where are you raise your hand thank you I'll be G thank you ask for the help thank you guys I'll be enjoy the rest hear that alright thank you very much [Applause]
Info
Channel: MongoDB
Views: 5,034
Rating: undefined out of 5
Keywords: Data Analytics, mongodb
Id: bqsKjMcoBCc
Channel Id: undefined
Length: 36min 36sec (2196 seconds)
Published: Thu Jul 12 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.