Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Putting the F in FaaS: Functional Compositional Patterns in a Serverless World

1,686 views

Published on

Presented at #ServerlessConf 2017 in New York City. Don't go looking for serverless patterns in strange places, take existing functional programming patterns instead.

Published in: Software
  • Hello! Get Your Professional Job-Winning Resume Here - Check our website! https://vk.cc/818RFv
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Putting the F in FaaS: Functional Compositional Patterns in a Serverless World

  1. 1. Putting the F in FaaS
  2. 2. ! @trieloff
  3. 3. ⚡⚡⚡
  4. 4. #serverlessconf ! 2017
  5. 5. #serverlessconf! 2016 (glad to be back)
  6. 6. ! @adobeio
  7. 7. Opinions are my own
  8. 8. Ideas are not
  9. 9. ⚡ Putting the F in FaaS
  10. 10. WTF?
  11. 11. WT !?
  12. 12. F is for Functions
  13. 13. Fundamentally, there are only two programming styles: functional and dysfunctional.
  14. 14. Functions in FaaS
  15. 15. Stateless
  16. 16. Stateless Short-lived
  17. 17. Stateless Short-lived Single-purpose
  18. 18. Stateless Short-lived Single-purpose Boring
  19. 19. !"
  20. 20. ⚡ Serverless Functional Patterns for the Aspiring Enterprise Architect
  21. 21. Fundamentally, there are only two architecture styles: functional and dysfunctional.
  22. 22. #serverlessconf ! 2017
  23. 23. #serverlessconf ! 2017 (sorry, I missed it)
  24. 24. #serverlessconf ! 2017 (sorry, I missed it) (but I read all the tweets)
  25. 25. ! @timallenwagner The Serverless Manifesto 1. Functions are the unit of deployment and scaling 2. bla 3. bla 4. bla 5. Never pay for idle
  26. 26. ! @yochayk Applied Serverless Design Patterns 1. Function Chaining 2. ASync HTTP (HTTP 202) 3. Fanout (Parallel) 4. Fanout + Fan-in 5. Long Running Function with Timeout
  27. 27. ! @ben11kehoe What's Missing From Serverless Providers Node is the WRONG runtime for serverless
  28. 28. ! @ben11kehoe What's Missing From Serverless Providers Node is the WRONG runtime for serverless
  29. 29. ! @ben11kehoe What's Missing From Serverless Providers Node is the WRONG runtime for serverless (because it’s making you do async wrong)
  30. 30. !
  31. 31. !
  32. 32. 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
  33. 33. ⚡ What LISP can Teach You About Serverless Patterns
  34. 34. LISP !" Clojure
  35. 35. 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.
  36. 36. 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.
  37. 37. 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.
  38. 38. 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.
  39. 39. 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.
  40. 40. 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.
  41. 41. 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.
  42. 42. 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.
  43. 43. 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.
  44. 44. That’s all the F you need
  45. 45. ⏰❓
  46. 46. Can my Serverless Vendor do this?
  47. 47. Probably. You need: 1. A Serverless (FaaS) Runtime 2. An Event Passing System 3. A Document Database with Triggers
  48. 48. ! @trieloff

×