Naohiro Tamura
Professional Engineer
Fujitsu Limited
FaaS Shell
Multi-Cloud Portable Serverless Function Workflow
Copyright 2018 FUJITSU LIMITED
Open Source Summit Japan 2018
Thursday, June 21 • 12:00 - 12:40
About me
 Recent work
 Apr. 2017 – Open Source PaaS, FaaS, Cloud Native Development (FaaS Shell)
 Oct. 2014 – Mar. 2017 Open Source IaaS Development (OpenStack Ironic)
 - Sep. 2014 Proprietary System and Resource Management Software Development
 Expertise
 System and Resource Management Software Development
 Personal Interest
 Functional and Logic Programming
1 Copyright 2018 FUJITSU LIMITED
FaaS Shell is written in Prolog
for agility, and also for joyful
Programming 
TOC
What is Function Workflow?
What is FaaS Shell and Why?
Demo
How does FaaS Shell work?
 Summary
 Q&A
2 Copyright 2018 FUJITSU LIMITED
What is Function Workflow?
 Serverless Function
 Small for doing single task
 Stateless and Immutable
 Event Driven and Reactive
 Auto scale
 Pay per use
3 Copyright 2018 FUJITSU LIMITED
 Functional Programming Language (FPL) Function
 Small for doing single task
 Stateless and Immutable
 Good at Event Driven and Reactive
 Good at Concurrent and Parallel
 FPL main theme is how to compose function
 sequential, conditional, repetition, parallel, exceptional handling, retry
 Serverless Function requires Function Composition as well as FPL
⇒ That is Serverless Function Workflow
Very similar like twins
If we look at Serverless Function from FPL’s point of view…
Serverless Function Workflow
 Consists of 3 elements, for example AWS case
 Serverless Function : AWS Lambda
 Serverless Function Workflow : Step Functions
 Workflow Language : Amazon States Language
 Workflow = Composition
 Sequential
 Conditional
 Repetition
 Parallel
 Exceptional handling
 Retry
Copyright 2018 FUJITSU LIMITED4
Amazon States Language (ASL)
 State Machine
 Pass
 Task
 Choice
 Wait
 Succeed
 Fail
 Parallel
5 Copyright 2018 FUJITSU LIMITED
{
"Comment": "A Hello World example of the Amazon States Language using a Task state",
"StartAt": "HelloWorld",
"States": {
"HelloWorld": {
"Type": "Task",
"Resource":"arn:aws:lambda:us-east-2:410388484666:function:hello",
"End": true
}
}
}
Specify AWS Lamda Function
in arn (Amazon Resource Name)
Task State
Entry State
JSON format
① Input {“name”: “FaaS Shell”}
② Output {“payload”: “Hello, FaaS Shell!”}
TOC
 What is Function Workflow?
 What is FaaS Shell and Why?
 Demo
 How does FaaS Shell work?
 Summary
 Q&A
6 Copyright 2018 FUJITSU LIMITED
Google Cloud
Composer
What is FaaS Shell?
 It’s a shell which enables to exploit Serverless Functions across Multiple Clouds
 Covers major 4 FaaS Providers as well as reusable Functions
 Works as abstraction layer with keeping agility for future changes
Copyright 2018 FUJITSU LIMITED7
FaaS Shell
Amazon State Language (ASL) Other Workflow Language
Abstraction Layer
…
…
…
AWS
Lambda
Google Cloud
Functions
AWS Step
Functions
Azure Logic
Apps
Azure
Functions
Twilio
StackStorm
IBM
Functions
Composer
IBM Cloud
Functions
Apache
OpenWhisk
Fission
Workflow
Fission
Why FaaS Shell?
 Serverless Function Workflow Landscape - Serveless Silo
 Each provider or platform has its own workflow service
 There is no interoperability among providers
 This situation will continue along with competing each other
8 Copyright 2018 FUJITSU LIMITED
AWS
Lambda
Azure
Functions
Google Cloud
Functions
AWS Step
Functions
…
Azure Logic
Apps
…
IBM
Functions
Composer
IBM Cloud
Functions
Apache
OpenWhisk
Fission
Workflow
Fission
Google Cloud
Composer
Benefit of using FaaS Shell
 1st Stage: Single Cloud Strategy
 Commit to one cloud vendor after thorough investigation
 Staying vendor lock-in state is nothing wrong if you and your customer are happy
 2nd Stage: Multi Cloud Strategy
 Serverless Function doesn’t cost at all unless called
 Each Cloud has strengths and weaknesses, own characteristics, especially in AI area
 Reusable FaaS such as IFTTT (if-this-then-that), Twilio, StackStorm, Node-RED, etc are available
 Why not exploit the best part of each cloud and integrate them?
 In fact, we actually have the fortune of selecting the most attractive features from each provider,
