Picking the right serverless platform (Part 1)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone thanks for tuning in today's serverless expedition takes us on a journey to learn more about google's serverless platforms including the differences and similarities between them right wes that's right martin and thanks for inviting me to help folks understand a bit more about app engine cloud functions and cloud run are you all ready let's go [Music] so normally on this show we only focus on one of google's serverless platforms uh why are we talking about all three today wes good question martin today's discussion is broader and doesn't address a specific use case it leaders may want a broad but technical overview of our platforms users new to google cloud are curious about how to run apps in the cloud without virtual machines or kubernetes comparing and contrasting our platforms give people a better understanding of their similarities and differences not to mention you don't have to worry about picking the right one from the start since you can switch between them wow those are good reasons but i'm not sure we have time to cover all that how are you going to do it oh you're absolutely right about that today we're focusing on the platforms and their use cases but the big reveal will be a special app i wrote that you can deploy to all three platforms with no code changes that sounds pretty exciting oh definitely but you're right in that we won't have time to go over all of those deployments today maybe you can invite me back for an extended episode so i can show deploying this app to app engine cloud functions and cloud run you're welcome back anytime with but the sooner the better we wouldn't want to keep everyone waiting right absolutely cool now tell me about serverless on google cloud the first one is google app engine this is our app hosting in the cloud service now why does app engine exist many years ago our product team want to ask developers worldwide what they need from us and they told us all these little brown boxes were the things that slowed them down from deploying an app around the world they wanted things like machines being taken care of the database being taken care of oh by the way make it auto-scaling as well and make it available in different languages that are supported and give us a local development server and also give us bundled services like a database caching external tasks and storage and by the way only charges if our app is actually running and so they took those little brown boxes and created a big large box called app engine made available in lots of different languages and boom that's app engine and here's your python mvp or minimally viable product it's made up of just three files this is the world's smallest web app and once you have these three files and you've downloaded the google cloud sdk you can run the gcloud app deploy command and in under 60 seconds your app will be available around the world at a predetermined url that we give you our next product is google cloud functions this is our function hosting in the cloud service now why does cloud functions exist well maybe unlike app engine maybe you don't have an entire app maybe you just have a small little bit of code that you want to have executed and you don't want to worry about having web frameworks like a lamp stack or a mean stack you don't want any kind of stack you just have a little bit of code that you want running these could be little utilities they could be large monoliths that you've broken up into multiple microservices or event driven tasks now like app engine cloud functions can be triggered with http but cloud functions can do a few things that app engine can't and those are bolded for example background events you can actually kick off a cloud function if we receive a message on cloud pub sub our message queue service or if somebody uploaded a file to cloud storage or if someone logged into firebase like app engine however cloud functions is auto scaling and highly available and you're also only paying for when your functions are being called now you can also develop on the command line like app engine but cloud functions allow you to do everything from the cloud console you can create your cloud function code your cloud function deploy it and test it all from the cloud console if you wanted to develop and test locally we also have the open source functions framework for you lastly i wanted to mention that there is an alternative product called cloud functions for firebase firebase is our mobile development platform and typically if you were going to do more mobile development you would be using the cloud functions for firebase but if you're doing more cloud development or using more cloud services you'll probably just stick with regular google cloud functions but i just wanted to bring up that there's two similar products all right and here's your python mvp for cloud functions it's a one line function no config files and because of that the command line is a little bit longer so instead of just g cloud app deploy its g cloud functions deploy followed by the function name uh the language that you're using as well as how this function can be triggered and just like with app engine in under 60 seconds typically your function will be available around the world at a specific url that's been predetermined you can either hit it with curl or hit your browser with http our last one is google cloud run this is our container hosting in the cloud solution now over the past 10 years containers have become quite popular one of the things that makes it a unique feature is that it supports any language any library any binary because it's a container you determine the operating system you know you load everything in it that you want and you know for serverless use cases sometimes those restrictions uh you know are things that you can't work around for example you saw with app engine and cloud functions there's you know a limited set of languages that we support but maybe you have a c plus plus imaging library um you know that's one of the reasons why you would have containers because we can support all of those uh docker's been around for a long time so you have a huge ecosystem of base images and really it's now become an industry standard and giving you that flexibility that you really need now one thing that can't be ignored is many times users just love the convenience of serverless however some of the trade-offs are a little bit more challenging like maybe we want to use c plus plus or how can we use binaries and sometimes when you use serverless platforms you're using the apis that go with those platforms and now it's not as easily movable or portable to other platforms so you really don't want to feel that locked in you know that feeling of being locked in um you know and the thing that people often uh asking is why can't i have the flexibility of containers along with the convenience of serverless with cloud run because it's a container-based system you can have any language any library any binary the only thing we ask of you is leave an http port open to us and also make your app stateless so that if your app is called multiple times it's not going to have any side effects on your data once you have that bundle everything into container using your familiar docker commands or the google cloud build command what happens is that will trigger a build of your container image it will put the image into the registry and once it's in one of the registries you can deploy to cloud run either fully managed or through gke now one other feature that cloud run has is that it supports get ups this is the ability to have cd push to deploy from git i'll give you links to the documentation and the announcement but if you also want to mix in tools like github actions you can also roll on some ci as well and so the main advantage here is that once you do you know a git commit followed by a git push that can trigger you know running all of your test cases and then ends up building a container image and then deploying to cloud run now one of the last things that you should know is that there's a new feature called cloud build packs where if you use that knowing docker having docker files or any knowledge of containers at all is optional all right here's your python mvp for cloud run you'll notice that this app is almost identical to the app engine example except for the last couple of lines which are sort of grayed out now with app engine and cloud functions a web server is given to you by those platforms but because we now have a container it's up to you to actually bundle the web server inside your container but just in case you forget the last two lines of code down there will start the flask development server in case you forget so other than that this app is exactly identical to the app engine one and uh we have a lot of quick starts that you can see in different languages and you can get them at the quick start link that you see on the screen all right one more thing the docker file so typically when you're building containers you would have a docker file of course you should also have a docker ignore so you don't bundle extra files into your container that you don't need once you have your code ready to go you can build your container image with the g cloud build submit command and that will take that uh build that container image and stick it into the registry and once you're done you can deploy to cloud run with the next line which takes that image in the registry and deploys it up to cloud run or you can be lazy and combine both commands with the single line command that you see down at the bottom which does exactly the same thing and just like with app engine and cloud functions in under a minute your app will be available around the world at the predetermined url that you see on screen as mentioned on the previous slide cloud build packs makes it so that you don't have to know anything about docker or have a docker file or having knowledge about containers it's really optional now and before we get back to the main part of the presentation i wanted to present to you just a list of common use cases for all of our platforms now this is a very subjective list but typically these are what i've seen other users and different customers have used with our platforms it used to be the case that we only had app engine and that was our only solution but now that we have a more complete suite of products you could pick and choose which product is right for you and your needs as the host of serverless expeditions i'm already familiar with our platforms uh but that was a pretty useful summary uh but what about that special no code changes needed app that's right it's a small app that implements a minimal google translate from english to spanish the app prompts for the text to translate calls the cloud translation api to do the hard work then displays the results in the browser let's take a quick look at the code at the heart of the application is the translate function here it is in python and node.js where you can see when users hit the app the first time its get request returns a blank form to enter the text they want translated when the form is submitted the post request passes the english text to the api where the resulting spanish translation is returned finally whether get or post data or no data the template is rendered to the user along with another blank form for another translation of desired the rest of it is all the supporting code you know the imports constants and web server stuff the most important thing is that the app runs on app engine cloud functions or cloud run without any code changes anyway it's all in the repo so check it out there cool app worse but i wouldn't go out of my way to write an app that runs on all three platforms why did you do it well a customer wrote that they had an app engine app and wanted to call the cloud translation api from it but couldn't find the exact instruction in the docs i wrote it as a proof of concept but also because i wanted to learn how to call cloud apis from serverless then i thought if it runs on app engine it should also work on cloud run finally since it's a one function app that should be a natural for cloud functions ah that makes sense as i was wondering why i really like that you introduced all three platforms and letting folks know they can't make a mistake and pick the wrong platform that's right pick the one that matches your use case and if you determine later that it's not right you can later switch if you code it in a flexible way like we did another goal of this app is to show how straightforward it is to call cloud apis and one day non-cloud google apis from serverless sounds good i know we don't have time to see any deployments but i'd like to see how the app works can you demo it locally on your machine yep no developers can run it with express or flask for python users once you've cloned the repo or downloaded the zip file you can test the app locally node developer should go into the node.js folder then install the necessary packages with npm install after that has completed you can check out what's there then use the gcloud auth application default login command to set the credentials for calling the cloud translation api from your machine now run express locally with npm start and you should be good to go python developers will do something similar cd into that folder and run the pip install command to get the necessary packages when that's done run the same gcloud auth application default login command for setting credentials you can confirm the files look good then start the flask development server by running main.py regardless of which version you run bring up localhost 8080 in your browser and translate some text express doesn't output anything unless you install some middleware but flask does output requests when received and you can see that in the console cool demo i'll take a look at the code when we're done but can you give me a heads up on what we're doing next as promised listen here are all the supported deployments in the follow-up video i'll walk through deploying this sample app to app engine cloud functions and cloud run in both python and node.js we'll do as many of them as we can time permitting so stay tuned for that in the meantime here's a link to the repo so you can get all the code samples as well as all the codelabs guiding you through each of those deployments today great thank you everyone for watching today if you have questions for me or watts or suggestions for future episodes please let us know in the comments below see you on another serverless expedition soon [Music]
Info
Channel: Google Cloud Tech
Views: 13,195
Rating: undefined out of 5
Keywords: cloud computing, cloud, google cloud, serverless, Serverless, App Engine, Cloud Functions, Google Cloud Functions, cloud functions, Google Cloud Run, Cloud Run, cloud run, google latest, google, Wesley Chun, app engine, PaaS, Google Translate, Cloud Translation API, migration, Python, AI, ML, AI/ML, ai, ml, machine learning, artificial intelligence, video, videos, tool, tools, codelab, codelabs, desktop, series, Google APIs, cloud developers, google developers, developers, developer, API, api, apis
Id: gle26fT28Bw
Channel Id: undefined
Length: 14min 1sec (841 seconds)
Published: Thu Jul 07 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.