Serverless Compute on Google Cloud: What's New (Cloud Next '18)

Serverless Compute on Google Cloud: What's New (Cloud Next '18)

Show Video

Mine. Well. Thank you everyone for coming, out today I'm, miles Barnes I'm and developer advocate, on cloud. Platform, also. One of the main Tanner's of nodejs, and do a lot of work with product. Managers like Jason, who's doing really amazing stuff will tell you all about it right now I'm. Jason I'm a product manager on clouds, specifically. In the service space. Before. We dive. In and I just want to make sure that we. Make it clear that service, can mean many many things in cloud platform it's not just computers, many services, that we have that, are. Service in the sense that you don't manage infrastructure, and you paper usage for, the purpose of this talk we're really narrowly scoping, that just to compute and. Concretely in cloud platform, that means two products, cloud. Functions, and app engine for, those unfamiliar, cloud functions, is our, event driven service. Compute, platform you deploy, functions, and they execute in the cloud and. App Engine is the og service. From, cloud platform. Web. Applications, again, sort, of totally sail or scales to zero. So. With App Engine yes. So. Quick. Pull the audience how many people in the audience have used App Engine before. Awesome. And how. Many people have, been using it for more than five years. That's. Really amazing App Engine celebrated. His ten-year anniversary this. Year it's, pretty, exciting that we've had it as long as we have and just. A quick recap of all the things it was launched in i/o in May of 2018. Originally. A Python runtime. With a memcache API. Introduced. Up Java. Runtime in April of 2009, and App, Engine moved at a preview, in. 2011. We, introduced, a go runtime in 2012. A PHP, runtime in, 2013. Java. 8 last, year in June and most recently at i/o with starin. Over here we introduced. The world to know GS 8 on App, Engine standard. On, our new second-generation runtime. So. Our, new second-generation. Runtime, is open, source idiomatic. Experience, you, write code the same way for App Engine that you would to just run on any. Version, of the runtime rewriting if you know how to write Python to run it on your computer you know how to write, Python to, run on an app engine the. New second-generation runtime. Can use any extension, or binary or framework, if. You're writing node pretty, much any node module that you want to use you can use any you, know Java, library. Or Python. Library the things that are running on the second generation can run them and this is a big difference from the first generation runtime and, as. I mentioned node 8 we announced at i/o, but, today we wanted to let you know about two new runtimes which are Python 37 and PHP 7, to which, you can use on App Engine today which is really exciting so. On. The cloud functions side. Again. A quick recap we we, went beta launch at this event last. Year, in, March, and. We launched, two beta with, a node.js runtime, we. Had some cool features like HTTP. Invocation. In the box so you could just deploy a function, and call. It directly wire, HTTP, without any other any. Other services, required we, did things like stackdriver integration. And of course it's a service product, so you only pay when your code runs and in, the time between then and now we've been doing, a lot of work on adding, capabilities to the platform, improving. The performance and, and. Across the board and so I want to take you through some of the things that we've been we've, been working on. So. Probably the most important, and upfront is that we are now generally available so Clara functions is out of beta, thanks. It's, open, to all it's. Ready for production use and we even have an SLA, so, we're sort of standing by the. Availability. We're. Rolling, out to more regions in beta were only available in the US in one region us Central we're, now available, in four regions.

