ive Serverless Architecture Basic Patterns with Serverless Jesse Butler Cloud Native Advocate, Oracle Cloud Infrastructure cloudnative.oracle.com
A presentation at Serverless NYC Meetup in February 2019 in New York, NY, USA by Jesse Butler
ive Serverless Architecture Basic Patterns with Serverless Jesse Butler Cloud Native Advocate, Oracle Cloud Infrastructure cloudnative.oracle.com
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 © 2018, Oracle and/or its affiliates. All rights reserved.
About Me • Oracle via Sun Microsystems • Responsible for Docker on Solaris, later on Oracle Linux • Some work with Open Containers and CNCF WGs • Now a Cloud Native Advocate @ Oracle Cloud • @jlb13 on Twitter Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 3
About OCI • Next-generation Cloud Infrastructure • Highly performant, very affordable • Managed Cloud Native Services – OKE & OCIR at the core – Many managed services in the pipeline • Check out OCI: https://cloud.oracle.com/tryit Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 4
Level Set • Serverless • In production? • Lambda? Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 5
Monolithic Applications Users Application Database Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Monolithic Applications Users Application Database Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Microservices Deploying Code to Systems We Build in the Cloud with Excellent Abstractions Load balancer Service Service Service Database Queue Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Serverless Deploying Code to Systems We Build in the Cloud with Excellent Abstractions Load balancer Service Service Service Database Queue Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Trend towards Serverless Functions Abstractions Containers Virtual machines Bare Metal Decreasing concern (and control) over infrastructure implementation Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 10
What Is Serverless? • Event-driven architecture • Invisible infrastructure • Automatic scaling on demand • Fault tolerant and highly available • Granular billing for execution time Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Confidential – Oracle Internal/Restricted/Highly Restricted 11
How Does it Work? Upload Function Source Code Configure Function Trigger Function is invoked when triggered Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Pay for execution time, not idle time 12
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 © 2018, Oracle and/or its affiliates. All rights reserved.
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 © 2018, Oracle and/or its affiliates. All rights reserved. 14
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 Autonomous Platform auto-scales functions No servers to provision, manage No Lock-in Built on open-source Fn Project and Docker Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 15
Key Features Open Source Engine Container Native Function Dev Kits Fine-grained Billing Advanced Diagnostics HTTP Events Streams Timer Oracle Cloud Triggers Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Execution Model • Synchronous • Asynchronous • Streaming Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Events, Determined by Context • Changes in data • Requests on endpoints • Changes in resources • Timers Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Using Events • Events or triggers are configured differently • Abstractly, inform the platform to what event(s) should invoke this function • OCI Functions use Cloud Events format for portability Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Use Case: Web and Mobile Backends ORACLE CLOUD Identity Database API Platform Web, Mobile Apps Mobile Trigger functions Functions Process data Storage Data persisted Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 20
Extend and Enhance Existing Applications ORACLE CLOUD SaaS App Inventory create / update Analytics Another App Support incident create / update Trigger functions Functions Enrich data and send to Analytics service Use data for analytics and insights Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Visualize data 21
Check tags Check security roles Patch or update Modify/kill resource Vulnerability assess Reports/Notifications State Change Triggers Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 22
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 Records saved in database Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Dashboards with user sentiment analysis trends 23
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 Storage Images saved in Storage, metadata in Database Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Generated images displayed on various pages and devices 24
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 PDF files saved in Storage Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Utility bill PDF file 25
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 Mobile Incident created in Service Cloud, notification sent to the technician Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Technician App 26
Mapping Execution, Events and Architecture • Eventing model is driven by the requirement and context • Choose the right execution model for your application Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Choose a Pattern that Helps you Minimize • Less is more, good rule of thumb is a single handler per module • Better to proliferate than to decompensate • Observability and triage become infinitely easier at the boundaries Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Separate and Simplify • Typically consumption of events define application boundaries • Share libraries between functions and applications, not execution context Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Separate and Simplify • Don’t worry about cold starts • Do worry about lock-in and data egress Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Thanks! cloud.oracle.com/trial cloudnative.oracle.com