![Page 1: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/1.jpg)
Putting the F in FaaS
![Page 2: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/2.jpg)
! @trieloff
![Page 3: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/3.jpg)
⚡⚡⚡
![Page 4: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/4.jpg)
#serverlessconf ! 2017
![Page 5: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/5.jpg)
#serverlessconf! 2016(glad to be back)
![Page 6: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/6.jpg)
! @adobeio
![Page 7: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/7.jpg)
Opinions are my own
![Page 8: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/8.jpg)
Ideas are not
![Page 9: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/9.jpg)
⚡ Putting the F in FaaS
![Page 10: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/10.jpg)
WTF?
![Page 11: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/11.jpg)
WT !?
![Page 12: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/12.jpg)
F is for Functions
![Page 13: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/13.jpg)
Fundamentally, there are only two
programming styles: functional and dysfunctional.
![Page 14: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/14.jpg)
Functions in FaaS
![Page 15: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/15.jpg)
Stateless
![Page 16: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/16.jpg)
StatelessShort-lived
![Page 17: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/17.jpg)
StatelessShort-lived
Single-purpose
![Page 18: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/18.jpg)
StatelessShort-lived
Single-purposeBoring
![Page 19: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/19.jpg)
!"
![Page 20: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/20.jpg)
⚡ Serverless Functional Patterns for the
Aspiring Enterprise Architect
![Page 21: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/21.jpg)
Fundamentally, there are only two
architecture styles: functional and dysfunctional.
![Page 22: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/22.jpg)
#serverlessconf ! 2017
![Page 23: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/23.jpg)
#serverlessconf ! 2017(sorry, I missed it)
![Page 24: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/24.jpg)
#serverlessconf ! 2017(sorry, I missed it)
(but I read all the tweets)
![Page 25: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/25.jpg)
! @timallenwagnerThe Serverless Manifesto1. Functions are the unit of deployment and scaling
2. bla
3. bla
4. bla
5. Never pay for idle
![Page 26: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/26.jpg)
! @yochaykApplied Serverless Design Patterns1. Function Chaining
2. ASync HTTP (HTTP 202)
3. Fanout (Parallel)
4. Fanout + Fan-in
5. Long Running Function with Timeout
![Page 27: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/27.jpg)
! @ben11kehoe
What's Missing From Serverless Providers
Node is the WRONG runtime for serverless
![Page 28: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/28.jpg)
! @ben11kehoeWhat's Missing From Serverless Providers
Node is the WRONG runtime for serverless
![Page 29: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/29.jpg)
! @ben11kehoeWhat's Missing From Serverless Providers
Node is the WRONG runtime for serverless
(because it’s making you do async wrong)
![Page 30: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/30.jpg)
!
![Page 31: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/31.jpg)
!
![Page 32: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/32.jpg)
Greenspun's tenth rule
Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp.
tl;dr: LISP did it first
![Page 33: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/33.jpg)
⚡ What LISP can Teach You About Serverless
Patterns
![Page 34: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/34.jpg)
LISP !" Clojure
![Page 35: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/35.jpg)
map/pmap (a.k.a. Fan-Out)(map some-function some-data)Apply some-function to each entry of the array of data in some-data. Then return the result as a new array. In parallel: use pmap.Why? To process lots of data.
![Page 36: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/36.jpg)
apply (a.k.a. Proxy)(apply some-function x y z)Call some-function with arguments x, y, and z. Why? To make the function to be called a variable itself.
![Page 37: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/37.jpg)
comp (a.k.a. Function Chaining)(comp some-function some-other-function)Create a function that first calls some-function on the arguments, and then some-other-function on the results.Why? To call multiple services in order.
![Page 38: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/38.jpg)
reduce (a.k.a. Fan-In)(reduce some-function some-data)Call some-function on the first item of some-data, then call some-function again, using the result of the prior invocation and the next item in some-data as arguments.Why? To compress large data sets into small results.
![Page 39: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/39.jpg)
fold (a.k.a. Fan-In with ! on Top)(fold reducef combined some-data)Break some-data into multiple sets, run (reduce reducef) on each, then run (combine combinef) on the results.Why? To compress really large data sets into small results, in multiple steps.
![Page 40: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/40.jpg)
iterate (a.k.a. Endless Function)(iterate start-value some-function)Create a function that creates a data stream starting with start-value from repeated calls to some-function.Why? To turn some-function into a data emitter, without some-function needing state.
![Page 41: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/41.jpg)
juxt (a.k.a. Parallel Functions)(juxt some-function some-other-function)Makes a function that calls some-function and some-other-function and returns a combined result.Why? To combine the results of multiple functions in one call.
![Page 42: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/42.jpg)
memoize (a.k.a. Good Ol’ Cache)(memoize some-function)Return a cached version of some-function that returns the same value for the same arguments.Why? To trade slow computing against fast cache lookups.
![Page 43: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/43.jpg)
partial (a.k.a. Wrapper)(partial some-function value)Creates a function that calls some-function with value as an argument, in addition to other arguments.Why? To provide default values and make powerful functions less dangerous.
![Page 44: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/44.jpg)
That’s all the F you need
![Page 45: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/45.jpg)
⏰❓
![Page 46: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/46.jpg)
Can my Serverless Vendor do this?
![Page 47: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/47.jpg)
Probably. You need:1. A Serverless (FaaS) Runtime
2. An Event Passing System
3. A Document Database with Triggers
![Page 48: Putting the F in FaaS: Functional Compositional Patterns in a Serverless World](https://reader034.vdocuments.site/reader034/viewer/2022052117/5a6479387f8b9a63568b45e3/html5/thumbnails/48.jpg)
! @trieloff