My slides from the London Cloud Native Meetup on 7th August 2018.
Covering serverless, FaaS (Functions-as-a-Service) and the Fn project (with a bit of help from William Shakespeare).
Sales Territory Management: A Definitive Guide to Expand Sales Coverage
FaaS you like it (if Shakespeare had written Functions-as-a-Service)
1. FaaS You Like It
(If Shakespeare had written
Functions as a Service)
2. “All the world’s a stage, And all the men and women
merely players; They have their exits and their entrances,
And one man in his time plays many parts…”
4. Agenda
1. What is FaaS (or “Serverless”)
2. The Fn Project
3. FDKs
4. As you like it - performed by Fn functions, written in Ruby & Java
5. Synopsis
“As You Like It subverts the traditional rules of romance.
Gender roles, nature and politics are confused in a play that
reflects on how bewildering yet utterly pleasurable life can
be.”
- Royal Shakespeare Company
24. FaaS
● Write small functions
● Do one thing well
● Easy to Understand
● Easy to Maintain
● Run on Abstracted Infrastructure (“Serverless”) platform
26. What is “Serverless”?
● Serverless is an abstraction of infrastructure and its operations including
provisioning, scaling, patching, etc.
● Serverless architecture is when an app is built entirely on serverless
components (compute, storage, networking)
● Function as a Service (FaaS) is the compute component in a serverless
architecture
27. For a fuller discussion...
Mike Roberts article on MartinFowler.com
https://martinfowler.com/articles/serverless.html
“Fundamentally, FaaS is about running backend code without managing
your own server systems or your own long-lived server applications.”
32. PaaS vs FaaS
● Granularity, Scale & Time
○ Paas (or IaaS) ⇒ (Micro)Service, long - running
○ FaaS ⇒ Function, invoked on demand
If your PaaS can efficiently start instances in 20ms that run for half a
second, then call it serverless.
- Adrian Cockcroft
40. Fn Project:
Write your functions in any language*.
Run them in any environment*.
*Supports / supported by Docker
41. Fn Project ( fnproject.io )
● Open-source serverless compute platform
● Can be deployed to any cloud or on-premises
● Containers are primitives
● Active w/ 2500+ commits across 50+ contributors
● Independently governed with representation at CNCF
● support for the upcoming CloudEvents specification
○ (CNCF Serverless working group )
● integration with the Serverless Framework toolkit
42. Functions as Containers
● Function and dependencies
● Single - purpose
● Self - Contained
● Stateless
● Ephemeral
● Run on Demand
43. An Fn Function
● Small chunk of code wrapped into container
● Input from STDIN & Environment
● Output to STDOUT
● Logs to STDERR
52. Fn deploy details
● Bump version in func.yaml
● Build container (multi stage)
● Push container to registry
● Create / Update function route
MyFunc:0.0.2
MyFunc:0.0.2 MyFunc:0.0.2
Your code
Fn Service
myfunc →
/r/myapp/myfunc:0.0.2
1 2 3
54. Fn Server
● “API Gateway”
● Manages apps and functions
○ (app ⇒ group of functions)
● Synchronous function calls
○ Executed immediately
● Asynchronous function calls
○ Queued and executed when capacity available
● Runs as a Container
● Hosts function containers using Docker - in - Docker
55. Docker in Docker
● Limited “blast radius”
○ Doesn’t affect outer VM
○ Kill Fn container & restart
● Docker version independence
○ (inner can differ from outer)
● Reduce chance of container name collisions
57. Hot and Cold
● Cold Functions
○ Run once only
○ Terminate immediately
○ New container every invocation
● Hot Functions
○ Run at least once
○ Wait before terminating
○ Potentially reusable
60. Function Development Kits (FDKs)
● Developer writes a handler function to the FDKs interface
● FDK
○ Parses STDIN
○ Provides input data to function
○ Handles writing output and errors
○ Manages multiple invocations
● Makes it a lot easier to write hot functions
61. FDKs
● Ruby ( https://github.com/fnproject/fdk-ruby )
● Others
○ Python
○ Go
○ Java
○ Node
○ Rust
○ ...more on the way...
62. Without an FDK
● Dockerfile
● func.yaml
● func.* (e.g. func.sh)
● DIY
65. Flow
● Promises based Orchestration
○ No new “special” language
○ Composable
○ Flexible
○ Supports “Saga Pattern”
● A Flow is...
○ ...written in Code
○ ...written as Function
○ ...deployed as a function (within an application)