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.

IRFC - A Design Pattern for Next Generation Business Applications: Couchbase Connect 2015

781 views

Published on

Published in: Software
  • Be the first to comment

IRFC - A Design Pattern for Next Generation Business Applications: Couchbase Connect 2015

  1. 1. IRFC A DESIGN PATTERN FOR NEXT GENERATION BUSINESS APPS Steve Yen, Couchbase, Inc.
  2. 2. IRFC A DESIGN PATTERN FOR NEXT GENERATION BUSINESS APPS Steve Yen, Couchbase, Inc. Immutable Requests For Change
  3. 3. IRFC A DESIGN PATTERN FOR NEXT GENERATION BUSINESS APPS Steve Yen, Couchbase, Inc. Immutable Requests For Change
  4. 4. IRFC A DESIGN PATTERN FOR NEXT GENERATION BUSINESS APPS Steve Yen, Couchbase, Inc. Immutable Requests For Change
  5. 5. ©2015 Couchbase Inc. 5 SteveYen steve@couchbase.com co-founder Couchbase
  6. 6. ©2015 Couchbase Inc. 6 How do I and my team build our Next Generation Business Applications using couchbase’s software suite?
  7. 7. ©2015 Couchbase Inc. 7 old school for inspiration
  8. 8. ©2015 Couchbase Inc. 8 old school
  9. 9. ©2015 Couchbase Inc. 9 old school document forms  real paper forms
  10. 10. ©2015 Couchbase Inc. 10 old school document forms  real paper forms press hard for 3 copies
  11. 11. ©2015 Couchbase Inc. 11 old school document forms  real paper forms press hard for 3 copies  yellow for accounting  pink for shipping  …
  12. 12. ©2015 Couchbase Inc. 12 old school document forms  real paper forms press hard for 3 copies  yellow for accounting  pink for shipping  … no erasers  route another form for changes
  13. 13. ©2015 Couchbase Inc. 13 old school wisdom document forms  real paper forms press hard for 3 copies  yellow for accounting  pink for shipping  … no erasers  route another form for changes denormalized replicatable route’able immutable
  14. 14. ©2015 Couchbase Inc. 14 old school wisdom denormalized replicatable route’able immutable  document forms  real paper forms  press hard for all 3 copies  yellow goes to accounting  pink for shipping  you keep white copy  canary for customer  no erasers  staple on yet another form for any future changes circa 2015
  15. 15. ©2015 Couchbase Inc. 15 old school wisdom denormalized replicatable route’able immutable  document forms  real paper forms  press hard for all 3 copies  yellow goes to accounting  pink for shipping  you keep white copy  canary for customer  no erasers  staple on yet another form for any future changes circa 2015 document databases
  16. 16. ©2015 Couchbase Inc. 16 old school wisdom denormalized replicatable route’able immutable  document forms  real paper forms  press hard for all 3 copies  yellow goes to accounting  pink for shipping  you keep white copy  canary for customer  no erasers  staple on yet another form for any future changes circa 2015 document databases sync functions
  17. 17. ©2015 Couchbase Inc. 17 old school wisdom denormalized replicatable route’able immutable  document forms  real paper forms  press hard for all 3 copies  yellow goes to accounting  pink for shipping  you keep white copy  canary for customer  no erasers  staple on yet another form for any future changes circa 2015 document databases sync functions the bottom line is immutability
  18. 18. ©2015 Couchbase Inc. 18 Pat Helland  “Immutability Changes Everything” http://www.cidrdb.org/cidr2015/Papers/CIDR15_Paper16.pdf  “Accountants don’t use erasers” http://blogs.msdn.com/b/pathelland/archive/2007/06/14/accountants-don-t-use-erasers.aspx CQRS  command query responsibility separation
  19. 19. ©2015 Couchbase Inc. 19 a familiar system-of-record web app server web browser
  20. 20. ©2015 Couchbase Inc. 20 a familiar system-of-record web app server web browser product-45 version: 1 name: t-shirt size: large price: 10 JSON stored in db
  21. 21. ©2015 Couchbase Inc. 21 a familiar system-of-record web app server web browser product-45 version: 1 name: t-shirt size: large price: 10 JSON stored in db
  22. 22. ©2015 Couchbase Inc. 22 a familiar system-of-record web app server web browser product-45 version: 1 name: t-shirt size: large price: 10 JSON stored in db browser GET’s a copy
  23. 23. ©2015 Couchbase Inc. 23 a familiar system-of-record web app server web browser product-45 version: 1 name: t-shirt size: large price: 10 JSON stored in db 1 browser GET’s a copy
  24. 24. ©2015 Couchbase Inc. 24 a familiar system-of-record web app server web browser product-45 version: 1 name: t-shirt size: large price: 10 JSON stored in db 1
  25. 25. ©2015 Couchbase Inc. 25 a familiar system-of-record web app server web browser product-45 version: 1 name: t-shirt size: large price: 10 JSON stored in db 1 render to view on-demand
  26. 26. ©2015 Couchbase Inc. 26 a familiar system-of-record web app server web browser product-45 version: 1 name: t-shirt size: large price: 10 JSON stored in db next, user wants to make some updates 1
  27. 27. ©2015 Couchbase Inc. 27 a familiar system-of-record web app server web browser product-45 version: 1 price: 10 -> 15 JSON stored in db JSON from AJAX / REST request product-45 version: 1 name: t-shirt size: large price: 10 1 AJAX/REST
  28. 28. ©2015 Couchbase Inc. 28 a familiar system-of-record web app server product-45 version: 1 price: 10 -> 15 JSON stored in db web browser product-45 version: 1 name: t-shirt size: large price: 10 product-45 version: 2 name: t-shirt size: large price: 15 1 JSON from AJAX / REST request AJAX/REST
  29. 29. ©2015 Couchbase Inc. 29 a familiar system-of-record web app server product-45 version: 1 price: 10 -> 15 JSON stored in db web browser ✓HTTP 200 ok product-45 version: 1 name: t-shirt size: large price: 10 product-45 version: 2 name: t-shirt size: large price: 15 1 JSON from AJAX / REST request AJAX/REST
  30. 30. ©2015 Couchbase Inc. 30 a familiar system-of-record web app server product-45 version: 1 price: 10 -> 15 JSON stored in db web browser product-45 version: 1 name: t-shirt size: large price: 10 product-45 version: 2 name: t-shirt size: large price: 15 1 2 JSON from AJAX / REST request AJAX/REST ✓HTTP 200 ok
  31. 31. ©2015 Couchbase Inc. 31 a familiar system-of-record web app server JSON stored in db web browser product-45 version: 1 name: t-shirt size: large price: 10 product-45 version: 2 name: t-shirt size: large price: 15 1 2
  32. 32. a concurrent client appears!
  33. 33. ©2015 Couchbase Inc. 33 concurrent client web app server JSON stored in db web browser product-45 version: 1 name: t-shirt size: large price: 10 product-45 version: 2 name: t-shirt size: large price: 15 1 2
  34. 34. ©2015 Couchbase Inc. 34 concurrent client web app server JSON stored in db web browser product-45 version: 1 name: t-shirt size: large price: 10 product-45 version: 2 name: t-shirt size: large price: 15 web browser 1 2 1
  35. 35. ©2015 Couchbase Inc. 35 concurrent client web app server JSON stored in db web browser product-45 version: 1 name: t-shirt size: large price: 10 product-45 version: 2 name: t-shirt size: large price: 15 web browser 1 2 1 product-45 version: 1 price: 10 -> 8
  36. 36. ©2015 Couchbase Inc. 36 concurrent client web app server web browser product-45 version: 1 price: 10 -> 8 JSON stored in db HTTP 409 conflictproduct-45 version: 1 name: t-shirt size: large price: 10 product-45 version: 2 name: t-shirt size: large price: 15 web browser 1 2 1
  37. 37. what if…
  38. 38. ©2015 Couchbase Inc. 38 product-45 version: 2 price: 15 -> 20 what if… web browser 1 2 JSON from AJAX / REST request web app server ✓HTTP 200 ok AJAX/REST
  39. 39. ©2015 Couchbase Inc. 39 product-45 version: 2 price: 15 -> 20 what if… web browser 1 2 JSON from AJAX / REST request this JSON is ephemeral web app server ✓HTTP 200 ok AJAX/REST
  40. 40. ©2015 Couchbase Inc. 40 product-45 version: 2 price: 15 -> 20 what if… web browser 1 2 JSON from AJAX / REST request web app server ✓HTTP 200 ok AJAX/REST what if… we held onto this request JSON?
  41. 41. ©2015 Couchbase Inc. 41 product-45 version: 2 price: 15 -> 20 req-id: 91 what if… web browser 1 2 JSON from AJAX / REST request web app server ✓HTTP 200 ok AJAX/REST what if… we held onto this request JSON?
  42. 42. why?
  43. 43. ©2015 Couchbase Inc. 43 slow, offline server web app server web browser 1 2 server gets really slow or goes down
  44. 44. ©2015 Couchbase Inc. 44 slow, offline server web app server web browser 1 2 validate.js mvc.js business logic unavailable server gets really slow or goes down
  45. 45. ©2015 Couchbase Inc. 45 validate.js slow, offline server web app server web browser 1 2 validate.js mvc.js mvc.js some business logic runs on both client and server side (some) business logic can run on both client and server side
  46. 46. ©2015 Couchbase Inc. 46 validate.js slow, offline server web app server web browser product-45 version: 2 price: 15 -> 20 req-id: 91 1 2 JSON from queued request validate.js mvc.js mvc.js
  47. 47. ©2015 Couchbase Inc. 47 validate.js slow, offline server web browser product-45 version: 2 price: 15 -> 20 req-id: 91 1 2 JSON from queued request mvc.js run client-side validation and provisional model updates validate.js mvc.js
  48. 48. ©2015 Couchbase Inc. 48 validate.js slow, offline server web browser product-45 version: 2 price: 15 -> 20 req-id: 91 1 2 JSON from queued request mvc.js run client-side validation and provisional model updates validate.js mvc.js client side can directly update its copy of the biz document… simple for update; complex for conflict resolution
  49. 49. ©2015 Couchbase Inc. 49 validate.js slow, offline server web browser 1 2 JSON from queued request mvc.js product-45 version: 2 maybe name: t-shirt size: large price: 20 maybe run client-side validation and provisional model updates run client-side validation and provisional model updates product-45 version: 2 price: 15 -> 20 req-id: 91 validate.js mvc.js
  50. 50. ©2015 Couchbase Inc. 50 validate.js slow, offline server web browser 1 2 JSON from queued request mvc.js product-45 version: 2 maybe name: t-shirt size: large price: 20 maybe product-45 version: 2 price: 15 -> 20 req-id: 91 a provisional biz document because client is not the source of truth
  51. 51. ©2015 Couchbase Inc. 51 validate.js slow, offline server web browser 1 2 JSON from queued request(s) mvc.js product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 20 -> 18 req-id: 92
  52. 52. ©2015 Couchbase Inc. 52 validate.js slow, offline server web browser 1 2 JSON from queued request(s) mvc.js product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 18 -> 10 req-id: 93
  53. 53. ©2015 Couchbase Inc. 53 validate.js slow, offline server web browser 1 2 JSON from queued request(s) mvc.js product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 10 -> 12 req-id: 94
  54. 54. ©2015 Couchbase Inc. 54 validate.js slow, offline server web browser 1 2 JSON from queued request(s) mvc.js product-45 version: 2 maybe name: t-shirt size: large price: 12 maybe run client-side validation and provisional model updates run client-side validation and provisional model updates product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 10 -> 12 req-id: 94 validate.js mvc.js
  55. 55. ©2015 Couchbase Inc. 55 validate.js slow, offline server web browser Change Requests 1 2 JSON from queued request(s) mvc.js product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 10 -> 12 req-id: 94
  56. 56. server’s back online
  57. 57. ©2015 Couchbase Inc. 57 validate.js server’s back online web browser Change Requests 1 2 JSON from queued request(s) mvc.js product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 10 -> 12 req-id: 94
  58. 58. ©2015 Couchbase Inc. 58 validate.js server’s back online web app server web browser Change Requests 1 2 validate.js JSON from queued request(s) mvc.js mvc.js 1 2 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 10 -> 12 req-id: 94 backend systems server’s back online! source of truth, system of record has returned!
  59. 59. ©2015 Couchbase Inc. 59 validate.js server’s back online web app server web browser Change Requests 1 2 validate.js JSON from queued request(s) mvc.js mvc.js AJAX/REST 1 2 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 10 -> 12 req-id: 94 backend systems
  60. 60. ©2015 Couchbase Inc. 60 validate.js server’s back online web app server web browser Change Requests 1 2 validate.js JSON from queued request(s) mvc.js mvc.js AJAX/REST 1 2 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 10 -> 12 req-id: 94 check for concurrent changes, business rules, other systems backend systems
  61. 61. ©2015 Couchbase Inc. 61 validate.js server’s back online web app server web browser Change Requests 1 2 validate.js JSON from queued request(s) mvc.js mvc.js AJAX/REST 1 2 2 2 5 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 10 -> 12 req-id: 94 backend systems check for concurrent changes, business rules, other systems
  62. 62. ©2015 Couchbase Inc. 62 validate.js server’s back online web app server web browser Change Requests 1 2 validate.js JSON from queued request(s) mvc.js mvc.js product-45 version: 1 price: 10 -> XL product-45 version: 1 price: 10 -> XL product-45 version: 1 price: 10 -> XL product-45 version: 5 req-id: 94 OK Change Responses AJAX/REST 1 2 2 2 5 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 10 -> 12 req-id: 94 backend systems
  63. 63. ©2015 Couchbase Inc. 63 validate.js server’s back online web app server web browser Change Requests 1 2 validate.js JSON from queued request(s) mvc.js mvc.js product-45 version: 1 price: 10 -> XL product-45 version: 1 price: 10 -> XL product-45 version: 1 price: 10 -> XL product-45 version: 5 req-id: 94 OK Change Responses AJAX/REST 1 2 2 2 5 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 10 -> 12 req-id: 94 backend systems every Change Request gets its own, paired Change Response
  64. 64. ©2015 Couchbase Inc. 64 validate.js server’s back online web app server web browser Change Requests 1 2 validate.js JSON from queued request(s) mvc.js mvc.js product-45 version: 1 price: 10 -> XL product-45 version: 1 price: 10 -> XL product-45 version: 1 price: 10 -> XL product-45 version: 5 req-id: 94 OK Change Responses AJAX/REST 1 2 2 2 5 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 10 -> 12 req-id: 94 backend systems
  65. 65. ©2015 Couchbase Inc. 65 product-45 version: 1 price: 10 -> XL product-45 version: 1 price: 10 -> XL product-45 version: 1 price: 10 -> XL product-45 version: 5 req-id: 94 OK validate.js server’s back online web app server web browser Change Requests 1 2 validate.js JSON from queued request(s) mvc.js mvc.js Change Responses AJAX/REST 1 2 2 2 5 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 10 -> 12 req-id: 94 backend systems
  66. 66. ©2015 Couchbase Inc. 66 product-45 version: 1 price: 10 -> XL product-45 version: 1 price: 10 -> XL product-45 version: 1 price: 10 -> XL product-45 version: 5 req-id: 94 OK validate.js server’s back online web app server web browser Change Requests 1 2 validate.js JSON from queued request(s) mvc.js mvc.js Change Responses 1 2 2 2 5 2 2 5 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 15 -> 20 req-id: 91 product-45 version: 2 price: 10 -> 12 req-id: 94 backend systems
  67. 67. what ab ut mobile?
  68. 68. ©2015 Couchbase Inc. 68 web app server web browser 1 2 2 2 5 backend systems
  69. 69. ©2015 Couchbase Inc. 69 works for mobile, too web app server web browser 1 2 2 2
  70. 70. ©2015 Couchbase Inc. 70 works for mobile, too web app server web browser CB Sync Gateway1 2 2 2 5
  71. 71. ©2015 Couchbase Inc. 71 works for mobile, too web app server web browser CB Mobile CB Sync Gateway1 2 2 2 5
  72. 72. ©2015 Couchbase Inc. 72 works for mobile, too CB Mobile
  73. 73. ©2015 Couchbase Inc. 73 works for mobile, too product-45 version: 2 name: t-shirt size: large price: 15 product 45 name: t-shirt size: large price: 15 CB Mobile
  74. 74. ©2015 Couchbase Inc. 74 works for mobile, too product-45 version: 2 name: t-shirt size: large price: 15 product 45 name: t-shirt size: large price: 15 CB Mobile
  75. 75. ©2015 Couchbase Inc. 75 works for mobile, too product-45 version: 2 name: t-shirt size: large price: 15 product-45 version: 2 req-id: 94 product 45 name: t-shirt size: large price: 15 CB Mobile
  76. 76. ©2015 Couchbase Inc. 76 works for mobile, too product-45 version: 2 name: t-shirt size: large price: 15 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 97 product 45 name: t-shirt size: large price: 15 CB Mobile
  77. 77. ©2015 Couchbase Inc. 77 works for mobile, too product-45 version: 2 name: t-shirt size: large price: 15 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 98 product 45 name: t-shirt size: large price: 15 CB Mobile
  78. 78. ©2015 Couchbase Inc. 78 works for mobile, too product-45 version: 2 name: t-shirt size: large price: 15 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 99 product 45 name: t-shirt size: large price: 15 CB Mobile
  79. 79. ©2015 Couchbase Inc. 79 works for mobile, too product-45 version: 2 name: t-shirt size: large price: 15 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product 45 name: t-shirt size: large price: 15 validate mvc product-45 version: 2 req-id: 99 CB Mobile
  80. 80. ©2015 Couchbase Inc. 80 works for mobile, too product-45 version: 2 name: t-shirt size: large price: 15 product-45 version: 2 maybe name: t-shirt size: large price: 20 maybe product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product 45 name: t-shirt size: large price: 15 product-45 version: 2 req-id: 99 CB Mobile validate mvc
  81. 81. ©2015 Couchbase Inc. 81 works for mobile, too product-45 version: 2 name: t-shirt size: large price: 15 product-45 version: 2 maybe name: t-shirt size: large price: 20 maybe product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product 45 name: t-shirt size: large price: 20 product 45 name: t-shirt size: large price: 15 product-45 version: 2 req-id: 99 no signal? no problem keeps on working CB Mobile validate mvc
  82. 82. ©2015 Couchbase Inc. 82 works for mobile, too product-45 version: 2 name: t-shirt size: large price: 15 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product 45 name: t-shirt size: large price: 15 product-45 version: 2 req-id: 99 CB Mobile
  83. 83. ©2015 Couchbase Inc. 83 works for mobile, too product-45 version: 2 name: t-shirt size: large price: 15 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product 45 name: t-shirt size: large price: 15 product-45 version: 2 req-id: 99 CB Mobile
  84. 84. ©2015 Couchbase Inc. 84 product-45 version: 5 req-id: 94 product-45 version: 5 req-id: 94 product-45 version: 5 req-id: 94 product-45 version: 5 req-id: 94 product-45 version: 5 req-id: 94 product-45 version: 8 req-id: 99 works for mobile, too product-45 version: 2 name: t-shirt size: large price: 15 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product 45 name: t-shirt size: large price: 15 product-45 version: 2 req-id: 99 CB Mobile
  85. 85. ©2015 Couchbase Inc. 85 product-45 version: 5 req-id: 94 product-45 version: 5 req-id: 94 product-45 version: 5 req-id: 94 product-45 version: 5 req-id: 94 product-45 version: 5 req-id: 94 product-45 version: 8 req-id: 99 product-45 version: 8 name: t-shirt size: large price: 20 product 45 name: t-shirt size: large price: 20 works for mobile, too product-45 version: 2 name: t-shirt size: large price: 15 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product 45 name: t-shirt size: large price: 15 product-45 version: 2 req-id: 99 CB Mobile
  86. 86. ©2015 Couchbase Inc. 86 product-45 version: 5 req-id: 94 product-45 version: 5 req-id: 94 product-45 version: 5 req-id: 94 product-45 version: 5 req-id: 94 product-45 version: 5 req-id: 94 product-45 version: 8 req-id: 99 product-45 version: 8 name: t-shirt size: large price: 20 product 45 name: t-shirt size: large price: 20 works for mobile, too product-45 version: 2 name: t-shirt size: large price: 15 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product 45 name: t-shirt size: large price: 15 product-45 version: 2 req-id: 99 Change Requests & Change Responses are now actual, persisted, replicated, routed JSON documents CB Mobile
  87. 87. ©2015 Couchbase Inc. 87 works for mobile, too web app server web browser CB Mobile CB Sync Gateway ✓
  88. 88. ©2015 Couchbase Inc. 88 works for mobile, too web app server web browser CB Mobile CB Sync Gateway ✓ Sync-Gateway is used as a message queue, but with advanced sync functions
  89. 89. advanced mobile topologies
  90. 90. ©2015 Couchbase Inc. 90 advanced mobile topologies web app server web browser CB Mobile CB Sync Gateway
  91. 91. ©2015 Couchbase Inc. 91 advanced mobile topologies : hub & spoke web app server web browser CB Mobile CB Mobile CB Sync Gateway hub & spoke CB Mobile
  92. 92. ©2015 Couchbase Inc. 92 advanced mobile topologies : peer to peer web app server web browser CB MobileCB Mobile CB MobileCB MobileCB MobileCB Mobile CB Sync Gateway peer to peer hub & spoke
  93. 93. ©2015 Couchbase Inc. 93 product-45 version: 2 name: t-shirt size: large price: 15 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 99 peer to peer sync
  94. 94. ©2015 Couchbase Inc. 94 product-45 version: 2 req-id: 94 product-45 version: 2 name: t-shirt size: large price: 15 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 99 peer to peer sync Change Requests sync’ed from peers
  95. 95. ©2015 Couchbase Inc. 95 product-45 version: 2 req-id: 94product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 peer to peer sync product-45 version: 2 name: t-shirt size: large price: 15 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 99 Change Requests sync’ed from peers
  96. 96. ©2015 Couchbase Inc. 96 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 peer to peer sync product-45 version: 2 name: t-shirt size: large price: 15 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 99 Change Requests sync’ed from peers
  97. 97. ©2015 Couchbase Inc. 97 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 peer to peer sync product-45 version: 2 name: t-shirt size: large price: 15 product-45 version: 2 maybe name: t-shirt size: large price: 20 maybe product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product 45 name: t-shirt size: small price: 20 product-45 version: 2 req-id: 99 Change Requests sync’ed from peers validate mvc
  98. 98. ©2015 Couchbase Inc. 98 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 99 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 peer to peer sync product-45 version: 2 name: t-shirt size: large price: 15 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 99 Change Requests sync’ed from peers Change Responses sync’ed from peers
  99. 99. ©2015 Couchbase Inc. 99 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 99 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 peer to peer sync product-45 version: 2 name: t-shirt size: large price: 15 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 94 product-45 version: 2 req-id: 99 Change Requests sync’ed from peers Change Responses sync’ed from peers product-45 version: 99 name: t-shirt size: large price: 18 new versions sync’ed from peers
  100. 100. ©2015 Couchbase Inc. 100 advanced mobile topologies web app server web browser CB MobileCB Mobile CB MobileCB MobileCB MobileCB Mobile CB Sync Gateway peer 2 peer hub & spoke ✓ ✓
  101. 101. kinds of IRFC documents
  102. 102. ©2015 Couchbase Inc. 102 immutable replicatable routable Biz Document Change Request Change Response Provisional Biz Document product-45 version: 2 name: t-shirt size: large price: 15 product-45 version: 5 req-id: 94 product-45 version: 2 req-id: 94 kinds of IRFC documents product-45 version: 2 maybe name: t-shirt size: large price: 15 maybe
  103. 103. ©2015 Couchbase Inc. 103 immutable replicatable routable Biz Document versioned y y Change Request Change Response Provisional Biz Document product-45 version: 2 name: t-shirt size: large price: 15 product-45 version: 5 req-id: 94 product-45 version: 2 req-id: 94 kinds of IRFC documents product-45 version: 2 maybe name: t-shirt size: large price: 15 maybe
  104. 104. ©2015 Couchbase Inc. 104 immutable replicatable routable Biz Document versioned y y Change Request y y y Change Response y y y Provisional Biz Document product-45 version: 2 name: t-shirt size: large price: 15 product-45 version: 5 req-id: 94 product-45 version: 2 req-id: 94 kinds of IRFC documents product-45 version: 2 maybe name: t-shirt size: large price: 15 maybe
  105. 105. ©2015 Couchbase Inc. 105 immutable replicatable routable Biz Document versioned y y Change Request y y y Change Response y y y Provisional Biz Document mutable no no client-side-only client-side-only product-45 version: 2 name: t-shirt size: large price: 15 product-45 version: 5 req-id: 94 product-45 version: 2 req-id: 94 kinds of IRFC documents product-45 version: 2 maybe name: t-shirt size: large price: 15 maybe
  106. 106. ©2015 Couchbase Inc. 106 creator updator Biz Document Change Request Change Response Provisional Biz Document kinds of IRFC documents, part 2 product-45 version: 2 name: t-shirt size: large price: 15 product-45 version: 2 maybe name: t-shirt size: large price: 15 maybe product-45 version: 5 req-id: 94 product-45 version: 2 req-id: 94
  107. 107. ©2015 Couchbase Inc. 107 creator updator Biz Document S-O-R S-O-R system of record system of record Change Request Change Response Provisional Biz Document kinds of IRFC documents, part 2 product-45 version: 2 name: t-shirt size: large price: 15 product-45 version: 2 maybe name: t-shirt size: large price: 15 maybe product-45 version: 5 req-id: 94 product-45 version: 2 req-id: 94
  108. 108. ©2015 Couchbase Inc. 108 creator updator Biz Document S-O-R S-O-R system of record system of record Change Request client no, immutable Change Response S-O-R no, immutable Provisional Biz Document kinds of IRFC documents, part 2 product-45 version: 2 name: t-shirt size: large price: 15 product-45 version: 2 maybe name: t-shirt size: large price: 15 maybe product-45 version: 5 req-id: 94 product-45 version: 2 req-id: 94
  109. 109. ©2015 Couchbase Inc. 109 creator updator Biz Document S-O-R S-O-R system of record system of record Change Request client no, immutable Change Response S-O-R no, immutable Provisional Biz Document client client kinds of IRFC documents, part 2 product-45 version: 2 name: t-shirt size: large price: 15 product-45 version: 2 maybe name: t-shirt size: large price: 15 maybe product-45 version: 5 req-id: 94 product-45 version: 2 req-id: 94
  110. 110. ©2015 Couchbase Inc. 110 creator updator deleter Biz Document S-O-R S-O-R system of record system of record Change Request client no, immutable Change Response S-O-R no, immutable Provisional Biz Document client client kinds of IRFC documents, part 2 product-45 version: 2 name: t-shirt size: large price: 15 product-45 version: 2 maybe name: t-shirt size: large price: 15 maybe product-45 version: 5 req-id: 94 product-45 version: 2 req-id: 94
  111. 111. ©2015 Couchbase Inc. 111 creator updator deleter Biz Document S-O-R S-O-R S-O-R system of record system of record Change Request client no, immutable requestor w/ change-response Change Response S-O-R no, immutable requestor w/ change-request Provisional Biz Document client client client kinds of IRFC documents, part 2 product-45 version: 2 name: t-shirt size: large price: 15 product-45 version: 2 maybe name: t-shirt size: large price: 15 maybe product-45 version: 5 req-id: 94 product-45 version: 2 req-id: 94
  112. 112. business scenarios
  113. 113. ©2015 Couchbase Inc. 113 works for many business documents  product / item  customer  employee / org  supplier  invoice  sales-order  packing-slip  shipping-manifest  inventory-count  RMA’s product-45 version: 2 name: t-shirt size: large price: 15
  114. 114. ©2015 Couchbase Inc. 114 works for many business documents  product / item  customer  employee / org  supplier  invoice  sales-order  packing-slip  shipping-manifest  inventory-count  RMA’s  item-transfer  acct-transfer  dashboard  leaderboard  report product-45 version: 2 name: t-shirt size: large price: 15
  115. 115. ©2015 Couchbase Inc. 115 works for many business documents  product / item  customer  employee / org  supplier  invoice  sales-order  packing-slip  shipping-manifest  inventory-count  RMA’s  likes / votes / pokes?  10 M followers?  10 M comments?  item-transfer  acct-transfer  dashboard  leaderboard  report product-45 version: 2 name: t-shirt size: large price: 15
  116. 116. we’ve just scratch the surface
  117. 117. we’ve just scratch the surface meaning, it’s time to wrap up
  118. 118. ©2015 Couchbase Inc. 118 How do I and my team build our Next Generation BusinessApplications using couchbase’s software suite? Mobilized > Occasionally < Disconnected
  119. 119. ©2015 Couchbase Inc. 119 IRFC – immutable requests for change
  120. 120. ©2015 Couchbase Inc. 120 IRFC – immutable requests for change old school inspired
  121. 121. ©2015 Couchbase Inc. 121 IRFC – immutable requests for change old school inspired design pattern
  122. 122. ©2015 Couchbase Inc. 122 IRFC – immutable requests for change old school inspired design pattern immutable, replicatable, routable document data biz document provisional biz document change response change request
  123. 123. ©2015 Couchbase Inc. 123 IRFC – immutable requests for change old school inspired design pattern immutable, replicatable, routable document data mobilized biz document provisional biz document change response change request
  124. 124. ©2015 Couchbase Inc. 124 IRFC – immutable requests for change old school inspired design pattern immutable, replicatable, routable document data mobilized multi-topology biz document provisional biz document change response change request web app server web browser CB MobileCB Mobile CB MobileCB MobileCB Mobile CB Sync Gateway
  125. 125. ©2015 Couchbase Inc. 125 IRFC – immutable requests for change old school inspired design pattern immutable, replicatable, routable document data mobilized multi-topology for your next-gen business applications biz document provisional biz document change response change request web app server web browser CB MobileCB Mobile CB MobileCB MobileCB Mobile CB Sync Gateway
  126. 126. ©2015 Couchbase Inc. 126 IRFC – immutable requests for change old school inspired design pattern immutable, replicatable, routable document data mobilized multi-topology for your next-gen business applications also has pretty colors biz document provisional biz document change response change request web app server web browser CB MobileCB Mobile CB MobileCB MobileCB Mobile CB Sync Gateway
  127. 127. IMMUTABLE REQUESTS FOR CHANGE #IRFC Questions? THANKS! (and please do the survey)
  128. 128. ©2015 Couchbase Inc. 128
  129. 129. ©2015 Couchbase Inc. 129 extra slides
  130. 130. ©2015 Couchbase Inc. 130 feedback from the crew why this not rev trees? is this implementing on top of rev-trees? instead of rev-trees? is this CB’s blessed approach for modeling (or just one of many patterns/tools) no mutable docs? new feature base rev and incr / CRDT example from dave change request is an atomic document on its own better title more compare & contrast to other patterns
  131. 131. cloud / datacenter CB Mobile CB Mobile CB Mobile CB Mobile CB Mobile CB Mobile topology peer to peer sync and cycles are fine, too CB Mobile (sync-gw) business logic (app svrs)
  132. 132. ©2015 Couchbase Inc. 132 validate.js slow, offline backend integration web app server web browser backend systems 1 2 validate.js mvc.js mvc.js
  133. 133. ©2015 Couchbase Inc. 133 immutability makes everything easier immutable  you can’t change a document  but you can version them  and, if you have concurrent updates  e.g., disconnected mobile users  you can make a new “change-request” documents against existing document & versions  a system of record needs to reconcile change-requests
  134. 134. ©2015 Couchbase Inc. 134 new school architecture ios app cloud / datacenter Couchbase ServerCB Mobile (sync-gw) CB Mobile (sync-gw) CB Mobile CB Mobile android app CB Mobile mobile web app sync funcs sync funcs web browser web app server server-side business logic web UI
  135. 135. CustomerDoc-001, version 12 a master doc and change requests
  136. 136. CustomerDoc-001, version 12 change-request 123 to CustomerDoc-001, version 12 “update address” a master doc and change requests an AP system can build up a stack of immutable change- request docs up against a master doc
  137. 137. CustomerDoc-001, version 12 change-request 123 to CustomerDoc-001, version 12 “update address” change-request 127 to CustomerDoc-001, version 12 “update address some more” a master doc and change requests an AP system can build up a stack of immutable change- request docs up against a master doc
  138. 138. CustomerDoc-001, version 12 change-request 123 to CustomerDoc-001, version 12 “update address” change-request 127 to CustomerDoc-001, version 12 “update address” change-request 133 to CustomerDoc-001, version 12 “update email” a master doc and change requests an AP system can build up a stack of immutable change- request docs up against a master doc
  139. 139. CustomerDoc-001, version 12 change-request 123 to CustomerDoc-001, version 12 “update address” change-request 127 to CustomerDoc-001, version 12 “update address” change-request 133 to CustomerDoc-001, version 12 “update email” a master doc and change requests an AP system can build up a stack of immutable change- request docs up against a master doc customer 001 name: steve yen phone: 650 804-1417 email: steve@cb.com address san francisco the edge AP system can display the master doc in a view merged with any change-requests, and can also indicate whether those changes-requests are still pending
  140. 140. CustomerDoc-001, version 12 change-request 123 to CustomerDoc-001, version 12 “update address” change-request 127 to CustomerDoc-001, version 12 “update address” change-request 133 to CustomerDoc-001, version 12 “update email” a master doc, change requests & change responses
  141. 141. CustomerDoc-001, version 12 change-request 123 to CustomerDoc-001, version 12 “update address” change-request 127 to CustomerDoc-001, version 12 “update address” change-request 133 to CustomerDoc-001, version 12 “update email” change-response 532 to change- request 133 on CustomerDoc-001, version 12 “ok” change-response 532 to change- request 133 on CustomerDoc-001, version 12 “ok” change-response 532 to change- request 133 on CustomerDoc-001, version 12 “accepted” CustomerDoc-001, version 14 a master doc, change requests & change responses
  142. 142. CustomerDoc-001, version 12 change-request 123 to CustomerDoc-001, version 12 “update address” change-request 127 to CustomerDoc-001, version 12 “update address” change-request 133 to CustomerDoc-001, version 12 “update email” change-response 532 to change- request 133 on CustomerDoc-001, version 12 “ok” change-response 532 to change- request 133 on CustomerDoc-001, version 12 “ok” change-response 532 to change- request 133 on CustomerDoc-001, version 12 “accepted” CustomerDoc-001, version 14 customer 001 name: steve yen phone: 650 804-1417 email: steve@cb.com address san francisco a master doc, change requests & change responses
  143. 143. extra slides 143
  144. 144. case: generating unique ID’s example: globally unique ticket ID generation UUID’s(hard for end-users to use (hard to read & type => copy & paste)) provisional #’s (bookmarks & refs might be to unapproved provisional ID’s) steve001-72(local, provisional) vs MB-11411(from the center, final) pre-reserved ranges(numeric gaps; need occasional sync to reserve new ranges) byzantine, adversarial actorsmight generate bad #’s? the center sorts it all out
  145. 145. case: inventory counts current inventory snapshot is 15 and, you sold one ticket via an edge POS device, so... create a change-request “change inventory to 13” (bad - concurrency races) vs “change inventory by -2” (a better model; commutative) vs “create inventory-reservation-request with count 2” (best) should have lots of cross-correlation data & refs for idempotency so that the center can apply the -2 just once
  146. 146. pattern: a change-response might also be master doc a inventory-reservation-request can have a change-response of “accepted” or a result of “success”, where we just create a brand-new inventory-reservation doc
  147. 147. case: aggregates aggregates are everywhere... similar to inventory counts similar to friend counts similar to “like’s” and “+1’s” similar to article/video “views”
  148. 148. case: leaderboards / dashboards a leaderboard or a global aggregate dashboard would be a master doc generated in the center local, edge changes can be reflected in local renderings
  149. 149. case: a new customer field sales meets new customer, begins data entry on her edge device so, it’s an edge document, like… CreateCustomerRequest rendered on device as provisional until the center creates a change-response like a brand new master doc… a Customer doc
  150. 150. multi-master change-requests transfer inventory, resource or money from A to B who’s the master doc? location A or location B? the answer might be “both”
  151. 151. search / queries ? user updates a customer record... but before she syncs back to the center… how do edge searches/queries work? answer: need to query the reduced/merged results where change-req’s shadow the underlying master docs
  152. 152. immutability simplifies a lot idempotency, too
  153. 153. immutability simplifies a lot idempotency, too (it’s also lambda architecture friendly)
  154. 154. but, immutability is expensive lots of mutations means lots of versions change-requests change-responses big storage utilization explosion? especially for fast-changing data
  155. 155. optimization: center documents CP system doesn’t need to track rev-tree’s for center documents; after all, center documents should be 100% consistent (source of truth) similarly, onAP side, there shouldn’t be bushy rev-tree’s for center docs; rev-trees can be aggressively pruned / dropped
  156. 156. optimization: cleaning old change requests & responses change request docs should never enter into a CP database; instead, biz logic should be bridging between AP & CP systems once a change-request doc is handled and has a matching change-response doc, they both can be deleted as long as they’ve been replicated (everyone’s seen the change-response)
  157. 157. optimization: delay immutability until replication you can relax on document immutability, as long as you haven’t replicated yet example: you can merge and collapse multiple change-requests into fewer, smaller docs, until you’re ready to replicate (cblite has controllable replication) see also: CRDT data structures (e.g. inventory counts or friend-like +1’s)
  158. 158. cloud / datacenter Couchbase Server Enterprise CB Mobile CB Mobile CB Mobile CB Mobile CB Mobile CB Mobile topology peer to peer sync and cycles are fine, too the design rules would still work if this was SAP or ORCL or SFORCE CB Mobile (sync-gw) business logic (app svrs) business logic rules bridge the AP & CP systems the design rules would still work if this was coredata or sqlite or meteorjs
  159. 159. ©2015 Couchbase Inc. 159 agenda problem pattern  new users, new employees, new products unique ID generation  blog, comments, stars embed vs refer  many followers 1 to (potentially) massive many append &positive/negative bags  a dashboard / leaderboard aggregate bins  time series data time based bins  inventory transfers atomic, immutable docs  enterprise apps atomic, immutable, mobile docs
  160. 160. ©2015 Couchbase Inc. 160 how I do...? create unique customer ID’s across devices? manage “already seen/read” on news events? integrate with my external credit check & scoring systems? implement friend “likes” and unlikes with double-counting? handle reserving or allocating potentially overbooked inventory? have aggregate reports on top N reps/region/product? transfer game gold or inventory from player A to player B? handle concurrent updates on a customer record? handle loops/cycles of P2P replication? implement a distributed CMS? handle comments on page? have audit trails? too small,etc to read?
  161. 161. Section Break (Blue) Subtitle
  162. 162. Thank you.
  163. 163. ©2015 Couchbase Inc. 163 next generation business apps  mobilized  occasionally disconnected  cross platform devices  multiple topologies (star, peer 2 peer, …)  IoT  scale out  flexible  transactions  reports
  164. 164. ©2015 Couchbase Inc. 164  Architecting next generation, disruptive business applications using document data modeling and design patterns that leverage Couchbase's full product suite
  165. 165. LEVERAGING COUCHBASE PRODUCTS TO BUILD NEXT GENERATION BUSINESS APPS Steve Yen, Couchbase
  166. 166. ©2015 Couchbase Inc. 166 .:/+mmsssssssm+/:.` -/msyyyyyyyyyyyyyyyyyyym/-` .+syyyyyyyyyyyyyyyyyyyyyyyyyys+- -myyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyys: .myyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyys- /syyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy+` `myyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyys` myyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyys` /yyyyyys/..````myyyyyyyyyyyyyyyys.```..:syyyyyym .syyyyyy- /yyyyyyyyyyyyyyyym `yyyyyyy: /yyyyyyy. /yyyyyyyyyyyyyyyym yyyyyyym myyyyyyy. /yyyyyyyyyyyyyyyym yyyyyyyy syyyyyyy. ````` ````` yyyyyyyy myyyyyyy. yyyyyyyy /yyyyyyy. yyyyyyym .yyyyyyy/ :yyyyyyy: +yyyyyyysm+//::::--------------:::://+msyyyyyyys myyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy` `myyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyys. +yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyym` -syyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: :syyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy/`

×