ive Serverless Patterns Design and Use Patterns in Serverless Jesse Butler Cloud Developer Advocate, Oracle Cloud Infrastructure cloudnative.oracle.com @jlb13
A presentation at Serverless Seattle Meetup in April 2019 in Seattle, WA, USA by Jesse Butler
 
                ive Serverless Patterns Design and Use Patterns in Serverless Jesse Butler Cloud Developer Advocate, Oracle Cloud Infrastructure cloudnative.oracle.com @jlb13
 
                Level Set • Roles in the room? • Serverless users? • In production? • Lambda? Azure? Something Else? Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13 2
 
                Monolithic Applications Users Application Database Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
 
                Monolithic Applications Users Application Database Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
 
                Virtualization and Consolidation Abstractions Containers Virtual machines Bare Metal To the Cloud Decreasing concern (and control) over infrastructure implementation Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13 5
 
                Microservices Deploying Code to Systems We Build in the Cloud with Containers and Kubernetes Load balancer Service Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Service Service Database Queue @jlb13
 
                Serverless Deploying Code to Systems We Build in the Cloud with Containers and Kubernetes Load balancer Service Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Service Service Database Queue @jlb13
 
                Trend towards Serverless Functions Abstractions Containers Virtual machines Bare Metal To the Cloud Infrastructure implementation and maintenance responsibility Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13 8
 
                Serverless is a Spectrum Container Orchestration Kubernetes Nomad Docker Swarm Ideally managed, but still infrastructure you care about Fully aware Container Services ECS, Fargate Azure CS GCP Cloud Run DIY FaaS OpenFaaS Fn Project Managed service provision containers, abstracts infrastructure you care about Leverage container management system under the covers, introduce Functions architecture Awareness of infrastructure Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Managed Serverless AWS Lambda Azure Functions Google Functions Oracle Functions Fully managed platform for hosting and executing code Invisible @jlb13 9
 
                Containers are the new Process Model, Right? Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13 10
 
                Containers are the new Process Model, Right? Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13 11
 
                Don’t Conflate Requirements with Complexity Aversion Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13 12
 
                What Is Serverless • Event-driven architecture • Invisible infrastructure • Automatic scaling on demand • Granular billing for execution time • Fault tolerant and highly available Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13 13
 
                Serverless Deployment, the Duck Test Upload Function Source Code Configure Function Trigger Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Function is invoked when triggered Pay for execution time, not idle time @jlb13 14
 
                Serverless is Not Really a Spectrum Container Orchestration Kubernetes Nomad Docker Swarm Ideally managed, but still infrastructure you care about Fully aware Container Services ECS, Fargate Azure CS GCP Cloud Run DIY FaaS OpenFaaS Fn Project Managed service provision containers, abstracts infrastructure you care about Leverage container management system under the covers, introduce Functions architecture Awareness of infrastructure Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Managed Serverless AWS Lambda Azure Functions Google Functions Oracle Functions Fully managed platform for hosting and executing code Invisible @jlb13 15
 
                What Is Serverless, Distilled Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13 16
 
                What Is Serverless Not • It’s not magic, it’s a choice • Brownfield: You need to break the monolith apart regardless • Greenfield: You need a solid design • Nothing is free Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13 17
 
                Hype Cycle – Productive Adoption Cloud Computing Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
 
                Hype Cycle – Serverless in Waves Serverless Computing Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
 
                Get Through This Quickly… Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
 
                …And Get Here Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
 
                Serverless From 30k Feet Event Sources Function Execution F(n) F(n) F(n) Backend Services F(n) Kubernetes, Docker, and/or Hypervisor Business Intelligence Analytics Triggers Compute, Network, Storage Databases Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13 22
 
                Function Example • Different projects and products differ in use and workflow • Just the code, configured against any number of event triggers • Basically follow microservices rules of engagement • As with microservices, applications are composed of many functions Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
 
                Events and Execution Models • Events are driven by context • Execution model is your choice Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
 
                Events, Determined by Context • Changes in data • API Invocations • Requests on endpoints • Changes in resources • Timers, Alarms, Direct Invocation… Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
 
                Using Events • Events are configured differently per platform • Inform the platform as to what event(s) should invoke this function • Function can consume the event and do the things • CNCF Serverless WG has drafted a CloudEvents specification Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
 
                Execution Models • Synchronous • Asynchronous • Streaming Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
 
                Error Handling by Model • Synchronous –Calling code handles the error • Asynchronous –System retries based upon timeline • Streaming –System retries based upon data efficacy Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
 
                What Can We Build With Serverless? • Web and Mobile Backends • Any other backend API implementations • Real-time Processing of Files, Streams • Batch Processing • Glueing up SaaS things • Kind of anything Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
 
                Web and Mobile Backends Identity Database API Platform Web, Mobile Apps Functions Mobile Trigger functions Process data Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Storage Data persisted @jlb13 30
 
                Extend and Enhance Existing Applications SaaS App Inventory create / update Analytics Functions Another App Support incident create / update Trigger functions Enrich data and send to Analytics service Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Use data for analytics and insights Visualize data @jlb13 31
 
                Real-Time Stream Processing Messaging/ Streaming Database Functions Data from multiple sources – Product Reviews and Ratings, Customer Service Interactions, Social Media, etc. Trigger functions Perform user sentiment analysis Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Records saved in database Dashboards with user sentiment analysis trends @jlb13 32
 
                Real-Time File Processing Database Storage Functions High resolution product image uploaded to storage Trigger functions Generate images of different resolutions and sizes Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Storage Images saved in Storage, metadata in Database Generated images displayed on various pages and devices @jlb13 33
 
                Internet of Things Executive Dashboard Service Cloud Ingest Functions Devices and things streaming sensor data Trigger functions Check data against thresholds. If exceeded, raise support incidents, send notifications Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Mobile Incident created in Service Cloud, notification sent to the technician Technician App @jlb13 34
 
                Batch Processing Scheduled batch job Database Database Functions Credit card transactions Transaction details Calculate bonus points Bonus points updated Loyalty bonus received Scheduled batch job Database Storage Functions Utility consumption Consumption details Generate utility bill PDF file Copyright © 2019, Oracle and/or its affiliates. All rights reserved. PDF files saved in Storage Utility bill PDF file @jlb13 35
 
                Check tags Check security roles Patch or update Modify/kill resource Vulnerability assess Check for idle State Change or a Timer Copyright © 2019, Oracle and/or its affiliates. All rights reserved. … @jlb13 36
 
                Big Ideas Around the Code • Don’t own what you don’t have to • Serverless is all about APIs • When you do implement, simplify • Plan ahead for observability Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
 
                Choose a Pattern that Helps you Minimize • Less is more: shoot for a single handler per module • If one function does more than one discrete thing, break it up • Better to proliferate than to decompensate • Observability and triage become infinitely easier at the boundaries Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
 
                Separate and Simplify • Simplify application estate as well • Events can and probably should define application boundaries • Share libraries between functions and applications, not execution context Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
 
                Code Reuse • Not long ago, Serverless function deployments were zip files • Now, many Serverless platforms expose a container image to you • Others use layering which mimics the container image stacking Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
 
                Observability • Metrics – Aggregate data regarding the behavior of a thing over time • Tracing – Instrumentation which provides an instance of an action, traversing the entire stack • Logging – Developer breadcrumbs we leave to give context for a certain code path Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
 
                Triaging Issues • Monolith in a VM – log into the host, look at logs, run a debugger • Containers in Kubernetes – Istio, Jaeger, Prometheus, Grafana, et al • Serverless… is complicated. Logging is there, but that’s not very useful at scale • OpenTracing & Jaeger is a possibility Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
 
                Observability Solutions From Your Provider Cloudwatch, X-ray, Stackdriver, OCI Monitoring and Logging, Azure Insights, IBM Monitoring, and others Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
 
                Observability Solutions From Other Experts Honeycomb, IO|Pipe, DataDog, Dashbird, Thundra, Epsagon, Splunk, Lightstep, Solo, and others (sorry if I missed yours!) Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
 
                Use Services and SaaS When Possible • DBaaS • Identity, Auth, Forms • Storage Services • Email, SMS • Maps, GPS • Media Streaming • Chat and Chatbots Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
 
                Worries • Don’t worry too much about cold starts • Do worry about data egress and migration • Pay attention to the system you are integrating with, keep it open if possible Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
 
                Is Serverless Simpler? • In a word, no • But that doesn’t mean it’s not better • Serverless doesn’t really mean less complexity • Resolving complexity is generally directly related to your core business Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
 
                Is Serverless Better? • In a word, yes • Less toil in deployment and maintenance of systems is beneficial to focus • OpEx reductions can be profound • Tradeoff: we depend upon third parties to address issues as they arise Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
 
                Final Thoughts • Put Serverless on your radar – Greenfield – Brownfield migration • Often a POC becomes production • Resist the urge to compare DevOps and Serverless. Apples to Apple Pie. • Build stuff! Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
 
                Thanks! @jlb13 cloud.oracle.com/trial cloudnative.oracle.com