Too, In the US and. One. In Europe and one in Asia we'll, be rolling out more regions progressively, but. Those are available today. And. An. Interesting, feature of cloud, functions, is, that, with, these new regions, what. May not be obvious is that you can actually deploy. Different. Functions, in the same project, that, are in different regions. This. Is allows. You to have. Different capabilities. That. In, the same project, so all the same permission, models the same IM rock rolls and so on but, addressing customers that may be in particular regions you, can also do things like have functions, with the same name in different regions in the same project. So. We. Mentioned the new runtimes for App Engine but there's, also some runtime announcements. For us to make for, cloud functions first of all I know, I'm really excited about no date for cloud. Functions, so. You can now as of today write cloud functions using node 8.11. Which. Brings in support for async/await, for myself that was a major change to the way in which I wrote JavaScript, thought about asynchronicity. It. Also has a new function signature which we'll be showing you in a minute if you, want to deploy you use the runtime no GS 8 or if you're doing it through the UI it's available through the drop down menu. So. If. You're writing functions today with note 6 you may recognize, this this is what. You would have for a background function where the the top one is a function written with a callback and the second one is a function that's, able to return a promise. The, API has changed a little bit for notate where. You. Could see we now have a data and a context, as opposed. To an event previously. You would have to dig into the event to get all this information this, is just available for you it's a lot faster you, can provide async, functions. As the function itself which allows you to then use the awake keyword to await the results, of asynchronous, operations, so, as we can see in in this async function that we have here at the top for a Hello pub/sub we, can do a whole bunch of asynchronous stuff and if we had multiple of these asynchronous, operations, in a row we, would actually be able to do those in, a, linear pattern which is for, myself a much better mental, model below, we can see the function signature, for HTTP, functions, which, remains unchanged. The main difference being again you, can provide, async functions and use the awake keyword within it, so. Python, 37, is really exciting, as a new runtime you, can write your cloud functions using Python you, deploy using runtime. Python 3:7 here's, an example of, HTTP. And a pub/sub function. You. Get a data and a context, for a pub/sub function and a request for a hello HTTP, this. Is based on flask I don't, know just, a lot, of people here use flask cool.

Yeah Like is really. Nice minimal. Idiomatic. Python way of writing, HTTP servers you, can do get put post delete, options. The, requests themselves, are based on flash start request so if you know the API signature, of that you already know, how to get up and running and if you don't the docs are there and, the response is just need to be compatible with flask make response and you'll, be able to start getting functions, up and running with Python today. Python. Back to background, functions. So. As with node you get the data which in Python is addicting. You. Get a context, which is Google Cloud functions context, and that context there's a whole bunch of information that you could dig in if. To, signal that the function, is successful, in Python all you need to do is return from your function and if, there's any problems, you raise an exception and stack, driver error handling will get automatically, notified and you'll be able to do you, know whatever, you want to setup in the process to handle error, recovery. So. There. Are common features between both, of these you you have logs, so. If you log out using the standard ways of logging in both libraries, those are going to be sucked. Up by stack driver and ready for you to dig in if you've, ever used the UI for deploying functions, if you've, done it with node where you can just kind of click immediately. After running, a test and see the logs to see if it worked is the, exact same way you can do it with Python, uncaught. Exceptions, as I mentioned before are automatically, hands it off to stack driver logging, and stack, driver error reporting, and. Similarly. To node, Python. Also will automatically, do the installation, of all of your dependencies. For. Node you have package.json, for. Python you have a requirements, txt, so, just list your requirements, and the requirements txt. And we're. Going to install all your dependencies for you in the cloud. So. The, context object that I mentioned before this, is how it breaks down you, have the, event ID the timestamp the event type and the resource. These, will be primarily these will be only for background functions you don't get a context, object with HTTP, functions. For those you get a request in a response in node and, you get the request for Python. But. These are the options that you would have from a background function, and you can use this in your code to determine like you know was it pub/sub that triggered me or am. I being triggered by another event that. Everything is in there that you need to kind of understand, the context, of the object and where it's running. This, is an example of what that may look like this would be for a publish, event. On a pub sub-q and you can get all the way down to even like the version of pub sub if you're breaking down that string in the type so, a lot of information in context that you can get from this. For, those of you who are using firebase, functions. Cloud. Functions, for firebase is now also in GA and it, has full support for no date so you can write your Xmas script 2017. You can use async await the. Language features that are supported, by GCF, also.

