Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Google Cloud Functions & Firebase Crash Course

91 views

Published on

#Serverless #Toronto community members Matt Welke (https://www.linkedin.com/in/matt-welke/) and Kudz Murefu (https://www.linkedin.com/in/kudzanai-murefu-7b128886/) introduced Google Cloud Functions and #Firebase to the community at our August meetup. It was the true "by the people, for the people" event!

More info https://www.meetup.com/Serverless-Toronto/events/259718715/
Recording https://youtu.be/CorFCkcuPOI

Published in: Science
  • Be the first to comment

  • Be the first to like this

Google Cloud Functions & Firebase Crash Course

  1. 1. Monday, Aug 12, 2019 1. Intro & Activity Update 2. Community Open Mic 3. Matt Welke: “A look at Google Cloud Functions” 4. Kudz Murefu: “Firebase Crash Course” 5. Networking 1 ServerlessToronto.org Meetup Agenda
  2. 2. Why we do what we do? 2 Serverless is New Agile Serverless Dev (gluing other people’s APIs and managed services) We're obsessed helping Startups (and creating meaningful MVPs & products) We build bridges between Serverless Community (“Dev leg”), and Front-end & Voice- First folks (“UX leg”), and empower UX developers Achieve agility NOT by “sprinting” faster (like in Scrum), but by working smarter (by using bigger building blocks and less Ops)
  3. 3. #ServerlessTO Sponsors 3
  4. 4. Manning Publications 2019 giveaways: 1. www.manning.com/books/serverless-applications-with-nodejs 2. www.manning.com/livevideo/production-ready-serverless 3. www.manning.com/livevideo/production-ready-serverless 4. www.manning.com/livevideo/serverless-applications-with-AWS 5. www.manning.com/livevideo/serverless-applications-with-AWS 6. www.manning.com/books/serverless-architectures-on-aws 7. www.manning.com/books/http2-in-action 8. www.manning.com/books/event-streams-in-action 9. www.manning.com/books/the-design-of-everyday-apis 10. www.manning.com/livevideo/graphql-in-motion 11. www.manning.com/books/voice-applications-for-alexa-and-google-assistant 12. www.manning.com/livevideo/machine-learning-for-mere-mortals 13. www.manning.com/books/classic-computer-science-problems-in-python 14. www.manning.com/books/getting-mean-with-mongo-express-angular-and-node 4Check out MEAP program from our Learning Sponsor!
  5. 5. Venue Sponsor 5 As Certified B Corporation, Myplanet is purpose-driven and creates benefit for all stakeholders, not just shareholders!
  6. 6. Catering Sponsor 6 Also an active Serverless Community member – check out their “Data Pipelines using Serverless Architectures” talk!
  7. 7. Devinity 7
  8. 8. Devinity… continued 8
  9. 9. Community Open Mic 9 10 seconds of freedom to pitch yourself, or your company
  10. 10. Future Talks 2019 10
  11. 11. Upcoming Serverless Toronto Meetups 11 1. September 12, 2019: Serverless Design Patterns and Best Practices – Mike Apted, Startup SA at AWS 2. October, 2019: Serverless CI/CD pipelines with AWS CodePipeline and CodeBuild, vs CircleCI, vs Travis, vs Seed – Frank Wang & Jay V 3. November or December: Serverless Heroes (authors of “Serverless Applications with Node.js”) Slobodan Stojanović & Aleksandar Simović will be here! 4. December or January, 2020: re:Invent recap – Jonathan Dion, Senior Technical Evangelist at AWS
  12. 12. Feature Talks 1. Google Cloud Functions 2. Firebase Crash Course 12
  13. 13. Intro to Google Cloud Functions Using gcloud to deploy a Node.js function with CORS support.
  14. 14. Google Cloud Functions Triggers - HTTP trigger - Respond to HTTP request - PubSub trigger - React (asynchronously) to message - Storage - React to object added to bucket etc - Firebase event triggers Stateless - Runs on temporary container with no persistent disk. - Cannot run background tasks after response sent
  15. 15. Google Cloud Functions Scaling - Stays at 0 running containers when not triggered - Scales up infinitely* as requests/messages come in - Charged per 100ms of code running per backing container
  16. 16. Interacting with Google Cloud Web Console: - See which cloud resources you have - Explore marketplace gcloud: - CLI tool that can list, create, and destroy cloud resources - Can be used to automate
  17. 17. Demo
  18. 18. Demo - CORS browser server request Access-Control-Allow-Origin: http://localhost:8080 1 2
  19. 19. Demo - CORS (OPTIONS preflight) browser server OPTIONS preflight request Access-Control-Allow-Origin: http://localhost:8080 Access-Control-Allow-Methods: POST Access-Control-Allow-Headers: Content-Type 1 2 POST request Access-Control-Allow-Origin: http://localhost:8080 3 4
  20. 20. AWS Lambda Comparison Similarities - Scale down to zero containers when not in use - Charge per 100ms - Only allow one request per container at a time - Be careful with SQL connections! - Be careful of expensive long running functions - Support HTTP APIs and reacting to cloud events
  21. 21. AWS Lambda Comparison Similarities - Support multiple runtimes - GCP: Node.js, Python, Go - AWS: Node.js, Python, Ruby, Java, Go, .NET Core (C#), custom runtimes - Allow long running tasks - AWS: 15 minutes (30 seconds for HTTP) - GCP: 9 minutes (HTTP + events)
  22. 22. AWS Lambda Comparison API Gateway - AWS function API Gateway (configurable) browser
  23. 23. AWS Lambda Comparison API Gateway - GCP function API Gateway (non-configurable) browser - Parse request based on Content-Type - Provide HTTPS endpoint
  24. 24. AWS Lambda Comparison API Gateway - GCP functionbrowser dev perspective
  25. 25. Thank you Finished code: https://github.com/welkie/talk-serverless-toronto-gcp-intro LinkedIn: https://www.linkedin.com/in/matt-welke/ Blog: https://mattwelke.com Email: mattwelke@gmail.com
  26. 26. Serverless on Firebase Realtime database | Cloud Hosting | Functions
  27. 27. Realtime Database ➔ Nosql Cloud-hosted database. ➔ Clients share one database instance. ➔ Connected clients receive updates on data changes. ➔ Scale to 100,000 concurrent connections.
  28. 28. Web Hosting ➔ Easily deploy static/dynamic web apps to a global CDN ➔ SSL built into Firebase Hosting ➔ Can pair with cloud functions to build microservices. ➔ Provides full versioning and release management with one-click rollbacks.
  29. 29. Deploy Single page apps Support for production grade dynamic single page apps
  30. 30. Firebase Storage ➔ Object storage service built for Google Cloud Storage. ➔ Robust uploads & downloads, restart where they stopped, saving your users time and bandwidth. ➔ Built on same infrastructure powering Spotify and Google Photos. ➔ Storage scales automatically, so no need to migrate to any other provider
  31. 31. Firebase Cloud Functions ➔ Run backend code in response to events triggered by Firebase features and HTTPS requests. ➔ Automatically scales up computing resources to match the usage patterns of your users. ➔ As load fluctuates(+/-), Google responds by rapidly scaling the number of virtual server instances needed to run your function. ➔ Code is in Javascript & Typescript currently
  32. 32. Console Overview
  33. 33. Firebase console dashboard
  34. 34. Realtime database dashboard
  35. 35. Firebase functions dashboard
  36. 36. Function console logs
  37. 37. Pairing Cloud Functions with Firebase features
  38. 38. Realtime Database triggers ➔ A change occurs in the database and an event is triggered. ➔ Function is invoked when the event occurs and performs its tasks. ➔ Function receives a data object that contains a snapshot of the data stored in the specified document.
  39. 39. Event handlers onWrite() On data create, update, or delete. onCreate() On new data is creation. onUpdate() On data is updated. onDelete() On data is deleted. Listen for specific events on the Realtime Database:
  40. 40. Cloud Storage triggers ➔ Upload object to storage bucket. ➔ Manipulate the object & its metadata in the function. ➔ Write object location to Realtime database. ➔ Re-upload updated object back to storage.
  41. 41. Demo
  42. 42. Pricing Free Pay as you go
  43. 43. Thank you LinkedIn: https://www.linkedin.com/in/kudzanai-murefu-7b128886/ My latest project: https://strma.io

×