Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Recursive Architecture

Recursive Architecture

E40271b7c37cc8647cc5255344727edb?s=128

Josh Comer

June 04, 2016
Tweet

More Decks by Josh Comer

Other Decks in Programming

Transcript

  1. Recursive Architecture

  2. Josh Comer Math Dad Architect at LiveOps Cloud Tea Enthusiast

  3. What is Recursion

  4. Recursions 101 Definition: see recursion Real Definition: the repeated application

    of a procedure or definition Two mirrors, fractals, etc.
  5. CS Recursion Everyone’s favourite topic in school Remember recursion ==

    iteration Fib(n) = Fib(n-1) + Fib(n-2), Fib(0)=0, Fib(1)=1 Fib is interesting case as naïve recursion leads to O(phi^n) while naïve iteration is O(n), though easy to fix.
  6. Quicksort Divide and Conquer (defn qsort3 [[pivot :as coll]] (when

    pivot (lazy-cat (qsort (filter #(< % pivot) coll)) (filter #{pivot} coll) (qsort (filter #(> % pivot) coll)))))
  7. So what’s the big deal Recursion is pure Recursion is

    clean Recursion is terse The barrier to solving a problem recursively usually means the solution has been thought through
  8. Conway’s Law organizations which design systems ... are constrained to

    produce designs which are copies of the communication structures of these organizations — M. Conway
  9. Dev-isms

  10. Josh Comer Senior Distinguished Software Engineering Evangelist of the Architecture

    Variety
  11. BDD

  12. Blog Driven Development Someone who is greatly influenced by reading

    a single blog post… daily ...and then changes all the code
  13. SODD

  14. Stack Overflow Driven Development Someone who codes exclusively using Stack

    Overflow answers. I’m a SODD with bash ☺️
  15. Heisenbug

  16. Heisenbug A defect which only happens when not observing (debugging)

    the software
  17. return;

  18. Architecture

  19. Why do we use patterns? Patterns help us communicate Humans

    are really good at patterns
  20. But… Patterns all start to fall apart if everyone isn’t

    on the same page. Not everyone has the GoF book memorized
  21. Concurrency The next frontier in programing: Vertical Scaling won’t work

    anymore But concurrent programming is hard for even the best programmers Abstract away the concurrency!!! - Joe Armstrong
  22. OO Architecture Design from the abstraction towards the problem Good

    OO design requires a lot of upfront effort Distracts from the problem Harder to change (we don’t always get it right the first time)
  23. Recursive Architecture Conway’s Law We are, seemingly, naturally good at

    reasoning about systems in the large Distributed Systems are becoming the new norm
  24. Where is the recursive part? We can design our services

    using the same primitives as our platform The inside mirrors the outside
  25. Let’s Design Something

  26. <Insert cliché example>

  27. Temporally Sorted Activity Planner ⏰

  28. TSAP We need to make something that allows us to

    store tasks in a list (sorted temporally). In addition to the task list, we want to be able to schedule actions at particular times.
  29. TSAP

  30. TSAP API

  31. TSAP API Load Balancer

  32. TSAP API Load Balancer DB

  33. TSAP API Load Balancer DB Scheduler

  34. TSAP API Load Balancer DB Scheduler Notifier

  35. TSAP API Load Balancer DB Scheduler Notifier(s) Queue

  36. Scheduler Needs to be: Receive scheduling requests Store pending tasks

    Send triggered tasks to the notifier
  37. Scheduler

  38. Scheduler RPC

  39. Scheduler RPC Ingress Server

  40. Scheduler RPC Ingress Server DAL

  41. Scheduler RPC Ingress Server DAL Journal

  42. Scheduler RPC Ingress Server DAL Journal Egress Server

  43. Scheduler RPC Ingress Server DAL Journal Egress Server Queue

  44. Building Blocks There are three main building blocks: API Servers

    Processes Pub-Sub
  45. Building Blocks There are three main building blocks: API Servers

    -> Gen-Server Processes -> Actor Pub-Sub -> Gen-Event Supervisors Gen-FSM It’s the Erlang OTP Behaviours
  46. API Servers are key AXD301 (one of the biggest Erlang

    code bases) uses gen- servers for 63% of its behaviours APIs allow us to hide execution particulars (think façade pattern)
  47. “You know nothing API Snow” An API can hide concurrency

    (it acts as a load balancer) An API can make asynchronous calls synchronous An API can provide a translation layer An API can handle errors An API can manage resiliency
  48. Isn’t this an Interface? Not quite The API is an

    active piece of code that contains control logic For example gen-server has fns for: Sync Call Async Call Timeout Shutdown and Startup
  49. Can we take this further? API Load Balancer DB Scheduler

    Notifier(s) Queue
  50. Can we take this further?

  51. So what is a service?

  52. Mic Drop

  53. Microservices Let’s call them nanoservices Even smaller than microservices Responsible

    for an extremely small portion of logic Built to be deployed in a shared resource environment with other nanoservices
  54. Is this even a thing? Actors! Actors are back Erlang

    is making a comeback (check out Elixir) Akka or Quasar for Java Akka.net for .NET
  55. Fin