Supported, By firebase, functions, there's. A new runtime configuration options. That allow you to control your region and your memory and timeout, these, are really great granular, controls, and. You, know a great thing to dig into for. The productivity of your applications, one, of the really cool things that's coming with this launch 2 is that, firebase events for analytics file store real-time. DB and authentication, are now available directly, in cloud functions so you can use your firebase events to trigger your, your cloud. Functions, both. Of these different, products have different great ways of using them and now you can kind of depending on what you're doing with your academic decisions based on what works best for your team. Thanks. So yeah one of the things that we talked about before in, the, new. Runtimes, for App Engine this. Applies to that as well we're rebasing the, underlying, operating system on, Ubuntu, and one. Of the main reasons for doing this is our. Ability, to provide. System. Libraries and native binaries in the image in in cloud functions, historically, we've, really only just allowed one and that's image magic with. This switch to a bun - we're, really broadening, the scope I've, listed a couple there image magic ffmpeg, this is something a lot of people have asked for for video processing, and. We've also made sure that we've bundled in all the system libraries required, to run headless Chrome so. You can take, screenshots of a web page from. Within a cloud function, and if. You want the big list here, is the list as of a few weeks ago it. May have been actually, added to since then I. Won't, spend too much time on that. Another, feature that a lot of customers have asked for is environment, variables, so. We're, announcing today that you can now, specify. Key, value pairs that, are bound to a single function but they don't exist inside your source code you set them at deploy time. Just. Any arbitrary number of key value pairs and then those will be injected, as literal, environment, variables at execution. Time so, at deploy time we'll save those and that at execution, time will, inject those into, the, environment. And, this is available in the web UI the cloud console, you can just set them in there it's. Also available in the API and, the CLI you saw just before. Okay. Miles, demo yeah. So all. The things we just talked about I decided hey like let's make something silly that uses all of them all at once so I can show. You some things onstage so I've got a demo here on my, machine that. I'm going to show you and. So. We got here the math bot it's, really friendly nice, person, I'm going to start a new conversation. With the math bot and I'll just be like you, know like hey, math wha what's, one plus one and. You. Know math bot needs to think it's been sleeping, so if you're not, familiar with scale to zero when you're not using your functions, they're, not running so you're not paying for it it, also means that you have what's known as a cold boot so the first time that you do, something it's, going to take a second for it to spin up and figure everything out and get, running. Hey. Math bot. Maybe. I shouldn't have picked something so hard oh I know why cuz I didn't at math bot. Didn't. Know I was talking to it and this, is actually a really great feature for hangouts chat so if you're making BOTS they're not just going to be responding, to anything. That you're saying inside of the chat they're only going to actually respond when. You talk to them we've got tutorials, available online so you can follow and get your own hangout spots going and so we could see math BOTS got back to me pretty quickly I get to feel like you know like what spy and it's. Gonna be like you, know it's not gonna say anything smarmy, it's gonna be pretty quick. On that and I can while. I'm waiting for that you know I anything, if you don't address it yeah. Oh yeah I keep doing that so you know what I'm just gonna go to math wat right here. I'll. Be like what spy and. It'll say you, know hopefully 3.14. I. Could. Be like what's the meaning of life. And. Of course it's gonna come back. It's. Navigating, the Wi-Fi, it's. It's getting really esoteric with, me. But. So well we've got going on here are two cloud functions we've, got a node.js cloud function, and a Python cloud function doing two separate things so, I have my own expertise, and one of them is not machine learning I know node really well so, when I wanted to start instrumenting. With the hangouts chat API and I needed to do things I haven't done before it, was it.

Was Way more idiomatic. And straightforward for me to get started with nodes so I used node to create a big a bridge between. Hangouts, chat and cloud functions but. I don't know anything about writing chat BOTS but I was googling around and found this thing called chatter bot which is available on pip which, had a demo that worked right out of the box so, I was able to get a chat bot spun up with Python so, if we take a look here we could see here's. A. Here's. The hangout, spot here's. Source code for the node side of things and we're. Using node fetch from big fan of fetch fetches. An API for making Network requests that returns a promise we've. Got this function. Which is an async function to ask the bot which makes the body sets. Up the headers it does, a try-catch where, it goes and waits for the response of from. The bot URL this is as we, can see up here an environment, variable that we've injected inside of the function and we await for the response text which is resolving, the result of that and the, rest of this is you know we this is the function that we're handing out to hangouts chat it's just, saying hey grab. The message and ask. The bot and then asking, the bot is heading over here to the Python code which, we can see which, is about, 41 lines of code and it's. Mostly just instantiation. Code where I've set up two logic adapters one, of them is custom so I can make that joke about the meaning of life that failed and then the other one is the mathematics, evaluation, in there and. It was pretty straightforward to tie the two together if we take a look here back in the code, and. We click Edit we can quickly take. A look at, the. Environment. Variables that we've got down here and we can see that I've got the bot URL right, here and that's just the URL of the other function that I'm gonna call so, I didn't need to embed that right in if I change the background function. There I can quickly get. That going later but, what we've seen here is a combination, of using. Node for what nodes good for using Python for what's pythons good for and, using environment, variables to make things a little bit more flexible, and then, all of this plugs into hangouts, chat so that you know I don't need to calculate how many grams of coffee to use when, I'm doing my 1 to 13 ratio of pour over I can just ask map math bot and it can get snarky with me but. So that's the end of this demo we can head back to the slide deck now and. I. Think it's back to you Jason I think, so. Thanks. Yeah. So. We'll just keep on rolling with the news the new things that we're adding for. Those people. Out there who have used cloud sequel, you may have bumped into this problem that we had with cloud functions, where it. Was pretty difficult to talk to cloud sequel, without doing a u-turn out to the Internet and back. So, we fixed that you. Now have a direct connection. To cloud. Sequel, you just use this socket. Path that you can see there slash cloud sequel /foo, is just the name of my database there, and. This would be, this. Would just be in your node code in this case it's JavaScript there's, a little. Weird thing there you may have picked up on this. Is creating a connection pool of size 1 why. Do I need a pool if it's only 1 and, that's. Really, a, side, effect of the fact that it's a service environment that's, going to scale up and down from.

