ive Serverless Patterns Basic Patterns with Functions and Serverless Jesse Butler Cloud Native Advocate, Oracle Cloud Infrastructure cloudnative.oracle.com @jlb13
A presentation at InnoTech San Antonio in April 2019 in San Antonio, TX, USA by Jesse Butler
ive Serverless Patterns Basic Patterns with Functions and Serverless Jesse Butler Cloud Native Advocate, Oracle Cloud Infrastructure cloudnative.oracle.com @jlb13
Safe Harbor Statement The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
Level Set • Devs, Ops, DevOps? • Serverless users? • In production? • Lambda? Azure? Something Else? Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13 3
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
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 Decreasing concern (and control) over infrastructure implementation Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13 8
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 9
How Does it Work? 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 10
Function Example • Different projects and products differ in use and workflow • This example function can be deployed in Oracle Functions • Just the code, configured against any number of event triggers • As with microservices, applications are composed of many functions Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
Functions-as-a-Service 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 12
Oracle Functions Pay Per Use Oracle Functions Pay for execution, not for idle time Functions-as-a-Service Oracle Cloud Integrated Container Native Open Source Engine Multi-tenant Secure Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Autonomous Platform auto-scales functions No servers to provision, manage No Lock-in Built on open-source Fn Project and Docker @jlb13 13
Key Features Open Source Engine Container Native Function Dev Kits Fine-grained Billing Advanced Diagnostics HTTP Events Streams Timer Oracle Cloud Triggers Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
Execution Model • Synchronous • Asynchronous • Streaming 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 Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
Using Events • Events are configured differently by platform • Abstractly, inform the platform to what event(s) should invoke this function • CNCF Serverless WG has drafted the CloudEvents specification • Oracle Functions use Cloud Events format for portability Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
Use Case: Web and Mobile Backends ORACLE CLOUD 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 18
Extend and Enhance Existing Applications ORACLE CLOUD 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 19
Check tags Check security roles Patch or update Modify/kill resource Vulnerability assess State Change Triggers Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Reports/Notifications @jlb13 20
Use Case: Real-Time Stream Processing ORACLE CLOUD 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 21
Use Case: Real-Time File Processing ORACLE CLOUD 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 22
Use Case: Batch Processing ORACLE CLOUD 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 23
Internet of Things ORACLE CLOUD Service Cloud Ingest Functions Devices and things streaming sensor data Trigger functions Executive Dashboard 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 24
Mapping Execution, Events and Architecture • Eventing is typically driven by context • Execution model is an important choice 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 • 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 • Typically consumption of events define application boundaries • Share libraries between functions and applications, not execution context Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
Worries • Don’t worry too much about cold starts • Do worry about lock-in and data egress • Pay attention to the system you are integrating with – keep it open Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
Dive In! • The best way to learn is to do • Often a POC becomes production • You will not be alone • Have fun! Copyright © 2019, Oracle and/or its affiliates. All rights reserved. @jlb13
Thanks! @jlb13 cloud.oracle.com/trial cloudnative.oracle.com