to enable a multi-cloud strategy.
9 Copyright 2018 FUJITSU LIMITED
Demo Next
FaaS Shell helps us shift Single Strategy to Multi Cloud Strategy
TOC
 What is Function Workflow?
 What is FaaS Shell and Why?
 Demo
 How does FaaS Shell work?
 Summary
 Q&A
10 Copyright 2018 FUJITSU LIMITED
Image RecognitionSpeech Recognition
Natural Language Processing
AI Services Evaluation Demo Background
11 Copyright 2018 FUJITSU LIMITED
Translation
API
Amazon
Lex
Amazon
Polly
Amazon
Rekognition
Vision
API
Speech
API
Natural
Language API
Computer
Vision
emotiontextanalytics
web-language-
model
Language
understanding
intelligent
service
recommendations
Speech
Amazon
Comprehend
Amazon
Translate
Amazon
Transcribe
translator
IBM
Visual
Recognition
Watson
Speech to Text
Text to Speech
Watson
Language
Translator
Watson
Language
Classifier
Watson
Tone
Analyzer
Watson
Personal
Insights
Which provider’s service is suitable for a specific app? We need evaluation!
Dataset and
Algorism are
different each
other
Translation Service Eval. Demo across Multiple Clouds
 Evaluate Translation using an Ambiguous Sentence
 very basic Natural Language Processing example
 it may be that the professor is lecturing with the cat, or that the student has the cat.
 See how each service translates it into other language and back to English
[1] “Structure and Interpretation of Computer Programs”
12 Copyright 2018 FUJITSU LIMITED
the professor lectures to the student with the cat. [1]
English Other Language Englishtranslate Translate back
Compare
Translation Evaluation Demo Workflow Graph
 Total 26 States and 4 Parallel Transitions
13 Copyright 2018 FUJITSU LIMITED
Translation Evaluation Demo Deployment
14 Copyright 2018 FUJITSU LIMITED
Amazon
Translate
Google
Translation
API
Azure
Translator Text
AWS
Lambda
Azure
Functions
Google Cloud
Functions
IBM Cloud
Functions
Watson
Language
Translator
FaaS Shell
Translation Eval. Workflow
Input
Output
text
Serverless Function
translation Service
Authentication and
Authorization code
are required
RBAC setting only,
No auth coding
Demo Steps through REST Interface
 Register Statemachine
 Execute Statemachine
 English to Arabic (ar), and back to English
 English to Chinese (zh), and back to English
 English to Japanese (ja), and back to English
 Generate Statemachine Graph (Graphviz DOT)
15 Copyright 2018 FUJITSU LIMITED
TOC
 What is Function Workflow?
 What is FaaS Shell and Why?
 Demo
 How does FaaS Shell work?
 Summary
 Q&A
16 Copyright 2018 FUJITSU LIMITED
REST API
17 Copyright 2018 FUJITSU LIMITED
REST API Function
/ Get version number
/executions/{execution_id} Get background statemachine information
/activity/{activity_task} Get/Put/Heartbeat activity
/trigger/{event_state} Send Event
/faas/{function} List callable function information in each FaaS
/statemachine/{statemachine} Register/Execute/Delete/Graph statemachine
/shell/{dsl} Register/Execute/Delete Workflow DSL
FaaS Shell Components
18 Copyright 2018 FUJITSU LIMITED
FaaS Shell Container
Flow DSL
Amazon State
Language (ASL)
(JSON)
FaaS Shell API End Point
Cloud Provider
Plugin
Flow DSL Interpreter
Graphviz
(DOT)
GUI Editor
NoSQL DB
(CouchDB/Coudant)
Deploy
Fasshell REPL
(Interactive Shell)
Invoke
(REST)
Call
FaaS
Put
Get
DOT Generator
ASL Compiler
program definitionlibrary※FaaS Shell
AWS Lambda
Azure Functions
GCP Cloud Functions APIEndPoint
IBM Cloud Functions
(Apache OpenWhisk)
K5, Fission, etc
API Gateway
packaging
Message Queue
(Kafka/built-in)
Message Queue
Plugin
IFTTT
(IF-This-Then-That)
TOC
 What is Function Workflow?
 What is FaaS Shell and Why?
 Demo
 How does FaaS Shell?
 Summary
 Q&A
19 Copyright 2018 FUJITSU LIMITED
Summary
 What is FaaS Shell?
 FaaS Shell is a shell which enables to exploit Serverless Functions across Multiple Clouds
 FaaS Shell helps us shift Single Strategy to Multi Cloud Strategy
 Future Plan
 Azure LogicApp Workflow Definition Language
 Visit github “https://github.com/NaohiroTamura/faasshell” and Try demos
 Especially if you are interested in Functional and Logic Programming
 Welcome your feedback!
 naohirot@jp.fujitsu.com