From, 0 and up down up to some number and then back to 0 and so. If you're scaling up rapidly and and I'll talk a little bit more about this in, you know in a minute. You. Might overwhelm your database if each function, is creating, 10 database connections, and we we do the magic of scaling it up for you and suddenly. You dose your own database, so. We recommend a connection, size of 1 but we recommend you use a pool because it has some nice features like Auto reestablishing. Your connection if it fails. So, this was the previous world, we, would ask customers to do, this horrendous you, turn, out to the Internet and use SSL, to secure it and so on well no more of that now you can just go straight across and, that's a secure connection managed, by us. As. I was just talking before scaling, controls, is a new thing we're adding, this. Is exactly the scenario I just described, you have some nice evenly. Shaped traffic, notwithstanding the fact that my diagram is not even. Traffic's. Coming in the database is happy everyone's, happy you. Get some more traffic and we do a great job of scaling up for you but. Then of course your, database is overloaded, and, you can't deal with any more traffic so. What do you do in this situation, well, we're introducing, scaling, controls so you can actually, limit, the number. Of instances that your. Function is going to use why, would you want to do that why would you want to limit the traffic well the the simple sort. Of canonical example, is let's. Say you have one database and two. Functions and one function, is your really, important, production function, that you don't want to go down maybe it's what your mobile clients, are calling and, that's the important one and then maybe you have some other background. Function. Or some other analytics, or reporting, thing that, it, doesn't really matter if it doesn't succeed and maybe, it has a bug and it gets into a loop and it, causes us to scale up many instances, of this non important. Function, and it, causes the database to go down which causes, your really, important function to cease operating so in this case you would put scaling controls over that less important, function to, preserve the database to make sure that the traffic is prioritized.

For The more important one. I'm. Sorry. Yes. Yes, or you could use API throttling the question the comment, was or if there's the throttling limit in the API yes that would also be appropriate. So. The limits are per function. Default. Limit of up to a thousand, and. Then. You. Can change, it on / function basis. So. This is what it looks like with, the scaling control same sort of situation. Regular. Traffic coming in, but. Now new traffic that. The gray, vertical, line is representing, the boundary, of your scaling limit, that you've said well I don't want to scale beyond this limit so those, those. Boxes with the dotted line will not be created and. Your database stays happy. So. For. Myself I've. Wanted, scheduling, for, a really long time I know that all of you but, we're, really excited to talk today about cloud. Scheduler, and, cloud. Scheduler, allows you to schedule, HTTP. Or pub/sub tasks at. Variables. Starting. Down to one minute intervals it. Can invoke cloud functions, over HTTP, or over. Pub/sub and it, can also invoke App, Engine, on a rel to the URL so, this means that we can start setting up timers for events, that we want it to happen it is, you know like setting up cron jobs if, you have tasks, that need to happen at a certain interval. This, is the way in which you can set it up so first. We're going to take a look at how that looks for cloud, functions. You, create a scheduler, job, you. Name that, job. You, have a message body which is what, the body of the message will be when it's triggered and you, schedule. It you, can do that using. You. Know just an English, like grammar so you say everyone minutes you, specify, the URL that it's going to trigger and the HTTP method that is going to use to trigger it so now this, endpoint, is going to get triggered every. Single minute with post, so. If you have things that you need to do like, you know checking. An endpoint or, checking. Like, doing anything by, a batch job you, can schedule it this way for. App Engine it's a little bit different you'll. Notice the two biggest differences, or the relative URL in the service so with App Engine you can specify the specific relative.

