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

Building Applications with Distributed Erlang

Building Applications with Distributed Erlang

NDC London, 2014

Christopher Meiklejohn

December 04, 2014
Tweet

More Decks by Christopher Meiklejohn

Other Decks in Programming

Transcript

  1. what is THE AGENDA (novice) 1. what is distributed erlang?

    (erlanger) 2. where do i go from here?
  2. what are the goals of a DISTRIBUTED SYSTEM “A distributed

    system is a software system in which components located on networked computers communicate and coordinate their actions by passing messages. The components interact with each other in order to achieve a common goal. Three significant characteristics of distributed systems are: concurrency of components, lack of a global clock, and independent failure of components.” Wikipedia, “Distributed Computing”
  3. what are some examples of a DISTRIBUTED SYSTEM distributed databases,

    riak, cassandra, etc. master/slave in sql, multi-partition txns
  4. what are some examples of a DISTRIBUTED SYSTEM distributed databases,

    riak, cassandra, etc. master/slave in sql, multi-partition txns web services via rest, soap, etc.
  5. what are some examples of a DISTRIBUTED SYSTEM distributed databases,

    riak, cassandra, etc. master/slave in sql, multi-partition txns web services via rest, soap, etc. mobile clients, internet of things
  6. why are distributed systems HARD the network is reliable L.

    Peter Deutsch, “Fallacies of Distributed Computing”
  7. why are distributed systems HARD the network is reliable latency

    is zero L. Peter Deutsch, “Fallacies of Distributed Computing”
  8. why are distributed systems HARD the network is reliable latency

    is zero bandwidth is infinite L. Peter Deutsch, “Fallacies of Distributed Computing”
  9. why are distributed systems HARD the network is reliable latency

    is zero bandwidth is infinite the network is secure L. Peter Deutsch, “Fallacies of Distributed Computing”
  10. why are distributed systems HARD the network is reliable latency

    is zero bandwidth is infinite the network is secure topology doesn’t change L. Peter Deutsch, “Fallacies of Distributed Computing”
  11. why are distributed systems HARD the network is reliable latency

    is zero bandwidth is infinite the network is secure topology doesn’t change there is one administrator L. Peter Deutsch, “Fallacies of Distributed Computing”
  12. why are distributed systems HARD the network is reliable latency

    is zero bandwidth is infinite the network is secure topology doesn’t change there is one administrator transport cost is zero L. Peter Deutsch, “Fallacies of Distributed Computing”
  13. why are distributed systems HARD the network is reliable latency

    is zero bandwidth is infinite the network is secure topology doesn’t change there is one administrator transport cost is zero the network is homogeneous L. Peter Deutsch, “Fallacies of Distributed Computing”
  14. what is DISTRIBUTED ERLANG 1 3 2 4 5 transparent

    • message passing • links • monitors transitive connections (except hidden nodes) access control via cookies
  15. what is DISTRIBUTED ERLANG 1 3 2 4 5 transparent

    • message passing • links • monitors transitive connections (except hidden nodes) access control via cookies 6
  16. what is DISTRIBUTED ERLANG 1 3 2 4 5 transparent

    • message passing • links • monitors transitive connections (except hidden nodes) access control via cookies 6
  17. what is DISTRIBUTED ERLANG 1 3 2 4 5 transparent

    • message passing • links • monitors transitive connections (except hidden nodes) access control via cookies 6
  18. what is DISTRIBUTED ERLANG 1 spawn functions on other nodes

    2 p1 p2 monitor or link on other nodes
  19. what is DISTRIBUTED ERLANG 1 spawn functions on other nodes

    2 p1 p2 monitor or link on other nodes 1 2 p1 p2
  20. what is DISTRIBUTED ERLANG 1 spawn functions on other nodes

    2 p1 p2 monitor or link on other nodes 1 2 p1
  21. what libraries come with DISTRIBUTED ERLANG global - global name

    registration and locking pg2 - process group registry
  22. what libraries come with DISTRIBUTED ERLANG global - global name

    registration and locking pg2 - process group registry mnesia - distributed transactions
  23. what libraries come with DISTRIBUTED ERLANG global - global name

    registration and locking pg2 - process group registry mnesia - distributed transactions net_kernel - erlang distributed networking kernel
  24. what libraries come with DISTRIBUTED ERLANG global - global name

    registration and locking pg2 - process group registry mnesia - distributed transactions net_kernel - erlang distributed networking kernel rpc - remote procedure call services
  25. what is GLOBAL global name registration and locking service shared

    state, replicated locally races under network partitions
  26. what is GLOBAL global name registration and locking service shared

    state, replicated locally races under network partitions provides ad-hoc resolution hook
  27. what is PG2 distributed process group registry usually used for

    work partitioning races under network partitions
  28. what is PG2 distributed process group registry usually used for

    work partitioning races under network partitions can lose values under network partitions
  29. what is PG2 distributed process group registry usually used for

    work partitioning races under network partitions can lose values under network partitions originally isis inspired, pg descendent
  30. transactional database in erlang implemented using replicated ets tables global

    transactions are *expensive* network partitions can cause values to be lost what is MNESIA
  31. maintenance of network in distributed erlang responsible for detecting failures

    dropped tcp connections, network partitions what is NET_KERNEL
  32. maintenance of network in distributed erlang responsible for detecting failures

    dropped tcp connections, network partitions poor mechanism for cluster management what is NET_KERNEL
  33. remote procedure call services serialized execution of requests call to

    a single node, or multi call synchronous programming pattern what is RPC
  34. what are the ANTI-PATTERNS* utilizing shared state reliance on physical

    time using predesignated masters treating the network as synchronous
  35. what are the ANTI-PATTERNS* utilizing shared state reliance on physical

    time using predesignated masters treating the network as synchronous * also: distributed objects, guaranteed delivery mechanisms, distributed serializable transactions, etc.
  36. what about CLUSTER MEMBERSHIP fixed membership, a priori don’t tie

    to net_kernel, net_ticktime store information locally, gossip 1 3 2 4
  37. what about CLUSTER MEMBERSHIP fixed membership, a priori don’t tie

    to net_kernel, net_ticktime store information locally, gossip hyparview, plumtree, thicket 1 3 2 4
  38. what about FAILURE DETECTION detection of delays vs. failed nodes

    net_kernel, net_ticktime the φ accrual failure detector 1 3 2 4
  39. what about FAILURE DETECTION detection of delays vs. failed nodes

    net_kernel, net_ticktime the φ accrual failure detector swim: membership and failure detector 1 3 2 4
  40. what about VALUE DIVERGENCE replicated data can diverge lamport clock,

    vector clocks, version vectors, wall clock identify concurrency 1 3 2 1 ?
  41. what about VALUE DIVERGENCE replicated data can diverge lamport clock,

    vector clocks, version vectors, wall clock identify concurrency how to resolve? lww vs. siblings vs. crdt 1 3 2 1 ?
  42. what about DISTRIBUTION BUFFERS 1 2 p1 p3 p2 large

    objects can cause head-of-line blocking
  43. what about DISTRIBUTION BUFFERS 1 2 p1 p3 p2 large

    objects can cause head-of-line blocking move objects to tcp sockets
  44. what about DISTRIBUTION BUFFERS 1 2 p1 p3 p2 large

    objects can cause head-of-line blocking move objects to tcp sockets increase distribution port buffer size
  45. what about DISTRIBUTION BUFFERS 1 2 p1 p3 p2 large

    objects can cause head-of-line blocking move objects to tcp sockets increase distribution port buffer size beware unbounded queues
  46. what about LEADER ELECTION gen_leader assumes fixed topology use paxos

    or raft gen_leader known to deadlock 1 2 3 4
  47. what about MESSAGE FORMATS mixed version clusters reality in large

    systems keep formats compatible upgrade to new format v1 v2
  48. distributed erlang gets you part of the way but, you

    still have to understand the problems and the tradeoffs what are the LESSONS
  49. distributed erlang gets you part of the way but, you

    still have to understand the problems and the tradeoffs what are the LESSONS http://christophermeiklejohn.com/distributed/systems/ 2013/07/12/readings-in-distributed-systems.html
  50. what are some useful ERLANG LIBRARIES riak_core: distributed systems toolkit

    https://github.com/basho/riak_core riak_ensemble: generic multi-paxos framework https://github.com/basho/riak_ensemble
  51. what are some useful ERLANG LIBRARIES riak_core: distributed systems toolkit

    https://github.com/basho/riak_core riak_ensemble: generic multi-paxos framework https://github.com/basho/riak_ensemble riak_dt: conflict-free replicated data types https://github.com/basho/riak_dt
  52. what are some useful ERLANG LIBRARIES riak_core: distributed systems toolkit

    https://github.com/basho/riak_core riak_ensemble: generic multi-paxos framework https://github.com/basho/riak_ensemble riak_dt: conflict-free replicated data types https://github.com/basho/riak_dt riak_test: riak_core testing framework https://github.com/basho/riak_test
  53. what are some useful RESEARCH PROJECTS syncfree: large-scale computation on

    erlang https://github.com/syncfree release: large-scale erlang deployments https://github.com/release-project/
  54. what are some useful RESEARCH PROJECTS syncfree: large-scale computation on

    erlang https://github.com/syncfree release: large-scale erlang deployments https://github.com/release-project/ paraphrase: parallel computation https://github.com/paraphrase