20 Copyright 2018 FUJITSU LIMITED
Q & A
21 Copyright 2018 FUJITSU LIMITED
Copyright 2018 FUJITSU LIMITED22
APPENDIX
23 Copyright 2018 FUJITSU LIMITED
Translation Service Catalog Spec among Multiple Clouds
24 Copyright 2018 FUJITSU LIMITED
Cloud Service Name Current Supported Languages
(more than 6,000 languages on the planet)
AWS Amazon Translate 6 languages to and from English for Preview:
(Arabic, Simplified Chinese, French, German, Spanish, and Portuguese)
6 additional languages will be supported soon,
(Japanese, Russian, Italian, Traditional Chinese, Turkish, and Czech)
Azure Translator Text supports more than 60 languages
GCP Translation API supports more than 100 different languages
IBM Language Translator Support 14 languages
Arabic, Chinese (Simplified & Traditional), Dutch*, English, French, German,
Italian, Japanese, Korean, Polish*, Portuguese (Brazil), Russian*, Spanish,
and Turkish*
*These languages are supported with the early access preview
Not yet
 Surprisingly, AWS is not the leader in this area at this moment
Doesn’t work
Comparison
 Difference between Serverless Framework and FaaS Shell
 Serverless Framework : Portable Solution for Serverless Function
 FaaS Shell : Portable Solution for Serverless Function Workflow
 Related work
 Serverless Inc. OSS Event Gateway : Similar but different focus and approach
25 Copyright 2018 FUJITSU LIMITED
FaaS Shell Complier and Workflow DSL
 Compiler supported Amazon State Language at first
 Generate Workflow DSL
 fsm()
 pass()
 task()
 choice()
 wait()
 succeed()
 fail()
 parallel()
26 Copyright 2018 FUJITSU LIMITED
{
"Comment": "A Hello World example using a Task state",
"StartAt": "HelloWorld",
"States": {
"HelloWorld": {
"Type": "Task",
"Resource":"arn:aws:lambda:us-east-2:410388484666:function:hello",
"End": true
}
}
}
fsm([task('HelloWorld',"arn:aws:lambda:us-east-2:410388484666:function:hello",[])])
FaaS Shell Runtime
 Execute Workflow DSL FSM (Finite State Machine)
 Implemented as Meta Interpreter
 Very concise code in language such as
Lisp or Prolog
 This is important to keep agility for
future changes
27 Copyright 2018 FUJITSU LIMITED
%%
%% reduce(+Dsl, +In, -Out, +EnvIn, -EnvOut)
%%
reduce(fsm(Dsl), I, O, EI, EO) :-
!,
reduce(Dsl, I, O, EI, EO).
reduce([], O, O, E, E) :-
!.
reduce([A|B], I, O, EI, EO) :-
!,
reduce(A, I, M, EI, EM),
reduce(B, M, O, EM, EO),
reduce(A, I, O, EI, EO) :-
call(A, I, O, EI, EO).
Entry
Exit
Recursive
Call State
FaaS Shell Runtime Executes Workflow in Batch Mode
28 Copyright 2018 FUJITSU LIMITED
$ curl -ksX POST ${FAASSHELL_APIHOST}/statemachine/hello_world_task.json?blocking=true ¥
-H 'Content-Type: application/json' -d '{"input": {"name": "Curl"}}' -u $DEMO
{
"asl": {
"Comment":"A Hello World example of the Amazon States Language using a Task state",
"StartAt":"HelloWorld",
"States": {
"HelloWorld": {
"End":true,
"Resource":"arn:aws:lambda:us-east-2:410388484666:function:hello",
"Type":"Task"
}
}
},
"dsl":"fsm([task('HelloWorld',¥"arn:aws:lambda:us-east-2:410388484666:function:hello¥",[])])",
"input": {"name":"Curl"},
"name":"hello_world_task.json",
"namespace":"demo",
"output": {"payload":"Hello, Curl!"}
}
How to resolve Function Input and Output Mismatch?
 State Optional Parameter
InputPath, ResultPath, OutputPath
29 Copyright 2018 FUJITSU LIMITED
"InputPath": "$.payload",
"ResultPath": "$.ifttt.value1",
"OutputPath": "$.ifttt",
{“payload”: “Hello, IFTTT!”}
{“value1”: “Hello, IFTTT!”}
HelloWorld
task output
SaveResult
task input
{
"Comment": “IFTTT as FaaS Demo",
"StartAt": "HelloWorld",
"States": {
"HelloWorld": {
"Type": "Task",
"Resource":"frn:wsk:functions:::function:hello",
"Next": "UpdateArg"
},
"UpdateArg": {
"Type": "Pass",
"InputPath": "$.payload",
"ResultPath": "$.ifttt.value1",
"OutputPath": "$.ifttt",
"Next": "SaveResult"
},
"SaveResult": {
"Type": "Task",
"Resource":"frn:ifttt:webhooks:::function:save_result",
"End": true
}
}
}
FaaS Shell REPL Executes Workflow Interactively
 Haskell REPL