URL. To, the service that you're going to be triggering and you can specify the service, because with App Engine you can deploy multiple services, to the same project, so, you, don't necessarily want to be triggering the default service I. Believe, that. The relative. URL, is the only or, no the schedule is probably the only thing that's, mandatory, but, you can go through the docs and take a look and see exactly, how you got to spin this up, but. It's really great it's intuitive. And I, really, love this capability and I think it expands a lot of the things, that we can build with our service offerings right now. We're. Gonna bring Deema. Up on stage quick round of applause for Deema and. Just. Don't. Worry about the fact that it says product marketing. Everyone. At Google writes code, thanks. You some big smiles okay. I will stick to this my hair so. Hey everyone I'm Deema. I know lead product marketing for cloud functions and let. Me show you a demo which, I built using some of those new features that Jason, and miles have just discussed I'm actually, I need some slides, I can we just please go back to the slide. Deck. Thank. You and. So. Sometimes you have to rely. On Jason. On. An external system as a part of your service, application, architecture, and I. Chose my sequel database in this case but that could be any third party API really. So. Imagine a scenario when your database goes down you. It could be due to an outage or a. Service. Part of your system scaling, out of proportion, and overwhelming. Your database so. You try to write something into the database and it fails what's. Next. So, you could you. Could actually, implement. Some retry logic, and. You can retry things immediately and this could help you when you are dealing with a small database, delay or small interaction and connectivity, but. What if your database, is totally slammed and you. Might not what you might not want to and. You have thousands of messages that failed you, might not want it overwhelm, it with additional, retries every, couple of few seconds. So. You, could actually in, that case you can save your, film messages to something like pipes up for example but, there's a problem which pops up it's really fast and your, retry logic will actually trigger right away possibly. Still too fast if, the database is down for an extended period of time, and. Obviously if you relied on the pub sub you actually. Would, have to recuse OHS messages, if they failed again so. When deal when you deal with an unknown amount of downtime you, might want to persist those messages into something like cloud storage so, that you can replay them later on, you take your time processing. Them so. To trigger this retry logic I'm scheduled you, can actually you, know stand up a VM and. You can create a virtual machine and things like Linux. Crontab have been around for, like. 50 years and, but. We're doing service here and what. If your chrome server goes down do. You have another one watching. This. Is where cloud scheduler, can really help so, let's let's say that action now if. Again please go back, to the demo. Slides. So. What you're looking at here is, front-end. Part of this damn it's, built in five days and all, it does it just visualizes. Messages moving between different components of the, of, the back-end architecture, in real time so. What we're going to do first we will send some load to, the HTTP. Endpoint which, is sitting in front of the database and all it does it writes some messages, to the my sequel database and, I just click the test button and. It. Sent a few requests, to the base and we should see and. There's obviously a lot it's a live demo so there's some latency involved okay there they are we see some blue. And green boxes appear here so the, blue box is the represent messages, that were sent to the database and the green ones are the corresponding, successful. Writes. So. When everything is working as expected we, would expect, to see the equal number of those boxes, which is exactly what we're seeing here now, let, me actually go to my project settings, and take, the database down to simulate the out an outage. So. This is I'm using cloud sequel just for the purpose of this demo so. What I'll do I'll just go ahead and restart it and that usually takes a few moments and. While, the database is restarting I'm going back to the visualizer. Up and sending a few more requests to the database. So. Now we, should we see some of the red, red boxes pop up here those. Represent messages, that failed and as, expected, because the database is down so. Those messages are saved to the dead letter Q which is built with pops-up, and cloud storage and they of course have another cloud function there which I'm not showing for simplicity all it does it, just saves, the messages as.

