About the talk
Are you a web or mobile backend developer on a small and/or growing team? In this session, you'll learn how to use the right compute tools as your project grows from idea, to minimal viable product, to distributed production service on Google Cloud Platform - to save costs, optimize throughput, and best utilize developer resources. From Google App Engine to Cloud Functions, virtual machines to Kubernetes, this talk will help you pick the right compute tools for the job based on your vision and scale.
Hi everyone. Thanks so much for joining us today. How are you doing? They're going to be talking to you about growing your app on gcp. First I'd like to introduce aaja aaja as a developer Advocate Rodger loves Ruby dinosaurs robots. And of course cats. And this is miles miles is developer Advocate on the cloud team with me and he's also the director of the note Jazz technical steering committee and he loves music and getting dim sum with his text friends. In fact earlier this week. We stumbled across them some randomly on the Google campus. We
had to pause a rehearsal so we can have dumplings before we can continue. I hate them all. Adopting it as your user base shifts. We know that picking the right tools for the job at the right time is a balancing act of costs versus benefits versus skill sets. And today we're here to show you the Google Cloud platform is products that will work for you. No matter what phase you are at and what your current struggles are. So once upon a time there was a startup.
cat facts has anyone heard of cat facts before raising hands too few of you. We might be old miles forgetting facts about cats. Butters cat facts app NBC we're running on some provider somewhere in a VM because originally were running on my laptop and we've got some of us in the database me up or I'll running in that environment because that's how I had it on my laptop and reason. Because miles and reasoning some nosql database because I don't want to deal with having to keep a schema consistent and having to deal with this game at those were
rapidly iterating on this thing and we're going to email integration through third parties. I don't want to deal with email. So like cats the vans that we use are a little temperamental. We only have one at a time. It's very precious. But it also, you know can get kind of angry if you try to pet it too quickly and we really have to take care of it. There's no real rooms when you have a single virtual machine for errors. So why was going to show his quick what the MVP? You are not familiar with the joy that is cat facts, so. Says you can see here.
We have cat facts. You're going to sign up for cat facts with your email address need to make one. Oh my God cats. Biz. Oh my God a cat stop this we're going to submit it now. Once we've submitted it. We subscribe to cat facts. We're going to get a response letting us know that we've successfully subscribe and then every single day we're going to get an email with a new fact and a new cat with a new cat fact back to you, Audra. Bring Smiles, so I can't fax app wants to move to the cloud and we're going to be using to sleep because we're here
at Google IO. So what are the reasons folks might want to move to the cloud into gcp. Why don't I hear a lot of people's investors want them to investors are familiar with the cloud and they know that it gives you a lot of flexibility to grow rapidly at your app to suddenly takes off and it's also a relatively easy to get an idea of what costs will be the coldest known in people are comfortable with it. Now, you might also want to move to Cloud because you don't have an obstacle more cat facts. It's just the two of us. We don't really have enough Steam and you might want to see because
you trust Google, you know, that Giuseppe is running on the same Hardware in the same data centers where we were on YouTube and search in Gmail and we keep those Ups 2 So we have a VM to run to the arms on gcp we're going to be using Google compute engine. This is Google's on the cloud service and we can pick it exact combination of CPU and RAM. That's right for serving her cat facts. And so I'm going to pick something that looks like my dad box cuz I know that works. So if we want to move a VM over to Google Cloud platform, there's a couple different ways
that we can do it. We can spit up a whole fractured hand and maintain it by hand and build everything up or we can try to find a way to orchestrated. This can be through tools such as ansible Chef or puppet or you can have file system images that you move over but it is going to be a manual process to move this over. GM's are awesome, though. There's a lot of things that I like about 2 p.m. You've really fast startup time. So you could see from the second that you spit up. The VM is going to be like 30 seconds until it's available ready-to-use and once it's running it's
available all the time. You don't have to worry about how fast is going to boot up after that from that you can make images and quickly boot up in the future at any time. You can also customize the specs you can customize how much memory you're going to have him to see if you you're going to have and you can really dial it in if you need graphics cards, you can do that to you need if you need to keep use for doing tensorflow. You can do that. It's extremely flexible. You can make it as big or as small as you want and is very familiar. So if you know, you know the invention environment or Windows
Server, you can just get that spot up quickly and be working in an environment that you know, Tell me what's the stuff to consider here. We have to consider Process Management security updates upgrades. We need to consider scaling we have to be responsible for doing all of those security patches. If something bad happens, I don't know how many of you guys were working in the industry would hardly happened. But I was working Consulting at that point. That was a very frantic morning for us as we passed the whole bunch of yams. You don't know what you're dealing with
Dion's you have to do backups have to disaster recovery and provisioning and you have to do database replication. And that's always been my least favorite Ops task is database replication is just the two of us and we don't have the time to deal with all of that stuff. So we're going to move to highly managed services. And specifically I want to start with a database cuz I really don't want a database replication. So we're going to move to one of Google's types of managed databases where we can get the services like that and some of our Disaster Recovery. I taken care of for us, you know
how to SQL and nosql options. We specifically have Cloud SQL and arts in a relational model and we support both my cycling postgres. And if you have something that's very high throughput need to do a lot of rides you need consistency and you need to be global scale without spanner, which is amazing. It can do so much stuff and it almost violates the cap theorem, but not quite in the way of data store, which is there no sequel data. Which is our nose people option. That's actually what we're going to be using in this demo and it wheels of fire sword is not on the side, but is part of
Firebase and is very similar to datastore. So now that we have the database moved over we want to figure out where to run the application how many people in the audience have used a pension before the prison and all the amazing benefits about moving to happen if it happens in is are managed platform-as-a-service. We love we love because there's no Ops it has integrated data store. When you Deploy on Athens and you at HTTP already ready for you you an idiomatic run time. So I love this is a node js developer. I can write my know Jas app. I can test it
locally and then I can apply to the car is going to run exactly the way that I expected to run and if I need to run it somewhere else is going to just work also all the container images that we use for a pension flexor all available on GitHub. So if you want a fork then if you want to answer them, it's easy for you to do that. So now we got someone else dealing with the applicant operations of are at and we demo for you but the demo for showing it running on app engine is nothing has changed. Skip that part so now we can get some more app and add new features which is what is an
application developer really want to be doing I want to make cool stuff. I don't want to deal with pagers. So what is your app or app males you cat facts and we don't really have to run the mailer in the front end on the same machine somos we can talk about what we're going to do next with the mail. So when we originally wrote this application for mdp will as we said we had everything in a VM the database was in the DM the single note app did everything and this isn't super flexible. It's not going to stay all nicely it's not going to have nice abstractions and it's not going to be
reusable. So one of the first things that we decided to abstract out once you moved over to a pension was our cat back as a service so we were able to go and maybe I should do you want to describe it gives a Miller and sweet also moved some other stuff there. But the first thing we need to do is to build out a function to get us cat facts. So this is some code to retrieve cat facts from the database and a picture to go with it. You can see Really basic data store queries here because we're ordering on
experience sew-in you saw the devil where I signed up with my email address. I want to get the response from the server giving me the confirmation that I've signed up we do that once your email addresses and David store, but once that's done, we don't need to wait for an email to go out to actually send a confirmation to the user. So we send a message out on pubsub to send an email and we have this generic email server that creates. And sends a request with the data to that's who the emails going to from the Teutons emailing it the subject and the body and this can be actually
reuse throat or application. So the exact same function is running to send an email when you subscribe and it's also sending an email every single day whenever new fax go out and buy some by splitting it out into a cloud function is able to scale up with our load as we have more people subscribing is able to be used for different things and it's able to be its own code that we can think about independently. And if we ever want to change your email service, for example, we could just change the cloud function as long as we adhere to the same API the rest of the services don't need to change it
all. And so we talked about adding new features and one of the things I wanted to add was cat facts spot cuz I really like chatbots there. A lot of fun and RTM uses Hangouts chat super cool. And so I've heard a Hangouts chat bot. And what are the interesting things? Is that both email her and the Bots use the same underlying cat fax service and all the hangers chatbot does is it reformats the fact and picture payload into the forum in Hangouts chat requires. All I have to do is call out to the to the cat fax service get a fax back and then send back a 200 with the Json package the exact
Hangouts chat expects it and I had a chat bot. It was a really fast and really easy and because it's running and Cloud functions. If 100000 people hit my my hangouts chat bot to get their shots at the same time. It's fine. And if no one's using my chat my cat facts chatbot because no one wants cat facts right now. That's also fine Cloud functions with scale automatically to what I need at the time and so i r e I don't know if cat facts is going to take off maybe people don't want cat facts in there chatbots. But most can actually show you that that chatbot right now and you're not going to
see pictures of my cats. So here you can see we are in Hangouts chat and we've got to check in with the boss like a boss. Give me a cat. And the Box going to think about it for a second. It's making a call to the cloud function. It's getting the data from the cloud function that comes back with a cat and the fact that each cat and owner has their own unique vocabulary and we can message it again. Hey more cats blocks, and we give it a second to think about a new cat and a new fax and it gets back to us.
With the same cat in the same fact, and that's how you know that this is a real demo. back to you Asha So what happened? There is we have we had a lot of time out. I did not actually sufficiently put enough time in my chatbots. You do the update on my query cuz we're trying to pull them up least recently used to bargain. Yesterday, but I'm sorry that you guys all the broken version but you know, it's real. So we've been talkin through all these different services but we thought that this diagram would kind of gives a clear idea of how we are protected in a
front-end that's written in know Jasmine Express that's running on a pension that's taking use a request and when you sign up it's adding a user to big table and then it's requesting a cat fact from the cat facts function and then it's submitting an event to do pubsub to let it know to send an email pubsub is then triggering the function that's listening for new email events and emailing it out. Now the task scheduler is in another app engine app. If you didn't know you can actually make run jobs using a pension to set it up to execute a
pathogen rest calls based on certain amount of time does task scheduler set to run on a daily basis every single day. It gets the list of all the people who have subscribed and then it sets a new task in the pub sub to you for every single person to send them. A new fact the email her goes and grabs the cat fact and sends it out. What's really cool about this too though is you'll notice that we have multiple Services calling to the cashback service. So we have the chat bot, which is also calling to the cat facts service and we can build a whole Fleet of services regarding cat facts
depending on the kind of service. Do I need to use it we can make email or SMS chatbot IRC Bots and they could all use the same micro service that can scale up based on how much love there is maybe we find out that people don't like, you know anymore and we need to Pivot the SMS. We're ready to do that and we don't have to do much refactoring to her actual architecture in order to support that. So at this point, let's just pretend that cat box is the new hotness and it is wildly successful and we have hundreds of millions of users get in there cat facts and cat pictures on a daily basis. So
if that happened which we hope will happen. We're going to be able to hire someone help us with operations. I want to talk to my friends who work in operations. One of them said we need to consider Google kubernetes engine. I was talking to her about it and she will give us more flexibility with architecture many of the benefits of a pension in Cloud functions and it was specially work well for us because we've already moved toward of microservices architecture with a bunch of different scalable components. So so you may be asking yourself. What's a kubernetes
how many people so far? You're not asking what's a kubernetes those who haven't kubernetes is the Greek word. I believe for Helmsman. It's in the ciencias to call date of computerization and it's for orchestrating and scaling Docker containers in production. It's a way of setting up Cloud architecture and its design based on the Google internal architecture board. So a lot of the lessons and things that we've learned about making scalable Services, we're all used to
inspire the architecture of kubernetes. Arnette slide we're going to show what a Jama file looks like for that. The big thing to be aware with is kubernetes in this is the thing that a lot of folks find challenging at first is it unlikely and you're doing scripting to make your VM is reproducible all that's focused on how you want to install this thing. And then this thing and then you want to change these ports and you want to set up this kind of load balancer kubernetes. You need to describe.
What a good state is for your product. This many versions of this container. This many versions of this container this kind of load balancer and it will cover Denny's best for you as it does everything in its power to keep that Happy State so I won't even though it's magically one of your GM's gets hit by lightning in the center of your data center. It could happen is we'll take what was running on that on that DM on that note and it will put it to other places in a way to make sure that your app is as close to that running state that happy state that you wanted to be and it takes a
little bit of work for a lot of people to get their head around the fact that you don't explain how to get there you use the concepts that are built into kubernetes pods services. describe what a successfully running app looks like so she did a bit in that example. I was actually using the nginx docker container. What's a Docker was one of the things that I asked people trying to teach me about fear for Daddy's Hands. Docker is a container and it has a container format in the container is
how to bring up run time and the files and dependencies to go with it. And then I think about is you can put multiple of them on a VM and you don't have to deal with dependency complex. Like I know when I was working in Ops for the things we have is we had like three different parts of the service different microservices in the each releasing slightly different versions of various ruby gems or slightly different versions of various C libraries and installing them together side by side with a problem going to get like three different teams actually agree on which version we're going to
standardize on with Dr. You could just package up an app with its dependencies and run it next to an app with slightly different are very different dependencies on the same machine and you get much better utilization and you get safety the other nice thing about using containers and Docker is that since your packaging and container you seem to have less problems with the works in Devon doesn't work in Broad situation, which I know I have spent many hours banging my head against and when you read about this, you're going to see stuff about namespaces and cgroups and all that but the big thing
is running application with its dependencies and its filesystem all packaged up neatly. So what you can see up on the screen now is a fairly straightforward dockerfile. We're starting from an image. That's actually published by the note. Jazz project. Carbon is the eight. X Branch for LTS. And if you go from nodejs carbon Alpine what that means is we're going to grab the latest published version of eight. X of node running on an Alpine base operating system in Alpine is a very very thin operating system that's
been designed specifically for running in Docker containers. If you're looking for a fast boots and Finn images Alpine is a good place to get started were copying the file system from the folder that we're running in directly into the image. We're going to run the command npm install production that production side make sure that you're dead dependencies don't get installed and it's important to run all of the commands to set up your environment before you're actually running a production. So this is going to make sure that all the dependencies you need her there that there's nothing in that
image that you don't need for running. Then the command npm start is going to boot everything up so that command gets run when the docker container is started is a really great way to boot things up. It's something you put in your package Json script if anyone has more questions about kind of best practices for setting up note applications. Please feel free to grab me after the talk. So one of the things I mentioned in And you might be thinking what to see group and that's out of scope for this talking. So you think you can come talk to me, there's containers office hours and
there's also office hours on Google Cloud open source projects in the office hours space and folks from the kubernetes project will be there if you want to talk in detail about the implementation. So why would you make a switch to kubernetes? This is a question. I get the most when I'm out in the field talking to Folks at events where I'm at. Box meet ups. And the first thing I want to say is you don't have to lose a lot of folks out. There were like kubernetes is the new hotness. I have to use kubernetes and if what you have works for you great at Vengeance Club function. F engine Cloud
functions or yams or any combination of those like we had our cat facts. There are fine way to run your app indefinitely if it works don't fix it, but containers provide some advantages around portability predictability and utilization and I've seen a lot of success with teams that have switch to this the big thing that I've seen for my dog coughs friends is that they're getting better utilization out of their VMS. They're able to use all of the CPU and all of the memory that they provision less of an issue with JCP because Google can't answer unless you specify and make custom GM's that
exactly fit your app. But if you have things that are really variable and load or you've got a bunch of times and all look the same for A reason might be a way to solve that problem. And if you decided to go with containers for any of these are other reasons kubernetes is a great way to manage the bin packing problem with putting things in there and making sure that everything stays up. I really like it. If you specify known good state it will take care of making that known good State maintained for you. Even if something weird happens to some of your machines. So some concluding
thoughts about all the things that we just said. Google Cloud platform is kind of like a delicious dim sum Buffet. Bear with me on this you have lots of different options and you can pick them all depending on your tastes as you need more there there there on the cart. They're steamed the ready to go. You need more siomai. We've got more siomai and it's really easy to share you with big projects. You can add more people to the projects. They can grab the dumplings if they want them really Hungry Jacks lunchtime almost as much about dumplings
as I think about compute, but I also like to not have to think about how I make the dumplings. I just want to eat them and that really becomes one of the great benefits about using a popcorn like this. If you need to focus on your MVP, if you need to focus on the product that you're getting out of the door and your product isn't operations, you may want to be just using all these things that are ready to go you can generate off of them as necessary and you can make architecture decisions to make sure that you are not super locked into things that are harder to move. We have a lot of
different products available for you today to run your computer in all sorts of different ways based on your needs. So we went through a lot of stuff really quickly and one of the things I want to make sure everyone knows is that if you choose one of these things it doesn't mean you can't change your mind later on all of these things play. Well together projects that use a lot of them are here to the high level summary about we just talked about so we got the computer Google compute engine virtual machines in custom sizes of talking to someone and they are done the math and he's over six
thousand ways. I think I can figure something different flavors of yam or if you just want to pick up something that you're running in a few. I'm on your local machine and shove it in the super adduction application platform. It's solution to running your app and you won't fully managed Services you want networking taken care of you want auto-scaling you want the ability to use? Images that are known to have the Google has endorsed and we were make sure we're maintaining or making sure we're patching and things
like that. We've driven serverless applications or for event-driven parts of your application for tasks that need High scale some of the time in a largely scale is especially good if you have something you need to run a lot at once and not a lot later on because you can show up as much for that pipe is you need to or as little it depends on what you're used to it and it's really great for that. And then we have Google kubernetes engine. This is managed kubernetes on Google compute engine. This is absolutely one of the easiest ways to get started with containers and kubernetes is how I got
started and it's really really good because we take care of a lot of the stuff for you while he's lots of folks involved in the kubernetes project both inside and outside. Google Google is still very involved and the team that builds Google kubernetes engine works with the team is working on kubernetes to make sure that everything is smooth. So we want to say thank you in before we actually say thank you to you all for attending I would actually really think all the food for making this possible. We've got fantastic stop running the lights and running the camera for live streaming
producing in this room. So if y'all could give them a round of applause I'd be grateful. And thank you all for coming and getting us, you know, 45 minutes of your wonderful day today at Google. I hope you have a wonderful afternoon.
Buy this talk
Access to all the recordings of the event
Buy this video
With ConferenceCast.tv, you get access to our library of the world's best conference talks.