You can run that on App Engine? (Google Cloud Next '17)

[MUSIC PLAYING] JUSTIN BECKWITH: Hi, folks How’s it going? Congratulations, it’s Friday You made it Ah It’s been a really fun couple of days I know it’s been fun for me getting to talk to a lot of customers, see a lot of product announcements, a lot of demos, a lot of fantastic conversations And I’m really excited, today, to come talk about App Engine We’ve got a lot of good stuff going on here We’re going to be going through a couple of cool things you can do with App Engine Really, this is a product that’s been around for 10 years now, which, in the cloud space, is a really, really long time And from when it first came out to where we are now, a lot of things have happened The cloud has changed Technology has changed The kinds of applications that we need to build for our customers have fundamentally changed And really, what today about is digging in and understanding how App Engine has kind of changed with the times to make it a great platform for helping build your applications So let’s have a little bit of fun Before we get into fun, a little bit about myself My name is Justin Beckwith I’m a product manager at Google primarily, these days, actually working on App Engine So this is kind of– for the last few years, this has been my baby It’s very exciting If you want to get in touch with me, my Twitter information is up there, also, my GitHub handle All of the demos that we’re going to see today, and actually, a lot of the technology that we’re going to see today, it’s all open source And this is all part of one of the things that we’re trying to do, which is get more and more openness, more into the open source community And everything you’re going to see here, large parts of it, all open source So before we degrade in, just a little bit– before we go build demos on App Engine and learn a bunch of cool stuff, what is App Engine? At the end of the day, it’s a very simple way to take your code, give it to us, and run it on top of Google’s infrastructure at scale So really, the fundamental thing that we want you to walk away with is, you bring your code, and we handle running it on Google’s infrastructure And when you’re running it on Google’s infrastructure, what you’re really doing is running it inside of a data center that’s been proven out for almost the last 20 years, the same technology that’s been built for Google Search, Maps, Gmail All these things that we rely on day in and day out, we have proven infrastructure that’s gotten the job done for us at Google and proven methods for getting it done And we think we want to make it easy for you to do the same thing with App Engine So what would you build on top of App Engine? Well, there are a couple of sweet spots And we’ve seen that several Compute offerings today, and we’re going to get into those in a little bit But really, the sweet spot for App Engine is web applications and APIs So if you’re building a user-facing website, be it in Node.js, Ruby, PHP– you know, any of your traditional web languages– it’s really a great destination Because you can just build it, deploy it, and run it without having to think about the ops or scale It’s also become really popular back end for mobile applications There are some pretty canonical examples out there, folks like Snapchat, other gaming companies that are built on top of us It’s really easy to scale up very, very quickly on App Engine And it’s easy to get up and running very fast So it’s been a popular choice for mobile back ends With that really comes just, also, HTTP APIs Even if it’s not a traditional mobile back end, a lot of us, our applications are powered by APIs And App Engine integrates really nicely with Cloud Endpoints, another product that we announced a v2 of recently, which makes it easy to do things like metering, billing, logging, authentication, all sitting on top of your API And Cloud Functions and App Engine make a really nice fit together to go build those kinds of things And then lastly, it’s a great fit for line of business applications We’re working with a lot of enterprises today that have a ton of internal sites that they need to build quickly, maintain, and do it with a small staff that they don’t want to have to build up expertise in five different deployment systems And App Engine has been a great fit for that As a matter of fact, it’s running the majority of a lot of our internal apps that we have at Google, the user-facing web applications we use for a lot of our payroll systems, for our learning and management systems All of this stuff at Google is actually increasingly built on top of App Engine, and we think it’s great for other companies to do that as well So where does App Engine fit into the broader context of Compute? You know, we’ve heard a lot of announcements We saw the Cloud Functions announcement We have committed use discounts on virtual machines We’ve heard containers, containers, containers and Kubernetes over and over again Where does App Engine fit into this? And when is it a good choice to use? So we’ll start at the bottom of the pyramid When we think about virtual machines and we think about Compute Engine, really, what you’re running is infrastructure So if you’re an organization that’s picking up, and you’re moving something, a bunch of applications that were built on traditional virtual machines, and you want to pick that up and find a path to the cloud, usually, this is the easiest first step that you can take to get into the cloud If you want to think about infrastructure, you want to think about VMs, you want to think about networks, then this is a good fit One level up in that level of– in that level of abstraction, you’re going to have containers If you’re an organization that’s already familiar with Docker and you want to run a fleet of Docker containers efficiently across a fleet of machines, Kubernetes is a fantastic option Now, the next step up when you get to App Engine, this is where we start thinking less about infrastructure,

and we start specifically thinking about serverless-style architectures You want to hand us our code and ask Google to figure out the most efficient and cost effective way to go run that code for you And really, that’s what App Engine does Again, web applications and APIs– you give us the code, we run it And then at the top, if you have a system where you want to respond to very specific events– think WebHooks– or every time a file is written into a GCS bucket, you want to have a little bit of code that reacts to that, that’s where Cloud Functions becomes a perfect bet Instead of thinking at the application or service level, you’re now thinking at the function and event abstraction So this is just kind of the examples of the various levels of Compute we have and where I think your applications can fit in So with that– you know, it was a lot of talking– let’s get into it This one is seven or eight tricks I’m going to be honest, until last night, I didn’t have the eighth trick working So I wasn’t sure if I was going to have eight But we’ll see, at the end, if it worked out So trick number one, you can go from your code to production in a single command That command is gcloud app deploy Now, this is part of the Cloud SDK And this might be something that we take for granted, especially if you’ve been an App Engine user for a long time it’s been out there But when you think about what I would normally go through with a deployment, I could deploy to an individual virtual machine I could take these files and upload the one VM But what happens when my application gets popular and it needs to scale up? What happens when, maybe, there’s trouble in the zone where I’ve deployed my virtual machine? What happens when, you know, something changes with the– there’s a problem with the underlying disk? A lot of things can go wrong when we run on one instance And if we’re just deploying to a single machine, we’re putting our application, and potentially, our business, at risk And we need to think about a lot of these problems So when you create a deployment in App Engine, we’re going to do a couple of things We’re going to take your code We’re going to upload it to Google Cloud Storage We’re going to take that And you don’t need to understand anything about Docker to use App Engine But under the hood, what we’re actually doing is we’re building your code along with our runtimes that we build into a container And then that container gets pushed to Google Container Registry And now it’s available for all of your App Engine applications We set up a Google Cloud load balancer, which, this is new We’re now using the same Cloud load balancer across all of Google’s infrastructure is coming in the same path And then we’re going to take your application, and we’re going to run it in three availabilities zones Now, the reason that we do this is that there may be trouble in an individual zone at any point You know, generally, this stuff is very stable But sometimes things in individual zones happen So what we do is automatically, out of the box, configure App Engine to deploy to three different availability zones so that even if we do have a problem, your application is going to automatically rebalance and keep serving to your customers And then within each of those zones, they all independently autoscale So as the use of your application grows, and as traffic increases, and as that use contracts again, we’re going to automatically provision and release new instances to serve your application So along the way– so we just talked mainly about application instances and the autoscalers– there are a bunch of other things that we’re setting up out of the box, stuff that, when you deploy an app to that individual VM, you have to think about at one point or another You have to think about logging How are you capturing your logs? Where are you sending those logs? Is that log system going to scale? Can you query through it efficiently when you need to? When you think about autoscaling, what do you happen when you get popular? Traffic goes up Traffic comes back down Load balancing, monitoring, health checking, configuring SSL, these are all additional things that, when you go to set up a site or a deployment on your own, you have to internalize and you have to think about instead of building your application or focusing on your business And they’re all things that we aim to do with App Engine So one of the new things that we have– that we’ve had now for a couple– actually, for a couple of months we’ve been working on– or a couple of years– is the App Engine flexible environment So originally, App Engine was available in Go or Python, Java, and PHP And we’ve now expanded that to include Node.js, Ruby And the big announcement yesterday, of course, is .NET going beta on App Engine as well And you can even bring your own container And this is something that we’re going to get a chance to look at in a little bit One of the big changes we were able to announce yesterday is all these services that you can run your own Docker container, Node, Ruby, you can do all of this with a 99.95% SLA And that’s something that we’re able to offer because, as of yesterday, the App Engine flexible environment is GA It’s OK, you can clap [APPLAUSE] I need this Thank you So the first trick was gcloud app deploy, getting 99.95% SLA with a single command and not having to think about it Let’s dig in a little bit to the second trick And this is one of my favorite ones With App Engine, I can split traffic between multiple versions of my application So why is this important? Think about that deployment we just created So we pushed our code We got it out there We have our multi-zonal release We’ve got many instances It’s going great But now I’m ready to push a new version Well, how do I know that my new version doesn’t have a bug? How do I know that it isn’t going to bring my app crashing down when I do it? What I want to do is I want to deploy a second version of my application

I want to verify it out-of-band, both with tests, and I want to go do manual checks And then slowly, over time, I want to take just a little bit of traffic and start sending it to that new set of instances I want to make sure that it can scale up the way I expect it to I want to make sure that things don’t come crashing down when I want to monitor errors And then only when I’m ready, and only when I’m sure that this new deployment is good, I want to transition 100% of my traffic over to the new version, and then eventually, turn down the old one And what this is called is a no downtime upgrade And it’s something that’s very difficult to get right on your own, but one of the things, with App Engine, we make very simple Use gcloud app deploy You set a traffic split however you’d like to set it, verify, and then go to 100% And it’s really easy to set up So another reason that you might want to go off and use our traffic splitting feature is if you want to do something like AB testing So let’s imagine that I have an application out there I’m an online grocer, and I’m selling fruit to people And I’m trying to decide, which background image is going to cause my customers to come into my site and buy more fruit You know, what do they think is more delicious? What gets them salivating and buying things on my site? Is it apples? Is it cherries? Is it lemons? Or is it the deliciously pungent durian, you know? I don’t know I don’t know what’s going to go ahead and get them hungry So let’s actually– it’s demo time Let’s figure out how we can actually go build something like this on top of App Engine So what I’ve got here is I have a site that I’ve created on App Engine It’s got a single service This single service has four different versions of my application, each ones that I’ve deployed with the gcloud app deploy command And you see, I’ve got the cherry version, the apple version, durian, and lemon So if I click on “cherry,” every time I do that, I’m going to get a cherry Looks pretty good Makes me a little hungry It is lunchtime I can click on “apple,” and I’m going to get my apples And you get the point I can click on these individually And any one at a time, I can verify, is going to give me the fruit that it’s named after But right now, all of my customers are getting cherry So every time they come to the site, they’re going to get cherry How do I enable a traffic split to test out my hypothesis? You know, I’m going to go with the idea that I think Apple is a better fit I can select all the versions of my running application right now I can choose Split traffic And what I’m going to do is I’m going to go ahead and say, apple’s going to get 33% Lemon is going to get 33% And Durian, we’re going to put that at 1%, because we’re still testing I’m still unsure if the durian is a good choice or not And I’m going to go ahead and save this So while this is saving, the next thing that we’re going to do is we’re going to click on Services And we’re actually going to take a look at how this works So I have a single service right now, one service, many versions under it And I’m going to go ahead and launch this page And it looks like, OK, the first time, I got lemon The second time, I got cherry, and then apple, and so on and so forth So what we can actually do– the way I’ve set up this site is I want to be able to track this You know, maybe you don’t believe that we’re actually doing that traffic split exactly right So let’s go here And I’m going to go over to a dashboard that’s actually tracking all of the hits on this page And I see somebody hitting apple I don’t know if anyone was able, actually, to see that URL or not And so this is the point in the talk where I want everybody– usually speakers don’t like it when you’re on your phones or laptop I’m looking at you, guy with the laptop It wasn’t actually you Go ahead and get them out Get out your phone Get out your laptop And I want everyone to try this out And we’re going to watch it in real time and see what happens So I want everyone to go to– so– and let’s see– we’re watching people hit these pages, coming in real time Looks like, right now, apples are out to lead Cherries are catching up We’re going to keep doing this until that 1% person manages to– oh, who got the durian? Ah, come on, someone has to admit to it Somebody got the durian It was you Was it? Come on up Come up on stage You are the big winner I can’t believe it was you that actually won the durian That’s amazing What I have for you, sir, is an actual durian– [LAUGHTER] –that I got in Chinatown this morning So please do not cut that here Take that home AUDIENCE: [INAUDIBLE] JUSTIN BECKWITH: That was a lot heavier than I expected it to, I’m not going to lie Yeah Enterprise scenarios here folks, that’s what we’re focusing on this week All right, so that’s one of the ways that we can use traffic splitting to both do safe upgrades and to make sure that we have the best version of our site for A/B testing By the way, all those images– Creative Commons Thank you to the very nice people who made them They were beautiful So that was trick number two was traffic splitting Let’s take a look at trick number three And this is a big one As of this week, you can now run NET core applications on App Engine And that’s because ASP..NET, on App Engine yesterday,

went beta So what that means is that we have a .NET core runtime We’ve got a full list of tutorials, samples The same runtime you can use on App Engine, you can actually pick up and use it on Container Engine and run it there as well inside of a Linux VM All the client libraries– so the things that use to access services like Spanner, the Cloud Vision API, Datastore, all these services and APIs that we have out there are now available via NuGet packages on .NET And finally, some tooling– all of this is available You can learn about it on And it’s got all of that getting started documentation The runtimes, the client libraries, the docs, all of the stuff that we’re putting out there, it’s all on GitHub So you can actually go to, search for .NET, and you’re going to find all the source code that we used to go build all of this stuff And of course, the part that I want to take a little bit of time and look at that I think is the most interesting is the integration directly into Visual Studio So let’s take a look and try that out All right, so over here, I’m running Visual Studio This is– I believe it’s 2015 And I’ve got a hello world ASP.NET project up and running So I’m going to go ahead and Alt-Tab over to my web browser You can see it’s running on localhost And this is your traditional– for those of you that have done ASP.NET, you’re probably used to staring at this screen It’s the traditional file, new project, hello world template And what you can do, as of now, is if you go– if I want to– let’s say I’m ready to deploy to App Engine I can go to my project file I can right-click on that And I’m going get a couple of new options, but the one that we’re going to try is Publish hellogcp to Google Cloud Now, at this point, we’re going to give you the option We’re actually going to let you choose, do you want to deploy to App Engine flexible environment Do you want to deploy to Container Engine? And we’re also going to be rolling out support for doing this on Compute Engine soon as well And you can just pick one of these And wherever you want to deploy, click the button Tell us what you want to name the version We automatically provision one for you We’re going to automatically promote so that this goes straight to prod And when it’s done, I want it to go ahead and open the website and show me the site So as this is going off right now, we’re going to do the build It’s going to kick off the deployment process And while that happens, I want to take a look at a couple of other things So now, under Tools, we also have this Google Cloud Tools, and we have the Cloud Explorer and the Account Manager Let’s check out the Account Explorer This is kind of my favorite part From within– inside of Visual Studio, without having to go to the Google Developer– the Cloud Developer– console, I can get a list of all of my App Engine applications, each version that’s out there running You can see I already deployed this version earlier today I can see all of my Google Compute Engine virtual machines And I have options to interact with those and set settings on them I have all my Cloud Storage buckets and all of my Google Cloud SQL instances all right here inside of Visual Studio If you’re a .NET developer, we think this is something you’re really going to love So while we’re waiting for this to deploy, you can see I already have a version deployed out here Let’s go ahead and check it out running on Google Cloud So I can right-click and say Open the Running Service And there we have it, ASP.NET on App Engine All right, so trick number three was running .NET on App Engine Let’s get into trick number four Trick number four is, I can customize my operating system packages Now, what does this mean, and why is it as important? Traditionally, with Platform as a Service, one of the walls that we’ve run into is that you’ll get started, you deploy your hello world, your hello ASP.NET web application, you get up to a certain point, and you hit a wall There’s a library you need There is a language you want to use There’s some part of the system that you need to go beyond where, if you were on a virtual machine, you could do it But because you’re in a Platform as a Service offering, you get stuck Well, we don’t think you should have to get stuck when that happens So what we want to do is give you the ability to bring in any operating system package, and your Linux virtual machine, that you want to bring in And so as a way to show this off, what I want to do is talk about, there’s this application that I wanted to build I wanted to send everybody home with something And as it would turn out, that would have been a lot of durian if I’d have chosen that So instead, I want to send you all home with a Twitter card And this is a card you can make on your own It’s got the Next branding Take a picture And you can go ahead and put that on Twitter if you’d like to So let’s see what this looks like Let’s actually go ahead and give it a try So I’m going to go ahead to And what this is going to do is it’s going to use the webcam inside– on the web page I’m going to give a smile All right And this is going to go take– send my picture to App Engine, use a couple of custom tools, generate this card And then when I’m ready, I can go tweet it out– so pretty cool So how would I go and build something like this? How do I do the image manipulation? This is a very classic wall when you’re running up and building one of these apps The way that I was able to do it on my MacBook is I just ran brew install imagemagick, you know? Done It was amazing It works on my machine Ship it And then I went a little further, and I figured out, actually, I want GraphicsMagick, you know,

that sits on top of ImageMagick OK, so now I’m building up a lot of libraries Well, it worked locally But how do I get that onto App Engine? And this is where Docker comes to the rescue And let’s actually check it out and see how we would go build that So here is my local version of the web application This happens to be in Node.js by the way, but you could run it in whatever language you’d like to And if you look down, I’m going to go find the spot where I’m grabbing the image that gets posted to my site So it’s posting to this sendpic endpoint And then I’m going to save the file locally And then I’m going to go use the GraphicsMagick npm module, which has a dependency on that underlying binary being installed inside of my container So how do I do this? Well, what I’m going to do right now is go out to the command line And I’m going to go ahead into my Photobooth application You can see all of our files here And what I want to do is I want to grab the Docker file that App Engine is using under the hood to build my system Right now, the only thing that I’ve had to tell the App Engine is, here’s an app.yaml Please use Node.js for me But I want to control the Docker file So what I can do now is I can say gcloud beta app gen-config –custom We’re going to tell it to update my app.yaml And now, when I go back over here, I’m going to get a couple of new files I’m going to get this Docker file, which is a file that I didn’t have before And it really explains how we’re going to build your application I’m going to use the base Node.js image– again, open source on GitHub And we’re going to go ahead and install our dependencies I happen to use Yarn If you’re a Node.js person, then you know it’s kind of the hipster thing to do now So what we would need to do now is we need to add the part of code that’s going to install our client libraries So let’s give this a shot So what I’m going to have to say RUN apt-get install -y– ooh, I almost messed it up– apt-get update– update– and then apt-get install -y -q imagemagick and graphicsmagick Save, and that’s it When you take and gcloud app deploy this, because there’s this Docker file in my current working directory, it’s going to take that as a cue And instead of using the container that we were going to pop out, it’s going to use the base container and add our stuff on top of it And then if I want to try this out locally, I really even need anything quite like a local emulator I can actually just use the standard Docker toolchain to test this out and know that it’s going to work So I can go off and do my docker build -t myapp And I’m going to end up with a container that has everything I need, at which point, I can go ahead and docker run it When I’m ready to go to production again, gcloud app deploy And it’s going to be off to the races So again, we were able to just use gcloud app deploy We were able to build our own Docker container All we had to do was add a little bit of logic to install ImageMagick and GraphicsMagick And again, this is one of those times– everybody, get out your phone, or your laptop, or whatever You can go to and actually tweet out the card that you’re generating from this And I’m going to go ahead and do it as well I didn’t actually tweet out the last one, so let’s do that Or here, I’ll actually tweet this out So there we go Sweet Make a good face Make it look happy, people All right So trick number four, we were able to customize the operating system packages Trick number five, we’re actually going to take, and we’re going to make our app a little bit better So when you look at the application that I just ran, it was really a single App Engine service And it was a bit of a monolith, right? We had one code base that was responsible for accepting the uploads It was running image processing It was generating new images, writing things to GCS It was sending out links You know, this was one service that was doing a lot And you have to wonder, over time, what’s going to happen when I scale up? What if my web process needs fewer resources than the parts that’s doing image manipulation, which is most likely the case, right? Is my application going to be scaling as efficiently as it could be? What happens when I’m ready to deploy? I’ve introduced more risk Every part of my application is all bound in one thing, and I can’t separate it out So instead of just having one service that’s having problems and deploying one set of changes, I have to bring the whole thing up and put it all out at the same time So the next thing that you can– trick you can use on App Engine is building apps that use microservice-style architectures So the way this works is, on App Engine, every time I gcloud app deploy, I can choose to build another service And I can keep adding more and more of these to construct my application These services can talk to each other directly through HTTP, or they can use a worker queue system In my case, what I did is I took the front end, I separated it out into a front end process It’s only responsible for serving web traffic and accepting uploads of the image I then created a backend service with a different autoscaler and its own set of instances that

are responsible for taking images, running it through GraphicsMagick, and then sending out the links so that they get rendered in the page And then I connect the two using a worker queue pattern And I’m using Google Cloud Pub/Sub So by doing this, what I’m able to do is independently scale the front end of my application from the back end of my application making sure that I’m only using the resources that I need and reducing the amount of risk I have when I roll out new changes So to do this, we saw that file, app.yaml, which essentially described how I want App Engine to interpret the code that we’re sending it And what I had to tell it was, the runtime is Node, the environment is the App Engine flexible environment, and the name of my service is the frontend service And I had one of these for the back end as well And then when you’re ready, all you do is gcloud app deploy And you can run many of these within the same project using the same underlying resources But in this example, I used Node, because at this stage, JavaScript is the language I’m the most comfortable with What if you don’t want to use Node for your back end? What if it’s a different team building the back end than the front end? What if you want to use Perl? Well, that happens sometimes Sometimes you have an old piece of code laying around Or you have that guy on your team, or that girl on your team, who just needs to do it in Perl And on App Engine, this was another one of those walls of pahs that you would run into, but not anymore So the next trick that you can do on App Engine– number five was microservice-style architectures Number six is bring your own language to the platform– yes, even Perl So let’s try it Let’s do it All right I’m going to go over here I’m going to get out of my Photobooth application And I’m going to go into some demo Perl code that I wrote And let’s take a look at that All right, so here I have a very simple Perl-based web application It’s, I believe, Perl 5 It’s using a web framework called Mojolicious, which is fun to say And it’s essentially just a very simple web app It has a single handler that’s going off on the root of the web application And it’s going to render a template named “index” that I give it And over here in my templates directory, I have template.html.ep And it just says, “Welcome to Perl,” along with a fancy green background color And then, to make that work on App Engine, I really only needed to add two files So one is I had to add this app.yaml file, which we’ve already talked about This describes how, to App Engine– tells App Engine how to run the app We say, it’s a custom runtime Don’t use Node.js Don’t use Ruby I’m going to tell you how to go run this application We have the environment And then, I’m deploying multiple of these services within one app, because we’re actually going to try a few other languages And then, the way that we do a custom runtime is by providing our own Docker file The exact same way that we were able to customize Node, we can use that to bring our own language And so in this case, instead of using the built in App Engine base image in Docker, I’m just going to use the latest version of the Perl base image that’s out on Docker hub I’m going to install some dependencies, so I’m going to use Perl’s package management system to go install the Mojolicious library I’m going to tell it to listen on port 8080– this is a bit of a magic port on App Engine that says where your application is supposed to serve– add the source files, play around with permissions, and then finally, run the main Perl process And that’s it I can take this, run gcloud app deploy, and have a live version of Perl running on my app But let’s try it out Let’s see what actually happens So I deployed this, like most of these, earlier today And I’m going to go ahead and do a gcloud app services list, give you a little preview, maybe, of things that are to come We can see, one of them here is the Perl service And just to see this running out on App Engine, I can do gcloud app browse –service perl This is a little convenience command that’s going to go ahead and open it in the browser And so here we have Perl on App Engine [APPLAUSE] So Perl is fun But let’s say I have a little bit more of an earthbound scenario here You know, I’m not dealing with a legacy system Let’s say that you’re an iOS developer And you’ve spent all of these years building up expertise in iOS applications, tons of years getting used to, first, Objective-C. And now you’ve dove head first into Swift And you want to be able to take advantage of all this experience that you have building Swift applications on the client for the iPhone and use that in building your backend web applications Well, on App Engine, you can actually do that So what I’m going to try out now is I have a demo with a Swift web application Again, we’re going to run code, take a little bit of a lap around the source code, and see how it works out All right So in my sources, I have main.swift And this is using the Kitura web framework on top of Swift I’m going to build a new router object, create a route for my health checks,

and then add the HTTP server, telling it to listen on port 8080 Not a whole lot going on here, very simple app All right, so if we look at the Swift file, we can see the dependencies that we’re bringing in And we’re using the Kitura web framework, similar to how we were using Mojolicious on Perl, or Express on Node, or Rails on Ruby– same concept And then inside of my Docker file, even simpler this time, I’m able to take and just, from the base image that’s out there for Swift, add my source code, do a Swift build, tell it how to run, and we’re done We’re running Swift inside of Docker on our machine Let’s go ahead and try it out and see what it looks like So gcloud apps services list we did above This time, when I do gcloud app browse, I’m going to say service And we’re going to look for the one name “swift.” And here we have the hello world for Swift running up on App Engine So you’re able to take the code that you want, the languages you want to write in For seven of those, we have them built in But if there’s a language that you need to use that we don’t support, you can just go into a Docker container, five lines in a Docker file And pretty much any language, you can actually one on top of App Engine And this is what we described I can use my own Docker file I can take the existing runtimes we have and take it out Now, what’s interesting is you can take those out and actually even go run them on Kubernetes or run them in GCE The code that you build between these platforms is entirely portable You can let us build the container, or you can build it in your own infrastructure You can build in Jenkins or in your own CI system, then do the deployment Or we’ll do it You can publish your container to Google Container Registry And then, as I mentioned, these are very portable So if you look back at our application, we did a little bit of what I like to– we looked at, said, it’s a monolith Make it microservices The guy from Google said microservices are good But really, we didn’t really do any performance analysis to back up the fact that we had to go do that, right? So we split it out We did a lot of work If I wanted to go do that, we really haven’t asked the question, how is my application performing, and how can I go figure that out So let’s check out how we can go analyze the performance of our apps in production I’m going to go over here And I’m hoping that some of you used that Photobooth app Because if you didn’t, you didn’t generate enough load, and the demo’s going to go sideways, and it’s just going to be really bad All right, we had a couple of hits So here, I’m on the App Engine dashboard And what we’re taking a look at now is a whole bunch of metrics that help us understand how users are hitting our app This is actually the Photobooth app that we were just using, where we took the picture and it generated the Twitter card And we see we had a little bit of a traffic spike And we got up to a total of 10 requests there So, eh, 10– I’ll take it But what are some of the other metrics that we can dig into? I can take a look at the average latency And I can see how the latency breaks down from my requests at the 50th, 95th, the 99th percentile I can dig in and take a look at my CPU utilization and understand how that’s been acting If I go down into the Instances tab, I can see the current list of machine instances we’re running And I can even get really deep, detailed information about how the autoscaler is behaving Here we can see, I’m sitting at two machine-type instances We can take a look at our utilization If that utilization dips up over the green line, you can see it scaled up there for a second So I can even dig deep and understand how CPU utilization leads to me autoscaling my application up or down So that wasn’t a lot We didn’t really have to do much there, right? Like, I was using ImageMagick What did we have, like 10 requests at the peak? You know, that’s not a lot of QPS What if we wanted to kick this up a notch? What if I didn’t want to do images, you know? What could I do to peg the CPU a little bit more? Maybe I want to do video So let’s give that a shot and see what it might look like So last time, we did a static screen shot This time I’m going to go to– I actually don’t remember the URL The other one was “card.” Yeah, it wasn’t video, it was GIF That’s what it is We’re going to generate a GIF– And this one, instead of just taking an image, it’s going to record a video And the whole time, I’m going to talk I’m going to dance It’s going to be awesome Recording a video on stage– recording a video while recording a video And then, what we’re going to do is upload that video from the browser, send it to an application that I have running And then when it generates the card, instead of building a static image, what I want it to do is go build something that’s live And there we go And so I’m going to take this and post it to Twitter [APPLAUSE] Ah, thank you I was inspired by a movie about wizards where everything they read had moving pictures on it And I wanted that for myself So you can go to, generate one of these for yourself, and tweet it out if you’d like to But let’s talk about how I actually built that and why this might put a strain on my system So to build this, I chose to use FFmpeg, which is kind of like the Swiss army knife of video editing in the same way

that ImageMagick is the Swiss army knife for image processing But as you could imagine, when I started playing around with that, especially if any of you are trying it right now, FFmpeg takes a fair bit of CPU cycles This is video processing It tends to be very CPU-intensive work So that leads us to trick number seven of what you can build on App Engine, which is, you can actually– because it’s so CPU-intensive, I want to customize the underlying hardware And this is a new thing that you can do on top of App Engine in GA as of this week To do that, we’re taking advantage of Google Compute Engine’s custom machine type feature Now, what this lets us do is actually size our instances not based on a pre-canned set of machine types, but size our instance completely tailored to our needs So right now, we give you a preset version of CPU, memory, and disk that seems to work for most people But for my image– or for my video processing application, what I really needed is, I didn’t need as much memory When it came to disk, I wasn’t storing anything locally I was using Google Cloud Storage So I didn’t need much disk When it came to CPU, I needed a lot of CPU if we were going to handle a couple of people in a room for this talk And to specify that, all you need to do is, inside of that app.yaml file where you’re telling us the rest of how to build your app, just tell us, I need a lot of CPU, I need a little bit of memory And that’s it You can customize the hardware inside of your machine completely based on the needs of your application So let’s give it a try And if you want to give it– we already did this, but if you want to give it a try, you can go out to We can see if we can get it to scale up at the end, get it to scale all the way up And at the end, we can take a look at the stats You have to prime some statistics for me for the dashboard All right, so we’re getting towards the end now, and we’ve got seven tricks Our last one was customizing the underlying hardware It was 7 or 8 We got the last one to work I called on an old demo from last year, actually, to get this put together But if you look back through our application– I think I’ve used this slide a couple of times– we had a pretty simple app But you know, it was a pretty trivial app that we just built, right? There were two App Engine services, one Pub/Sub thing in the middle In production, our apps rarely end up actually looking like that This is kind of a contrived example A more classic example of what you’re going to go build is something that looks like this, you know? We’re going to have front ends We’re going to have back ends We’re going to have the queues We’re going to have APIs that we’re taking advantage of We’re going to have scalable file storage We’re going to have databases We’re going to have managed databases We’re going to have virtual machines that run that old piece of software that we couldn’t port You know, there are all kinds of different pieces in a real production service, along with duct tape, and baling wire, and love, that it takes to keep it running over time So to do this, one of the best parts about App Engine is that you have access to all of the APIs that are available inside of Google Cloud Spanner, we announced, Cloud Machine Learning, the Video Intelligence API, Pub/Sub, BigQuery, Vision API– there’s a big, long list of all the different things These are now all at your fingertips and simple to use from within of your App Engine application You don’t just have to use the services that come out of the box with App Engine It’s all of GCP GCP is the new Platform as a Service So to do that on Node.js, all I had to do was npm install google-cloud, and we had an npm module that had access to all those services Of course, if you’re in Python, pip If you’re in Ruby, gem And I kept going with this, but it was too many slides, you know? It’s available on all of those seven languages that we talked about earlier And you use this API, let’s say that I wanted to do something very simple Let’s say that I just wanted to be able to look at a picture and figure out what’s in that picture– traditionally, one of those problems that take an army of computer scientists eight years to solve Well, with Google Cloud, on App Engine, using the Vision API, I can do it in four lines of code– well, four lines of JavaScript I can do it in four lines of JavaScript We just bring in the library, detect the labels And then we can find out, is it a dog, a canine, a poodle But you don’t have to take my word for it We’re going to try it out So with access to these machine learning APIs, all this technology that we’ve built up at Google over the last two decades, all the intelligence, all the stuff in Google Photos, mail, inbox– you know, amazing technology now at our fingertips– we could actually go off, and we could change the world if we wanted to with this stuff I used it to build an app about my cat So let’s see what that looks like So I’m going to go to And what I wanted to find out is I wanted to find out if people found dogs or cats to be the cutest of animals And to do that, I decided to use the Cloud Vision API So what I’m going to do is I’m going to go off and read a bunch of data from Reddit, r/aww to be specific This is all real time You can go and check it out if you want to And we’re going to figure out, are there more pictures of dogs or cats on the aww subreddit So let’s give it a shot OK, so we’re downloading each of these images This is a front end process It has a back end Communication is through Pub/Sub And it’s using the Video API We’ve got our first response And it looks like we’ve got cats out to an early lead,

but the dogs are catching up Oh, there are a lot more puppies in this one than there usually are, so that’s good We’ve got sleepy kitty We’ve got a little bit of duplication going on, but that’s OK I think the dogs are back out to a lead We have a– I think that’s a Yoda cat That’s awesome We’ve got Jedi cat, dog in sunglasses And this is going to go on for a while And at the end of this, we’re going to be able to use the Cloud Vision API to break up and split out all of these different characteristics You know, all the chaos in these images, it can tell us dog, cat, neither, or both Cat with pancakes– that is amazing All right And let’s see, I have to wait until it gets to the end I have to know if the cats or the dogs win Too much anticipation All right, I’m just going to let it keep on chugging, and we’ll come back to this in a second So what did we learn today? The big things that I want you to come away with, and I’m hoping that you came away with, from this talk is that we really want you to be able to focus on your code You know, as developers, we really have to be thinking of our customers all the time We have to be focusing on doing what’s best for them, building our applications, focusing on our business Shouldn’t have to focus on infrastructure And that’s one of the goals, ultimately, that we have with App Engine I want you to be able to focus not only just on your code, but any code It shouldn’t be limited to the seven languages that we support We want you to be able to bring in anything Bring in your Perl Bring your Swift Bring your Elixir, whatever you need to run your application inside of the cloud to solve problems for your customers We want you to be able to break beyond PaaS So a lot of the limits that you traditionally think of when you run into a Platform as a Service offering, you shouldn’t have to put up with it There should be ways to use custom amounts of CPU, your own languages, bring your own container And lastly, we want to be able to liberate intelligence So we have access, now, to things like the Speech API, the Video API, the Vision API You can now use these, fold them into your applications, and use them to help solve real problems for your customers All the stuff that we did today, as I mentioned, is up on GitHub There’s a bunch more information at these links you have over here If you have questions for us, if you ever want talk to the App Engine team, we’re always available We’re always on our Slack room You can go here, to to sign up for that And we’re happy to answer questions for you any time And thank you [MUSIC PLAYING]