SOSCON Serverless Computing Models · FaaS: PaaS with less than 20 ms startup requirement can be...
Transcript of SOSCON Serverless Computing Models · FaaS: PaaS with less than 20 ms startup requirement can be...
FaaS: Function As A Service
SOSCON Serverless Computing Models
Samsung Electronics | Open Services Platform Lab
October 26, 2017
Container Technology Serverless
FaaS Platforms
Use Cases
Implementation
Beyond Cloud Economics & Scalability
Architectural Impact
Programming Models
Serverless Computing Models
Containers
Containers – popular container orchestration systems
CONTAINERS
Sandboxed Process: Forerunner to the concept of a container, to isolate a process space for
security
LXC/Linux Container
A Linux User Name space with chroot, ACLS associated with it.
KUBERNETES: Container Orchestration w/ Clustering, replication, high-availability support
DOCKER: Package an application with all its dependencies, comes from VM & hypervisor background
Others: rkt, OpenVZ
Linux containers act like process level wrappers that isolate the application and account for its resource consumption. -- Containers leverage the Linux namespaces [50] for isolation (e.g., network, process ID, mount points, etc.) & -- control groups (/cgroups) to limit & account for the resources (eg.CPU, memory and disk I/O) consumed by its processes. -- A container is spawned based on an image.
Containers vs. Hyper Containers vs. VMs
CONTAINERS
VM
Hyper.sh
Container
Serverless
SERVERLESS
From: https://www.slideshare.net/CodeOps/serverless-architecture-a-gentle-overview
SERVERLESS – FaaS, PaaS, BaaS, SaaS …
SERVERLESS
Serverless: A generic term for cod-execution on cloud (specifically PaaS, FaaS) – An architecture where code execution & runtime is fully managed by a cloud provider
– No responsibility to manage, provision, maintain servers to deploy code- faster development
– Run Code with any Backend, Runtime
– Called thru in-app composition or triggered from other services
– Highly scalable
FaaS:
PaaS with less than 20 ms startup requirement can be implemented with FaaS
F(Input) = Output – No side-effects
Stateless – In practice some state may still be maintained (e.g.. daemon sets)
Ephemeral – after generating output, f() not needed, applications may cache/reuse for perf.
AaaS & DbaaS can use FaaS to implement their requirements logic
Other Cloud Services that could use FaaS:
IaaS( IP addr, hostname …), DBaaS( DB CRUD operations), AaaS ( Analytics)
SERVERLESS
• Web Services existed a long time – Became easy to build, export & use with REST architecture
• Popularity of (Web)Apps on different devices made “application packaging & security” a priority
• RSS Feeds enabled real-time event-based services(FB Updates/Posts, google alerts)
• Big-Data presence required services to log, collect & process them
• Proliferation of IOT devices needed readymade/ready-to-use service capabilities
• Building heterogeneous systems(driven by IOT, Big data ...) by composing Micro-services
• Micro Service architectures evolved to support above
Use Cases Evolution Architecture Evolution
Desktop applications Web Services Web Apps Installable Appln packaging Big Data Data processing Services IOT Devices Cloud Event Processing
Monolithic architectures Web Servers SOA REST Architecture Big Data platforms Container Architectures Micro-Services
Serverless – Micro Services Evolution
FaaS Platforms
• AWS Lambda
– https://aws.amazon.com/lambda/
• IBM OpenWhisk
– https://www.ibm.com/cloud-computing/bluemix/openwhisk
• Google Cloud Functions(Fission, Funktion)
– https://cloud.google.com/functions/
• Microsoft Azure Functions
– https://azure.microsoft.com/en-us/services/functions/
• Others: – Webtask.io
– Iron.io
FAAS PLATFORMS
aws lambda create-function --function-name hello-test --runtime nodejs4.3 --zip-file fileb://./aws-lambda.zip --handler run.handle --role arn:aws:iam::259394719635:role/lambda { "CodeSha256": "QYKOebaDN/fqEzb1nmaV3ByNDZK3JvD0kWX6YQnPpjE=", "FunctionName": "hello-test", "CodeSize": 265356, "MemorySize": 128, "FunctionArn": "arn:aws:lambda:eu-west-1:259394719635:function:hello-test", "Version": "$LATEST", "Role": "arn:aws:iam::259394719635:role/lambda", "Timeout": 20, "LastModified": "2016-05-23T10:32:38.126+0000", "Handler": "run.handle", "Runtime": "nodejs4.3", "Description": "" } $ aws lamdba invoke-function --function-name hello-test { "StatusCode": 200 } $ cat test "child process exited with code 0“
FAAS PLATFORMS - AWS LAMDA
FAAS PLATFORMS - IBM OPENWHISK
FAAS PLATFORMS - GOOGLE CLOUD FUNCTIONS
https://cloud.google.com/functions/
FAAS PLATFORMS - MICROSOFT AZURE
GOOGLE CLOUD FREE LIMIT PER MONTH PRICE ABOVE FREE LIMIT PRICE UNIT
Invocations * 2 million invocations $0.40 per million invocations
Compute Time 400,000 GB-seconds $0.0000025 per GB-Second
200,000 GHz seconds $0.0000100 per GHz-Second
AZURE FUNCTIONS : PRICE FREE GRANT (PER MONTH)
Execution Time* $0.000016/GB-s 400,000 GB-s
Total Executions* $0.20 per million executions 1 million executions
AWS LAMBDA: First 1 million requests per month are free $0.20 per 1 million requests thereafter ($0.0000002 per request)
IBM Weather Company: •10 Calls per Minute 10,000 Calls per Account •Free
Maximum of 10 calls to The Weather Company per minute, up to a maximum of 10,000 API calls, for each Bluemix Account.
FAAS COST
AWS Lambda Google Cloud Fns Openwhisk/Bluemix Azure Function
Opensource X X O O
Min & Max memory 128MB ~ 1536MB Unknown 128MB ~ 512MB 1536MB
Supported Language C#, Java 8, Node.js 4.3, Pyt
hon Node.js
Docker, Node.js 6, Python, Swift v3
Bash, Batch, C#, F#, JavaScript, Php, PowerShell, Python
Scalability Automatic scaling Automatic scaling Automatic scaling Automatic scaling
function chaining user code can call other lam
bda functions X
Create sequence action by grouping each action
X
Integrations
API Gateway, AWS IoT, CloudFront, CloudWatch Event -Schedule, CloudWatch Logs, Cognito Sync Trigger, Dynamo
DB, Kinesis, S3, SNS
Cloud Storage, Cloud Pub/Sub, SendGrid, Slack
CLOUDANT, COMBINATORS, MOBILE PUSH, SLACK, WATSON SPEECH TO TEXT, WATSON TEXT TO SPEECH, WATSON TRANSLATOR, WEATHE
R, WEBSOCKET
Azure DocumentDB, Azure Event Hubs, Azure Mobile Apps(tables), Azure Notification Hubs, Azure Service Bus (queues and topics), Azure Storage (blob, queues, and tables), GitHub (webhooks), On-p
remises (using Service Bu
Template 70 templates 12 samples @github 48 templates in public
package 69 scenarios
FAAS PLATFORMS – FEATURE SUMMARY
Note: the platforms are evolving with new features, runtimes – so the following may not match the new infromation at their websites
Use Cases
• IOT device services – Raspberry Pies provide the h/w & basic OS, – Everything else can be provided by the Serverless – Event based processing suitable to IOT applications
• Static Web Pages /WebApp Backends – weather service, Add insertion – image compression
• Real-time Analytics – Image processing, – Text processing, – data processing, – map-reduce
• Chatbots/Data bots/Translation services – E.g. Facebook, google-translate. – IBM Watson services
• Github commits, buildbots • Application Composition from scalable micro-services • New high-level language paradigms
USE CASES
Deployment
Implementation – Building Blocks
– Pre-packaged language Runtimes
– Event Driven Architecture, Real-time Events / Data Feeds
– Third-party s/w Reuse
– Cloud-storage
– REST APIs
– SDKs for Mobile integration
System Configuration ( eg. Openwhisk) Runtimes supported
API Paths ( to list resources, to discover services, to call APIs/services)
Implementation – Guidelines
– Reusable, warm containers
– Container Orchestration for optimal resource use( multi-tenancy)
– Replication clusters for high-availability, reliability
– Config scripts for easy deployment/maintenance
IMPLEMENTATION
Pros: – Scalability , easy to build & deploy – Facilitates productivity by code-reuse via third-party libraries, runtimes, focusing on essential
application code – Language aspect:
• Application composition from existing functions • Polyglot programming
Cons: – Porting Existing Monolitic code (breaking up into micro-services based) – Security surface vulnerabilities (e.g.. from MultiTenancy) – Vendor lock-in/reliance
Application Suitability: – Latency requirements (not suitable for front –end, user-interactive applications) – Not for long running Jobs ( Eg. AWS Lambda terminated if run > 5 mns) – Only for ephemeral Programs Insensitive to State/History – Not for jobs that require extensive communication between each other
IMPLEMENTATION
Implementation – When to use Serverless
• Evaluated the FaaS platforms: – AWS Lambda
– OpenWhisk
• Experimenting with IBM OpenWhisk for internal FaaS Deployment
• Deployment on Kubernetes clusters
• Active participation in OpenWhisk developer forums
• OpenSource Contribution (Openwhisk, possibly Kubernetes)
• Challenges in mapping to underlying Container Orchestrations
• Ideally for use by internal AaaS, DBaaS, BaaS etc, along with FaaS use cases
FaaS Deployment
FaaS Deployment - OPENWHISK on Kubernetes
Deploy all components on the K8s cluster as a pod HA / Scalability can be managed by K8s
Faas Deployment – challenges, current limitations
OpenWhisk doesn’t have abstraction layer or any mechanism for the container based orchestration tool Abstraction layer would be a kind of bridge between OpenWhisk and Cloud Providers
Container
Container
Container ?
• So far most compelling arguments for Serverless computing
– Economics of operation (rent, pay-for-only-what-u-use)
– High Scalability
• 1977 ACM Turing Award Lecture (Backus- Can programming be Liberated?)
– Conventional programming languages are growing ever more enormous, but not stronger
– Alternative functional style of programming is founded on the use of combining forms for creating programs
– Combining forms can use high level programs to build still higher level ones in a style not possible in conventional languages.
• FaaS as the building-block, also enables new computing models, architectures, programming paradigms
• So far programs are written keeping the Computer architecture and language limitations in view - Now Computers can be built per application requirements
• Optimizations, Estimations possible thru employing Lambda-calculus
BEYOND CLOUD ECONOMICS & SCALABILITY
Virtual Function processor
ARCHITECTURAL IMPACT – Compute Model
Architectures – Traditional VonNeumann vs. FaaS based Architecture
FaaS Containers
Input and Output from/to
Cloud
Events/Data Feeds
NameSpace URLs
Cloud Storage
Clo
ud
bus
Cloud Storage
Events/ Data Feeds
FaaS Functions (some functions may b
e in h/w as FPGAs)
Input
Output
Container Namespace
ARCHITECTURAL IMPACT – OS Model
IoT Device Interface Thru FaaS Containers as Event handlers
Cloud OS
Applications
Cloud H/W
IOT
Dev Registry
device1
device2
device3
device-n
Eg. IOT Dev Registry == AWS IOT Thing Registry, IOT Hub Identity Registry, IBM Watson IOT Platform
FaaS as
Device ISRs
IMPACT ON PROGRAMMING MODELS
• Complex High-Level Instructions Sets, depending on the needs of the M/C
• Polyglot Programming Code/Service Reuse , program at a high level irrespective of specific Language Syntax Behind the REST API, it could be any implementation with any Runtime
• Function Composition
Lookup existing services thru catalogues, services Gradual, modular, testable, development Less scope for redundancy- leading to efficient code Building Complex /customized architectures from simpler Reference architectures
• Optimal Scheduling, Optimal Resource Utilization Lambda function sequence/composition expressed thru Eg. Mathematical Expressions Optimization of Programs thru Mathematical expression manipulation Formal Verification of Programs facilitated thru such expressions Automatic Parallelization of code (eg. thru mathematical re-factorization) Dynamic programming thru identifying reusable components automatically
PROGRAMMING MODELS – Function Composition
• Function Composition
• AWS Step Functions, AWS State Languages • IBM Function Composer • Azure Logic Apps The tools are not yet matured, so the composing programs look quite complex at the moment. But ideally, with stateless event driven functions, we could get to something like, "f1() + g1() + f1().g1() + f(g()) + C1. h1() + C2.f2() " // arguments to functions not mentioned Where C1, C2 constants refer to a particular Event,(/and rule combination)that triggers the function
Optimization of Resources/Time: Above programming forms can be used to optimize the workloads for memory & compute resources.
PROGRAMMING MODELS – Polyglot Functions
• FaaS:
• Specify Runtime • Upload Code to run
• FaaS, ideal of Ployglot Function Composition • Enables Code-reuse • Accommodates Programmer Flexibility • Enables choosing resource-optimal runtimes
Openwhisk polyglot Functions
References
Papers: • Next Generation Cloud Computing: New Trends and Research Directions • Status of Serverles Computing and_Function-as-a-Service : FaaS inIndustry and Research • Cloud Event Programming Paradigms: Applications and Analysis • Serverless Computation with OpenLambda • The Econonomics of Microservices: • Be Wary of the Economics of "Serverless" Cloud Computing • Comparing Scaling Methods for Linux Containers • Function level programs as mathematical objects • Can programming be liberated from the von Neumann style?: a functional style and its algebra of programs
OpenSrc Implementations: • https://github.com/openwhisk/openwhisk
http://docs.aws.amazon.com/lambda/latest/dg/building-lambda-apps.html • https://github.com/serverless/serverless • https://funktion.fabric8.io/docs/#get-starte • https://azure.microsoft.com/en-us/resources/samples/?sort=0 • https://github.com/apex/apex • https://github.com/iron-io/functions • https://webtask.io/
Copyright ⓒ 2017 SAMSUNG ELECTRONICS. ALL RIGHTS RESERVED
Q&A
Copyright ⓒ 2017 SAMSUNG ELECTRONICS. ALL RIGHTS RESERVED
THANK YOU