Serverless Patterns

A presentation at Serverless NYC Meetup in February 2019 in New York, NY, USA by Jesse Butler

Slide 1

Slide 1

ive Serverless Architecture Basic Patterns with Serverless Jesse Butler Cloud Native Advocate, Oracle Cloud Infrastructure cloudnative.oracle.com

Slide 2

Slide 2

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.

Slide 3

Slide 3

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

Slide 4

Slide 4

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

Slide 5

Slide 5

Level Set • Serverless • In production? • Lambda? Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 5

Slide 6

Slide 6

Monolithic Applications Users Application Database Copyright © 2018, Oracle and/or its affiliates. All rights reserved.

Slide 7

Slide 7

Monolithic Applications Users Application Database Copyright © 2018, Oracle and/or its affiliates. All rights reserved.

Slide 8

Slide 8

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.

Slide 9

Slide 9

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.

Slide 10

Slide 10

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

Slide 11

Slide 11

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

Slide 12

Slide 12

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

Slide 13

Slide 13

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.

Slide 14

Slide 14

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

Slide 15

Slide 15

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

Slide 16

Slide 16

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.

Slide 17

Slide 17

Execution Model • Synchronous • Asynchronous • Streaming Copyright © 2018, Oracle and/or its affiliates. All rights reserved.

Slide 18

Slide 18

Events, Determined by Context • Changes in data • Requests on endpoints • Changes in resources • Timers Copyright © 2018, Oracle and/or its affiliates. All rights reserved.

Slide 19

Slide 19

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.

Slide 20

Slide 20

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

Slide 21

Slide 21

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

Slide 22

Slide 22

Automation and DevOps ORACLE CLOUD Compute Storage Other

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

Slide 23

Slide 23

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

Slide 24

Slide 24

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

Slide 25

Slide 25

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

Slide 26

Slide 26

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

Slide 27

Slide 27

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.

Slide 28

Slide 28

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.

Slide 29

Slide 29

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.

Slide 30

Slide 30

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.

Slide 31

Slide 31

Thanks! cloud.oracle.com/trial cloudnative.oracle.com