ghic> hello = ¥e -> return (e+1)
ghic> update_arg= ¥e -> return (e*2)
ghic> save_result = ¥e -> return (e^2)
ghic> pure 1 >>= hello >>= update_arg >>= save_result
16
 FaaS Shell REPL
faasshell> Hello = task('HelloWorld',"frn:wsk:functions:::function:hello",[]),
| UpdateArg = pass('UpdateArg',[result_path('$.ifttt.value1'),input_path('$.payload'),out_path('$.ifttt')]),
| SaveResult = task('SaveResult',"frn:ifttt:webhooks:::function:save_result",[]),
| startsm(_{name:"Repl"}), Hello, Pass, SaveResult.
Output=Congratulations! You've fired the save_result event
30 Copyright 2018 FUJITSU LIMITED
FaaS Shell startsm corresponds Haskell pure
FaaS shell comma operator ','
corresponds to Haskell bind operator '>> ='.
Devises for supporting Multiple Clouds
 Function Name Resolution
 Resource Naming (Direct Invocation)
 Function Discovery (Indirect Invocation)
 Event State
 Supported Event State in Workflow DSL
 CNCF WG-Serverless Whitepaper v1.0 [1] (P.32) pointed out:
> AWS provides “step function” primitives (state machine based primitives) for the user to
> specify its workflow, but step function does not allow specification of what event/events
> triggering what functions in the workflow.
 Amazon States Language can handle Event through Activity Task, but it’s not straightforward.
[1] https://github.com/cncf/wg-serverless/blob/master/whitepaper/cncf_serverless_whitepaper_v1.0.pdf
31 Copyright 2018 FUJITSU LIMITED
Resource Naming - Function Name Resolution (1)
 Resource Naming in Amazon States Language Specification [1]
 A Task State MUST include a “Resource” field, whose value MUST be a URI that uniquely identifies the
specific task to execute.
 AWS Step Functions Implementation
 ARN (Amazon Resource Name)
"Resource":"arn:aws:lambda:us-east-2:410388484666:function:hello“
 FaaS Shell Implementation
 FRN (FaaS Resource Name)
AWS “ Resource”:“frn:aws: …“ or “arn:aws: …“
Microsoft “ Resource”:“frn:azure: …“
Google “ Resource”:“frn:gcp: …“
IBM/OpenWhisk “Resource”:“frn:wsk: … “
IFTTT “ Resource”:“frn:ifttt: …“
Fujitsu “ Resource”:“frn:k5: …“
[1] https://states-language.net/spec.html
32 Copyright 2018 FUJITSU LIMITED
Either URN or URL
Function Discovery - Function Name Resolution (2)
 Discover Function Semantically
 Make use of Open Linked Data technology, OWL (Web Ontology Language)
 FaaS Shell Implementation
 "Resource": "https://naohirotamura.github.io/faasshell/ns/faas#hello"
 Define Triple (Subject – Predicate – Object)
 User owns Function
 FaaS assigns FRN
 FRN invokes Function
33 Copyright 2018 FUJITSU LIMITED
demo:User hello:Function
aws:FaaS
azure:FaaS
gcp:FaaS
wsk:FaaS
frn01:FRN
frn03:FRN
frn02:FRN
frn04:FRN
URI: Unique Identifier
https://naohirotamura.github.io/faasshell/ns/faas#hello
Function Discovery Cont. - Function Name Resolution (2)
 There are several weather service on Internet
 Assume reusable function “weather” open linked RDF data or SPARQL end point is available
 "Resource": "https://weather.org/ns/faas#weatherβ"
 Querying the linked data, we will figured out that “frn02”,”frn03”,”frn04” are callable
