无服务器工作流:广泛应用无服务器的关键

无服务器平台允许开发人员快速构建新应用程序,而无需在服务器资源配置、扩展和生命周期管理上花费时间。这些任务由无服务器平台来处理。 为了支持跨不同无服务器平台的无服务器应用程序的可移植性,CNCF 无服务器工作组正在开发通用的应用程序工作流规范。在此会议中,Cathy 和 Rachel 将概述应用程序工作流规范。在本次演讲中,Cathy 和 Rachel 将概述应用程序工作流规范。 本次演示的目标是分享我们在无服务器工作组中的工作,并将人们聚集在 CNCF 社区中,以讨论和开发一个全面和通用的无服务器工作流描述模型,该模型可用于跨所有类型的无服务器应用程序和平台。
展开查看详情

1.Serverless Workflow: Key to Wide Serverless Adoption Cathy Zhang, Principal Architect Huawei Silicon Valley Center

2.Agenda ● CNCF Serverless Function Workflow Model ● How to Use Workflow Model to Describe Serverless Application Use Cases ● Comparison of CNCF Function Workflow vs AWS Step Function ● Product Information Link on Serverless Workflow ● Q&A

3. Function Workflow Model A Function Workflow can be naturally modeled as a state machine. There are three key components  List of Events (trigger the function execution): Event For example: Storage event, Web Request event, Event 1 FN1 State DB Access event, Email event, etc. Event1 Payload  List of States (build the workflow structure): Switch • event-state State • operation-state • switch-state Payload=A Payload=B • delay-state • parallel-state Operation Operation FN2 FN3 • end-state with success or failure status State State  Functions associated with a state (executes the business logic ): FN4 • Directives for parallel/sequential execution of functions Event Event 2 State FN5 • Directives for Retry • Directives for information passing/filtering

4.IoT Home Monitoring Use Case Application Workflow Specification Motion Event Face Event Recognition State-1 DoorOpen (Start) Event Family Non-Family Member Member Motion Event Face Event State-3 Recognition Time-out Non-Family Family Member Member Send Event DoorOpen Notification State-2 Event Send Operation Notification State Time-out End State

5.How to Specify Workflow States "STATE-NAME": { "type": state type "start": a Boolean value to specify whether it is a start state "events": [ { "event-expression": a Boolean expression of events, e.g. “Event1 and Event2” "timeout": the timeout period waiting for the events, transition to end state "action-mode": functions are executed in sequence or in parallel "actions": the list of functions to be performed. "next-state": the next state to transition to after all the functions are successfully executed. } ] }

6.How to Specify Function Retry { "function": the function that must be invoked "timeout": the amount of time to wait for the completion of the function "retry": [ { "match": the matching value for the retry (function response/timeout) "retry-interval": the interval between the time that the error response is received to the time the retry is started "max-retry": the maximum number of retry attempts "next-state": the next state to transition to when exceeding max-retry limit } ] }

7.How to Specify Pass/Filter of Information

8.Travel Booking Use Case Application Workflow Specification TravelBooking Event Booking Validation, ReqEvent State-1 Notify Manager (Start) Manager Event Response State-2 Interpret the response Event Reject Approve Check Price of Airline1 Operation Check Price of Airline2 State-1 Check Price of Airline3 Price Info Operation Compare Prices, times State-2 and Book the ticket End State

9.Loan Application Use Case Application Workflow Specification LoanReq Event Loan Application Event State-1 Sanity Check (Start) Pass Fail Check Background Operation Check Credit History State-1 Check Financial Strength Send result to manager Loan Manager Event Interpret the response Response Event State-2 Approve Prepare Loan Operation Documents State-2 Reject Notify customer to sign the loan End State

10.Video Streaming Use Case Application Workflow Specification Video Upload Event Analyze Video File Event State-1 Metadata (Start) Original Encoding Info Invoke MP4 Media Transcoder Service Operation State-1 Invoke HLS Media Transcoder Service Invoke DASH Media Transcoder Service MP4 Service Response Event Response Benefit of Breaking an Application into a Workflow HLS Service Event encoding Publish the Response Event State-2 Transcoding Modify/replace/add a function without impacting DASH Service Wait for more other functions or other steps. Response Event responses Switch State Flexibility to add a new step to provide new All responses service, such as creating thumbnails, inserting received ads in the video stream, inserting a video End transcription, etc. State

11.CNCF Workflow vs AWS Step Function AWS Step Function Flow  Step Function can not handle event. User needs to configure extra lambda function to connect an event to a step function and needs to coordinate these configurations manually  Customer needs to provision Dynamo DB and use it to pass info from one Step Function to the next step function  Configure multiple Lambda Functions and Step Functions vs one CNCF Workflow

12.Information Links 1. https://github.com/cncf/wg-serverless/tree/master/workflow/spec 2. https://www.huaweicloud.com/en-us/product/functiongraph.html 3. https://aws.amazon.com/step-functions/

13.Thank You! Questions?