They Pop up on the pops, up pops up topic, so. Now what we can do we can go ahead and take a look at the dead letter Q and also create a cloud scheduler, job to rerun those failed messages. So. This is my cloud storage bucket and. That'll. Work use cloud storage bucket and sometimes it takes a moment for the UI, to refresh here so I'm just going to click refresh, button and we. Can see some of our failed messages they started to pop up pop up here with, the appropriate time stamps from a minute or so ago. So. We. Took after they can look at that let's go ahead and create a cloud scheduler job. I actually, pre-populated. All the values just to save time and as. You can see all you need to do here is it's really simple you just have to name it and I'm using hello next 18, here as a name set, up frequency, such as every, Friday afternoon or as in our case every minute and, also. Select target in our case the target is the HTTP, endpoint which, replace, the, failed messages. And. Now also go ahead and start, a timer here to track approximately. How much time we have left until that cloud, scheduled job fires off and, as, you can see here in the console hasn't run yet will in version. And it. Was really easy to I just wanted to reiterate it was super easy to create a, scheduled. Job with cloud scheduler so, we actually accomplished something very powerful here it was just a few clicks we now have this code that will run every minute go to the dead letter Q and and, try to replay failed, messages if any. So. I'm going to switch back to the Oh okay. So I guess the cloud scheduler job already triggered. So. For. My initial test I think it happens on top of every minute and so that was like an approximate, timer for, dramatic effect but, it already triggered and and. Actually. Successfully. Replayed all, of those failed messages. And. Now. Just to double-check I'll go back to the bucket and refresh, it and it should be empty yes, and it is empty as, expected so. Just. Switching back to the visualizer app and. As. You could see the it. Through plated successfully, and in, the real life scenario obviously if you, if, you're building this for reals and you've had a lot of failed, messages like thousands of them you, could there. Might be a situation that, when you're dead Laura Q holds, way more messages than you can actually replay within a minute so. That could be solved by either obviously, by either increasing, the. Time. Interval or introducing. Another cloud, storage bucket to hold messages. That are being processed replayed. And, the. Recap I just talked about this idea of how you can build a reliable, system using. Some of the primitives that we have available.

To You on GCP today and this. Pattern can be especially useful, when, you are. External, systems as a. Part of your implementation. Thank. You and back, to Jason miles. Thanks. Tina if we can go back to slides please oh is it slides Oh looks, the same okay. Let's. Just keep rolling. More on cloud functions access, and I am. So. We're also very. Excited, to, announce, V, PC access. Again. If anyone's used cloud functions, before you would have plausibly. Bumped into this limitation. Consider. You have some. Number of virtual. Machines GCE, instances. In cloud platform. Those. Instances. Let's say are all on, the same network that's great they can talk to each other and. Then you have a cloud function out here in the wild but, it cannot, talk to those virtual, machines for very, irrational. And complicated, network security reasons. Good. News is we've fixed that bug so. You can now connect. The cloud, function, via. A connection, service to. That, network a and, and, thereby. Grant access, from. The function to, any virtual machine on that network. Yes, so you just simply add the. Cloud function to the network and allows, you to egress to, transmit. Bytes from the function to to. The virtual machine. Very, simple command. Line at deploy, time, connected. V PC with, the name of the network and you're done. On. The side of security controls something. That we get asked for a lot. When. We started with cloud functions, when, we announced the beta last year I mentioned, before that one of the features that we wanted to promote. Was this ability to deploy a function, and give it an HTTP, URL and curl it straight away and it's, very very good for simplicity, and terrible, for security because. This, HTTP, function is invoked. Ball effectively. Globally, so. What we're introducing, now is I, am controls. On. The data plane itself, on the invoke, of a function. We have a new role, called, cloud functions invoker and, you can assign it to a particular user, in the in. The example, above I'm. Saying Alice, Alice. Can invoke my, function called hello world and in. The example below that's. Effectively, making it public we have a a special, string in cloud, platform called all users which, effectively says that all users have invoked permission, on my function and this means you can now deploy a cloud function that cannot be invoked by anyone, in the outside world and this is perfect, for sort, of function to function invocation use, cases. So. It looks like this outside. Traffic from the outside world comes into our serving stack, there's, an iam check which, checks does, this request have the appropriate credentials are those credentials authentic, and, if they are the. Function receives the request as normal the, same situation, applies if one, function is calling another function its. Identity will be verified by this I M check and its role verified. To make sure that it has the appropriate role on that function. Okay. That is. The bulk of the, regular, announcements, and. For. Those who were paying attention we had a number. So the N is just representing, the number it, doesn't really have a number and that's because this next bit is, not ready yet this, is a this is a sneak peek if anyone was in, the. Server spotlight, earlier. You, may have seen something in relation, to this and those who weren't you. Get to see it now. So. Coming, very soon, is. Service. Containers, we. Talked a little bit before about these, next generation runtimes.

