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

Infinispan in the world dominated by RAFT

Infinispan in the world dominated by RAFT

Slides for a talk I gave at Geecon Prague 2017. Source code for the demo is available at https://github.com/jfojtl/geecon17

Avatar for Jakub Fojtl

Jakub Fojtl

October 20, 2017
Tweet

More Decks by Jakub Fojtl

Other Decks in Programming

Transcript

  1. Distributed mode W(k,v) f(k) -> [nodeX,nodeY] numOwners W op requires

    fixed # of nodes ISPN cluster Client Consistent hashing function
  2. Distributed mode W(k,v) f(k) -> [nodeX,nodeY] numOwners scales linearly W

    op requires fixed # of nodes ISPN cluster Client Consistent hashing function
  3. Distributed mode W(k,v) f(k) -> [nodeX,nodeY] numOwners scales linearly W

    op requires fixed # of nodes sync & async versions ISPN cluster Client Consistent hashing function
  4. Distributed mode W(k,v) f(k) -> [nodeX,nodeY] numOwners scales linearly W

    op requires fixed # of nodes sync & async versions ISPN cluster W op is always accepted - AP system Client Consistent hashing function
  5. RAFT W(k,v) Single partially-ordered replicated log Requires n/2+1 nodes for

    W ops (works best with odd # of nodes) - CP system Leader Client
  6. RAFT W(k,v) Single partially-ordered replicated log Requires n/2+1 nodes for

    W ops (works best with odd # of nodes) - CP system Available as long as n/2+1 of cluster is healthy Leader Client
  7. RAFT W(k,v) Single partially-ordered replicated log Requires n/2+1 nodes for

    W ops (works best with odd # of nodes) - CP system Available as long as n/2+1 of cluster is healthy Complicated recovery Leader Client
  8. And suddenly you have 2 clusters ISPN cluster ISPN cluster

    both clusters are available rebalance happens
  9. And suddenly you have 2 clusters ISPN cluster ISPN cluster

    Client Client both clusters are available rebalance happens
  10. And suddenly you have 2 clusters ISPN cluster ISPN cluster

    Client Client W(k,v) W(k,v) both clusters are available rebalance happens
  11. ISPN cluster ISPN cluster + When the problem is solved

    there are accumulated data on both sides of split brain
  12. ISPN cluster ISPN cluster + When the problem is solved

    there are accumulated data on both sides of split brain Conflict resolution
  13. Merging Merge needs to happen when you have 2 different

    values on the same key Infinispan has merging policies
  14. Merging Merge needs to happen when you have 2 different

    values on the same key Infinispan has merging policies MergePolicies.PREFERRED_ALWAYS
  15. Merging Merge needs to happen when you have 2 different

    values on the same key Infinispan has merging policies MergePolicies.PREFERRED_ALWAYS MergePolicies.PREFERRED_NON_NULL
  16. Merging Merge needs to happen when you have 2 different

    values on the same key Infinispan has merging policies MergePolicies.PREFERRED_ALWAYS MergePolicies.PREFERRED_NON_NULL MergePolicies.REMOVE_ALL
  17. Merging Merge needs to happen when you have 2 different

    values on the same key Infinispan has merging policies MergePolicies.PREFERRED_ALWAYS MergePolicies.PREFERRED_NON_NULL MergePolicies.REMOVE_ALL Manual
  18. Merging Merge needs to happen when you have 2 different

    values on the same key Infinispan has merging policies MergePolicies.PREFERRED_ALWAYS MergePolicies.PREFERRED_NON_NULL MergePolicies.REMOVE_ALL … you need to decide what happened first Manual
  19. Time is not continuous very hard to synchronise clocks across

    cluster do not use time for coordination
  20. Time is not continuous very hard to synchronise clocks across

    cluster do not use time for coordination Talk: ordering of events in Systems by @kavya
  21. Append-only approach we only add data to DB model changes

    of data as events on one entity 3 kinds of events
  22. Append-only approach we only add data to DB model changes

    of data as events on one entity 1. Order of changes is determined based on the type of the event 3 kinds of events
  23. Append-only approach we only add data to DB model changes

    of data as events on one entity 1. Order of changes is determined based on the type of the event airplane journey: take off < landing < taxi 3 kinds of events
  24. Append-only approach inspired by some properties of Commutative replicated data

    structures (CRDTs) 2. commutative & idempotent events e1 + e2 + e2 = e2 + e1 e1 + e2 = e2 + e1
  25. Append-only approach inspired by some properties of Commutative replicated data

    structures (CRDTs) 2. commutative & idempotent events e1 + e2 + e2 = e2 + e1 3. Order of events does not matter e1 + e2 = e2 + e1
  26. Op requiring coordination sequence number generation Client S: 5 No

    coordination vs Store operation can be done only on one node without direct involvement of other nodes
  27. Op requiring coordination sequence number generation Client S: 5 No

    coordination no messages - no problem :) vs Store operation can be done only on one node without direct involvement of other nodes
  28. Transactions W For order of operations Roll-back incomplete writes to

    not damage data tx no update to existing data
  29. Transactions W For order of operations Roll-back incomplete writes to

    not damage data tx no update to existing data NoSQL - no foreign keys
  30. Transactions W For order of operations Roll-back incomplete writes to

    not damage data tx no update to existing data NoSQL - no foreign keys data cannot be damaged
  31. Transactions W For order of operations Roll-back incomplete writes to

    not damage data no update to existing data NoSQL - no foreign keys data cannot be damaged
  32. Transactions W For order of operations Roll-back incomplete writes to

    not damage data R no update to existing data NoSQL - no foreign keys data cannot be damaged read query must be designed to handle missing parts
  33. Transactions W For order of operations Roll-back incomplete writes to

    not damage data R no update to existing data NoSQL - no foreign keys data cannot be damaged read query must be designed to handle missing parts leaves unwanted artefacts - requires cleaning
  34. Client Client microservice microservice microservice ISPN cluster client responsible for

    finishing
 users’ wishes failover UUID for keys when client is down expectation of the user is that everything is lost op
  35. Client PUT /resource { … “op-id” : “Resource.05c1b930- add8-40cd-840c-920ed77429ed” …

    } Idempotent Distinquish between 2 wishes and 1 repeated wish Monitoring
  36. Take away RAFT is not bad Distributed system is hard

    to encapsulate Try to avoid coordination
  37. Take away RAFT is not bad Distributed system is hard

    to encapsulate The more resilient your application is the easier your life becomes once in production Try to avoid coordination
  38. Take away RAFT is not bad Distributed system is hard

    to encapsulate The more resilient your application is the easier your life becomes once in production Know the properties and limitations of the building blocks you use Try to avoid coordination
  39. @jakubfojtl | jfojtl.com Thank you Used resources can be found

    at https://pastebin.com/pqeD6M9n source code at https://github.com/jfojtl/geecon17