using PublicUser “u1” account.
34 Copyright 2018 FUJITSU LIMITED
weatherβ:Weather
serviceA:FaaS
serviceB:FaaS
serviceC:FaaS
serviceD:FaaS
frn01:FRN
frn03:FRN
frn02:FRN
frn04:FRN
URI is just Identifier
u1:PublicUser weatherα:Weather
Function ClassUser Class
Event State
35 Copyright 2018 FUJITSU LIMITED
{
"Comment": "A Hello Event example",
"StartAt": "HelloEvent",
"States": {
"HelloEvent": {
"Type": "Event",
"Resource": "frn::states:::event:test",
"End": true
},
}
}
Start
Event State
frn::states:::event:test
End
③ Function “hello”
arn:aws:lambda:us-east-2:410388484666:function:hello
② Event “frn::states:::event:test”
{“action”:”arn:aws:lambda:us-east-2:410388484666:function:hello”
① Input {“name”: “Event”}
④ Output {“payload”: “Hello, Event!”}
FaaS Shell Deployment
36 Copyright 2018 FUJITSU LIMITED
Kubernetes/OpenShift
Service
End Point
FaaS Shell 1
(statefulset)
FaaS Shell 2
(statefulset)
Message Queue
(Kafka, Zookeeper)
NoSQL DB
(CouchDB)
FaaS Shell 3
(statefulset)
・・・
NoSQL DB
(CouchDB)
Message Queue
(Kafka, Zookeeper)
Faasshell
name
space
Docker/Kubenetes/OptnShift
CouchDB
FaaS Shell
① Development ② Horizontal Scale Out

FaaS Shell: Multi-Cloud Portable Serverless Function Workflow

  • 1.
    Naohiro Tamura Professional Engineer FujitsuLimited FaaS Shell Multi-Cloud Portable Serverless Function Workflow Copyright 2018 FUJITSU LIMITED Open Source Summit Japan 2018 Thursday, June 21 • 12:00 - 12:40
  • 2.
    About me  Recentwork  Apr. 2017 – Open Source PaaS, FaaS, Cloud Native Development (FaaS Shell)  Oct. 2014 – Mar. 2017 Open Source IaaS Development (OpenStack Ironic)  - Sep. 2014 Proprietary System and Resource Management Software Development  Expertise  System and Resource Management Software Development  Personal Interest  Functional and Logic Programming 1 Copyright 2018 FUJITSU LIMITED FaaS Shell is written in Prolog for agility, and also for joyful Programming 
  • 3.
    TOC What is FunctionWorkflow? What is FaaS Shell and Why? Demo How does FaaS Shell work?  Summary  Q&A 2 Copyright 2018 FUJITSU LIMITED
  • 4.
    What is FunctionWorkflow?  Serverless Function  Small for doing single task  Stateless and Immutable  Event Driven and Reactive  Auto scale  Pay per use 3 Copyright 2018 FUJITSU LIMITED  Functional Programming Language (FPL) Function  Small for doing single task  Stateless and Immutable  Good at Event Driven and Reactive  Good at Concurrent and Parallel  FPL main theme is how to compose function  sequential, conditional, repetition, parallel, exceptional handling, retry  Serverless Function requires Function Composition as well as FPL ⇒ That is Serverless Function Workflow Very similar like twins If we look at Serverless Function from FPL’s point of view…
  • 5.
    Serverless Function Workflow Consists of 3 elements, for example AWS case  Serverless Function : AWS Lambda  Serverless Function Workflow : Step Functions  Workflow Language : Amazon States Language  Workflow = Composition  Sequential  Conditional  Repetition  Parallel  Exceptional handling  Retry Copyright 2018 FUJITSU LIMITED4
  • 6.
    Amazon States Language(ASL)  State Machine  Pass  Task  Choice  Wait  Succeed  Fail  Parallel 5 Copyright 2018 FUJITSU LIMITED { "Comment": "A Hello World example of the Amazon States Language using a Task state", "StartAt": "HelloWorld", "States": { "HelloWorld": { "Type": "Task", "Resource":"arn:aws:lambda:us-east-2:410388484666:function:hello", "End": true } } } Specify AWS Lamda Function in arn (Amazon Resource Name) Task State Entry State JSON format ① Input {“name”: “FaaS Shell”} ② Output {“payload”: “Hello, FaaS Shell!”}
  • 7.
    TOC  What isFunction Workflow?  What is FaaS Shell and Why?  Demo  How does FaaS Shell work?  Summary  Q&A 6 Copyright 2018 FUJITSU LIMITED
  • 8.
    Google Cloud Composer What isFaaS Shell?  It’s a shell which enables to exploit Serverless Functions across Multiple Clouds  Covers major 4 FaaS Providers as well as reusable Functions  Works as abstraction layer with keeping agility for future changes Copyright 2018 FUJITSU LIMITED7 FaaS Shell Amazon State Language (ASL) Other Workflow Language Abstraction Layer … … … AWS Lambda Google Cloud Functions AWS Step Functions Azure Logic Apps Azure Functions Twilio StackStorm IBM Functions Composer IBM Cloud Functions Apache OpenWhisk Fission Workflow Fission
  • 9.
    Why FaaS Shell? Serverless Function Workflow Landscape - Serveless Silo  Each provider or platform has its own workflow service  There is no interoperability among providers  This situation will continue along with competing each other 8 Copyright 2018 FUJITSU LIMITED AWS Lambda Azure Functions Google Cloud Functions AWS Step Functions … Azure Logic Apps … IBM Functions Composer IBM Cloud Functions Apache OpenWhisk Fission Workflow Fission Google Cloud Composer
  • 10.
    Benefit of usingFaaS Shell  1st Stage: Single Cloud Strategy  Commit to one cloud vendor after thorough investigation  Staying vendor lock-in state is nothing wrong if you and your customer are happy  2nd Stage: Multi Cloud Strategy  Serverless Function doesn’t cost at all unless called  Each Cloud has strengths and weaknesses, own characteristics, especially in AI area  Reusable FaaS such as IFTTT (if-this-then-that), Twilio, StackStorm, Node-RED, etc are available  Why not exploit the best part of each cloud and integrate them?  In fact, we actually have the fortune of selecting the most attractive features from each provider, to enable a multi-cloud strategy. 9 Copyright 2018 FUJITSU LIMITED Demo Next FaaS Shell helps us shift Single Strategy to Multi Cloud Strategy
  • 11.
    TOC  What isFunction Workflow?  What is FaaS Shell and Why?  Demo  How does FaaS Shell work?  Summary  Q&A 10 Copyright 2018 FUJITSU LIMITED
  • 12.
    Image RecognitionSpeech Recognition NaturalLanguage Processing AI Services Evaluation Demo Background 11 Copyright 2018 FUJITSU LIMITED Translation API Amazon Lex Amazon Polly Amazon Rekognition Vision API Speech API Natural Language API Computer Vision emotiontextanalytics web-language- model Language understanding intelligent service recommendations Speech Amazon Comprehend Amazon Translate Amazon Transcribe translator IBM Visual Recognition Watson Speech to Text Text to Speech Watson Language Translator Watson Language Classifier Watson Tone Analyzer Watson Personal Insights Which provider’s service is suitable for a specific app? We need evaluation! Dataset and Algorism are different each other
  • 13.
    Translation Service Eval.Demo across Multiple Clouds  Evaluate Translation using an Ambiguous Sentence  very basic Natural Language Processing example  it may be that the professor is lecturing with the cat, or that the student has the cat.  See how each service translates it into other language and back to English [1] “Structure and Interpretation of Computer Programs” 12 Copyright 2018 FUJITSU LIMITED the professor lectures to the student with the cat. [1] English Other Language Englishtranslate Translate back Compare
  • 14.
    Translation Evaluation DemoWorkflow Graph  Total 26 States and 4 Parallel Transitions 13 Copyright 2018 FUJITSU LIMITED
  • 15.
    Translation Evaluation DemoDeployment 14 Copyright 2018 FUJITSU LIMITED Amazon Translate Google Translation API Azure Translator Text AWS Lambda Azure Functions Google Cloud Functions IBM Cloud Functions Watson Language Translator FaaS Shell Translation Eval. Workflow Input Output text Serverless Function translation Service Authentication and Authorization code are required RBAC setting only, No auth coding
  • 16.
    Demo Steps throughREST Interface  Register Statemachine  Execute Statemachine  English to Arabic (ar), and back to English  English to Chinese (zh), and back to English  English to Japanese (ja), and back to English  Generate Statemachine Graph (Graphviz DOT) 15 Copyright 2018 FUJITSU LIMITED
  • 17.
    TOC  What isFunction Workflow?  What is FaaS Shell and Why?  Demo  How does FaaS Shell work?  Summary  Q&A 16 Copyright 2018 FUJITSU LIMITED
  • 18.
    REST API 17 Copyright2018 FUJITSU LIMITED REST API Function / Get version number /executions/{execution_id} Get background statemachine information /activity/{activity_task} Get/Put/Heartbeat activity /trigger/{event_state} Send Event /faas/{function} List callable function information in each FaaS /statemachine/{statemachine} Register/Execute/Delete/Graph statemachine /shell/{dsl} Register/Execute/Delete Workflow DSL
  • 19.
    FaaS Shell Components 18Copyright 2018 FUJITSU LIMITED FaaS Shell Container Flow DSL Amazon State Language (ASL) (JSON) FaaS Shell API End Point Cloud Provider Plugin Flow DSL Interpreter Graphviz (DOT) GUI Editor NoSQL DB (CouchDB/Coudant) Deploy Fasshell REPL (Interactive Shell) Invoke (REST) Call FaaS Put Get DOT Generator ASL Compiler program definitionlibrary※FaaS Shell AWS Lambda Azure Functions GCP Cloud Functions APIEndPoint IBM Cloud Functions (Apache OpenWhisk) K5, Fission, etc API Gateway packaging Message Queue (Kafka/built-in) Message Queue Plugin IFTTT (IF-This-Then-That)
  • 20.
    TOC  What isFunction Workflow?  What is FaaS Shell and Why?  Demo  How does FaaS Shell?  Summary  Q&A 19 Copyright 2018 FUJITSU LIMITED
  • 21.
    Summary  What isFaaS Shell?  FaaS Shell is a shell which enables to exploit Serverless Functions across Multiple Clouds  FaaS Shell helps us shift Single Strategy to Multi Cloud Strategy  Future Plan  Azure LogicApp Workflow Definition Language  Visit github “https://github.com/NaohiroTamura/faasshell” and Try demos  Especially if you are interested in Functional and Logic Programming  Welcome your feedback!  naohirot@jp.fujitsu.com 20 Copyright 2018 FUJITSU LIMITED
  • 22.
    Q & A 21Copyright 2018 FUJITSU LIMITED
  • 23.
  • 24.
  • 25.
    Translation Service CatalogSpec among Multiple Clouds 24 Copyright 2018 FUJITSU LIMITED Cloud Service Name Current Supported Languages (more than 6,000 languages on the planet) AWS Amazon Translate 6 languages to and from English for Preview: (Arabic, Simplified Chinese, French, German, Spanish, and Portuguese) 6 additional languages will be supported soon, (Japanese, Russian, Italian, Traditional Chinese, Turkish, and Czech) Azure Translator Text supports more than 60 languages GCP Translation API supports more than 100 different languages IBM Language Translator Support 14 languages Arabic, Chinese (Simplified & Traditional), Dutch*, English, French, German, Italian, Japanese, Korean, Polish*, Portuguese (Brazil), Russian*, Spanish, and Turkish* *These languages are supported with the early access preview Not yet  Surprisingly, AWS is not the leader in this area at this moment Doesn’t work
  • 26.
    Comparison  Difference betweenServerless Framework and FaaS Shell  Serverless Framework : Portable Solution for Serverless Function  FaaS Shell : Portable Solution for Serverless Function Workflow  Related work  Serverless Inc. OSS Event Gateway : Similar but different focus and approach 25 Copyright 2018 FUJITSU LIMITED
  • 27.
    FaaS Shell Complierand Workflow DSL  Compiler supported Amazon State Language at first  Generate Workflow DSL  fsm()  pass()  task()  choice()  wait()  succeed()  fail()  parallel() 26 Copyright 2018 FUJITSU LIMITED { "Comment": "A Hello World example using a Task state", "StartAt": "HelloWorld", "States": { "HelloWorld": { "Type": "Task", "Resource":"arn:aws:lambda:us-east-2:410388484666:function:hello", "End": true } } } fsm([task('HelloWorld',"arn:aws:lambda:us-east-2:410388484666:function:hello",[])])
  • 28.
    FaaS Shell Runtime Execute Workflow DSL FSM (Finite State Machine)  Implemented as Meta Interpreter  Very concise code in language such as Lisp or Prolog  This is important to keep agility for future changes 27 Copyright 2018 FUJITSU LIMITED %% %% reduce(+Dsl, +In, -Out, +EnvIn, -EnvOut) %% reduce(fsm(Dsl), I, O, EI, EO) :- !, reduce(Dsl, I, O, EI, EO). reduce([], O, O, E, E) :- !. reduce([A|B], I, O, EI, EO) :- !, reduce(A, I, M, EI, EM), reduce(B, M, O, EM, EO), reduce(A, I, O, EI, EO) :- call(A, I, O, EI, EO). Entry Exit Recursive Call State
  • 29.
    FaaS Shell RuntimeExecutes Workflow in Batch Mode 28 Copyright 2018 FUJITSU LIMITED $ curl -ksX POST ${FAASSHELL_APIHOST}/statemachine/hello_world_task.json?blocking=true ¥ -H 'Content-Type: application/json' -d '{"input": {"name": "Curl"}}' -u $DEMO { "asl": { "Comment":"A Hello World example of the Amazon States Language using a Task state", "StartAt":"HelloWorld", "States": { "HelloWorld": { "End":true, "Resource":"arn:aws:lambda:us-east-2:410388484666:function:hello", "Type":"Task" } } }, "dsl":"fsm([task('HelloWorld',¥"arn:aws:lambda:us-east-2:410388484666:function:hello¥",[])])", "input": {"name":"Curl"}, "name":"hello_world_task.json", "namespace":"demo", "output": {"payload":"Hello, Curl!"} }
  • 30.
    How to resolveFunction Input and Output Mismatch?  State Optional Parameter InputPath, ResultPath, OutputPath 29 Copyright 2018 FUJITSU LIMITED "InputPath": "$.payload", "ResultPath": "$.ifttt.value1", "OutputPath": "$.ifttt", {“payload”: “Hello, IFTTT!”} {“value1”: “Hello, IFTTT!”} HelloWorld task output SaveResult task input { "Comment": “IFTTT as FaaS Demo", "StartAt": "HelloWorld", "States": { "HelloWorld": { "Type": "Task", "Resource":"frn:wsk:functions:::function:hello", "Next": "UpdateArg" }, "UpdateArg": { "Type": "Pass", "InputPath": "$.payload", "ResultPath": "$.ifttt.value1", "OutputPath": "$.ifttt", "Next": "SaveResult" }, "SaveResult": { "Type": "Task", "Resource":"frn:ifttt:webhooks:::function:save_result", "End": true } } }
  • 31.
    FaaS Shell REPLExecutes Workflow Interactively  Haskell REPL ghic> hello = ¥e -> return (e+1) ghic> update_arg= ¥e -> return (e*2) ghic> save_result = ¥e -> return (e^2) ghic> pure 1 >>= hello >>= update_arg >>= save_result 16  FaaS Shell REPL faasshell> Hello = task('HelloWorld',"frn:wsk:functions:::function:hello",[]), | UpdateArg = pass('UpdateArg',[result_path('$.ifttt.value1'),input_path('$.payload'),out_path('$.ifttt')]), | SaveResult = task('SaveResult',"frn:ifttt:webhooks:::function:save_result",[]), | startsm(_{name:"Repl"}), Hello, Pass, SaveResult. Output=Congratulations! You've fired the save_result event 30 Copyright 2018 FUJITSU LIMITED FaaS Shell startsm corresponds Haskell pure FaaS shell comma operator ',' corresponds to Haskell bind operator '>> ='.
  • 32.
    Devises for supportingMultiple Clouds  Function Name Resolution  Resource Naming (Direct Invocation)  Function Discovery (Indirect Invocation)  Event State  Supported Event State in Workflow DSL  CNCF WG-Serverless Whitepaper v1.0 [1] (P.32) pointed out: > AWS provides “step function” primitives (state machine based primitives) for the user to > specify its workflow, but step function does not allow specification of what event/events > triggering what functions in the workflow.  Amazon States Language can handle Event through Activity Task, but it’s not straightforward. [1] https://github.com/cncf/wg-serverless/blob/master/whitepaper/cncf_serverless_whitepaper_v1.0.pdf 31 Copyright 2018 FUJITSU LIMITED
  • 33.
    Resource Naming -Function Name Resolution (1)  Resource Naming in Amazon States Language Specification [1]  A Task State MUST include a “Resource” field, whose value MUST be a URI that uniquely identifies the specific task to execute.  AWS Step Functions Implementation  ARN (Amazon Resource Name) "Resource":"arn:aws:lambda:us-east-2:410388484666:function:hello“  FaaS Shell Implementation  FRN (FaaS Resource Name) AWS “ Resource”:“frn:aws: …“ or “arn:aws: …“ Microsoft “ Resource”:“frn:azure: …“ Google “ Resource”:“frn:gcp: …“ IBM/OpenWhisk “Resource”:“frn:wsk: … “ IFTTT “ Resource”:“frn:ifttt: …“ Fujitsu “ Resource”:“frn:k5: …“ [1] https://states-language.net/spec.html 32 Copyright 2018 FUJITSU LIMITED Either URN or URL
  • 34.
    Function Discovery -Function Name Resolution (2)  Discover Function Semantically  Make use of Open Linked Data technology, OWL (Web Ontology Language)  FaaS Shell Implementation  "Resource": "https://naohirotamura.github.io/faasshell/ns/faas#hello"  Define Triple (Subject – Predicate – Object)  User owns Function  FaaS assigns FRN  FRN invokes Function 33 Copyright 2018 FUJITSU LIMITED demo:User hello:Function aws:FaaS azure:FaaS gcp:FaaS wsk:FaaS frn01:FRN frn03:FRN frn02:FRN frn04:FRN URI: Unique Identifier https://naohirotamura.github.io/faasshell/ns/faas#hello
  • 35.
    Function Discovery Cont.- Function Name Resolution (2)  There are several weather service on Internet  Assume reusable function “weather” open linked RDF data or SPARQL end point is available  "Resource": "https://weather.org/ns/faas#weatherβ"  Querying the linked data, we will figured out that “frn02”,”frn03”,”frn04” are callable using PublicUser “u1” account. 34 Copyright 2018 FUJITSU LIMITED weatherβ:Weather serviceA:FaaS serviceB:FaaS serviceC:FaaS serviceD:FaaS frn01:FRN frn03:FRN frn02:FRN frn04:FRN URI is just Identifier u1:PublicUser weatherα:Weather Function ClassUser Class
  • 36.
    Event State 35 Copyright2018 FUJITSU LIMITED { "Comment": "A Hello Event example", "StartAt": "HelloEvent", "States": { "HelloEvent": { "Type": "Event", "Resource": "frn::states:::event:test", "End": true }, } } Start Event State frn::states:::event:test End ③ Function “hello” arn:aws:lambda:us-east-2:410388484666:function:hello ② Event “frn::states:::event:test” {“action”:”arn:aws:lambda:us-east-2:410388484666:function:hello” ① Input {“name”: “Event”} ④ Output {“payload”: “Hello, Event!”}
  • 37.
    FaaS Shell Deployment 36Copyright 2018 FUJITSU LIMITED Kubernetes/OpenShift Service End Point FaaS Shell 1 (statefulset) FaaS Shell 2 (statefulset) Message Queue (Kafka, Zookeeper) NoSQL DB (CouchDB) FaaS Shell 3 (statefulset) ・・・ NoSQL DB (CouchDB) Message Queue (Kafka, Zookeeper) Faasshell name space Docker/Kubenetes/OptnShift CouchDB FaaS Shell ① Development ② Horizontal Scale Out