In App Engine we talked about some. Commonalities. In the infrastructure. Underneath. All of that and and, this has been true actually, since day one of cloud functions, we. Actually accept. As an input into the, infrastructure, a docker image, and. So what we're going to be doing is exposing. That to, customers so you can, bring, along, with you any pre-built. Docker image you can use any base, image you like I mentioned before we, default to a bun - if you want alpine linux bring your app on linux you. Can arbitrary, system libraries arbitrary, language runtime but, everything else is the same you get the same server less execution, environment, you don't manage any servers you pay only when code is executing, all the, other bells and whistles that you saw before, the scheduling, the. Environment, variables while in variables, probably can do yourself, but. All, the surrounding, things are the same and you and you just bring your container, image and. Prove. That this is true I want. To invite stearin onstage to. Give you a demo. Thanks. Yes. Right. So we were brainstorming, this, demo and why would you use containers, when. GCF provides you node and Python well, maybe you have your. Own favorite programming. Language like go, or rust we try them it, works but, is that. What. If we could actually write, a. Cloud function, that, renders, a 3d, image based. On the URL parameter how, cool was that and to do that if we can switch to the. Demo screen to. Do that actually you wrote a very small HTTP. Function. Let. Me show you the code. Yeah. So. It's. A Python function but. Simply. It will execute a, 3d, software to, render an image out of a predefined, 3d, model and, so. This. Software is not in the cloud function, based, image the one that you get when you use the Python version of, code function, to. Use this software I had to. Put. It into the image of my function and to do that I simply. Wrote this you, know 10 lines of code of. That is. Literally, a docker file so that we describe, what. How to be how to build that container image so, first thing to note is that it starts from the. Official, Python, base image like nothing fancy here then, what I'm doing is I'm installing, a 3d. Software which is the C++ module. Of a on the moon too and, then I'm doing you know I'm starting my app and exposing. The right port and I'm starting the. App. So. Okay let's, deploy, dance so the first step would be to build, this. You know the dockerfile and the, code into a container image for the sake of time I already did that if I wanted to do it I would, have used darker, build. Build. Or. I could have used a cloud build that. That builds that for you in the cloud but, this image has, already been built, now I'm just going to deploy it to cloud, functions. Click. Load, entrance. Deploy, you, know that part the. New thing is - - image and. Then. I point, to my. Container. Image that I stored in Google Cloud registry. Looks. Good. Here. We are we are deploying the image to. Flood function so it should take around around. 30 minutes. Alright. So as. You see I could have used any programming. Language I want as long as I can build it into a container image I could have used any OS, package, I want as long as it's available in my. In. My image or even I could bring my own binary we have customers who have special, binaries. That they need to import into the upload function so, that's why they do they use containers to do that here. We have it so, let's click on it right. So, as I told you this this, function takes a URL parameter which, is the. Location. Because as we know we have many cloud necks coming so, today, we are in San Francisco. And. What's happening here it's that the 3d software is. Rendering, an image based on the input I give so. You, know the next one is in Tokyo I think, and. We. Have London, so quite. Quite nice, of course I also. All. Right I added all the three mothers for fun. It's. Okay. Yeah. In. The shooing this money all right thanks. That's. A 3d server error right there. That's. Container, on Google Cloud functions, you. Can sign up on. Geo, / service containers, to get access to it thank. You. Okay. That's basically the end just. To recap. We've. Talked, about a lot of things many, of them are available today.

Yeah, I'm sure many of you are going to go out there immediately, and start writing Python, cloud functions, Python, is available today no date is available today some of these other features are. Rolling out over the next couple of weeks. Just, check the cloud. Platform blog will be having blog posts coming out over the next few weeks with, instructions, on how to get them and if they're in early, access mode, then, how you can sign up. Thank. You very much. You.

2018-07-31 11:09

Show Video

Comments:

No functions for #golang? This does not look so good ...

Yay!

I really enjoyed this talk. In particular at 22:00 the Cloud Scheduler is very welcome! I upgraded gcloud alpha but sadly it's whitelist... would be great if you could add me to that list? (The API "cloudscheduler.googleapis.com" doesn't exist or you don't have permission to access it)

Serverless containers (37:00) support any langugage/library.

And what about Python?

serverless containers cool!!!

Other news