presenters
play

Presenters Phillipa Avery Robert Reta Senior Software Engineer - PowerPoint PPT Presentation

Presenters Phillipa Avery Robert Reta Senior Software Engineer Senior Software Engineer Project Technical Lead and Engineer Event Sourcing System Architect Downloads License Accounting Downloads License Accounting pavery@Netflix.com /


  1. Presenters Phillipa Avery Robert Reta Senior Software Engineer Senior Software Engineer Project Technical Lead and Engineer Event Sourcing System Architect Downloads License Accounting Downloads License Accounting pavery@Netflix.com / @PhillipaAvery rreta@netflix.com / @rreta04

  2. Phillipa Robert

  3. Overview 1. Why do we need a Downloads License Accounting Service? 2. Event Sourcing overview. 3. Deep dive into the Event Sourcing Architecture. 4. What’s it like working with the License Accounting Service after release?

  4. Streaming Playback Lifecycle CREATE PLAYBACK CONTEXT LICENSE SESSION EVENTS (START, PAUSE, RESUME, KEEPALIVE)

  5. Streaming Playback Lifecycle RELEASE STOP LICENSE SESSION EVENT (STOP)

  6. Downloads Playback Lifecycle CREATE PLAYBACK CONTEXT LICENSE DOWNLOADED ENCODED MOVIE

  7. Downloads Playback Lifecycle SESSION EVENTS (START, PAUSE, RESUME, KEEPALIVE, STOP) RELEASE LICENSE RENEW LICENSE? X ~ 1 year

  8. Download Business Requirements ● Devices with downloads

  9. Download Business Requirements ● Devices with downloads ● Downloads per studio

  10. Download Business Requirements ● Devices with downloads ● Downloads per studio ● Movie downloads or playback over year ~ 1 year

  11. License Accounting Service Requirements ❏ Flexible y t i l i b F ❏ Debuggable a i l l e e R x i b i l ❏ Reliable i t y S ❏ Scalable c a l a b Debuggability i l i t y

  12. License Accounting Service Requirements... ✓ Flexible: data model can be changed ❏ RDBMS ❏ Document Model

  13. License Accounting Service Requirements... ✓ Flexible: data model can be changed ❏ RDBMS ❏ Document Model ✓ Debuggable ❏ Event Sourcing

  14. License Accounting Service Requirements... ✓ Flexible: data model can be changed ❏ RDBMS ❏ Document Model ✓ Debuggable ❏ Event Sourcing ✓ Reliable ❏ Fallbacks

  15. License Accounting Service Requirements... ✓ Flexible: data model can be changed ❏ RDBMS ❏ Document Model ✓ Debuggable ❏ Event Sourcing ✓ Reliable ❏ Fallbacks ✓ Scalable

  16. Event Sourcing

  17. Domain Model

  18. Commands Make Purple Command

  19. Commands Command Handler Make Purple Command

  20. Commands Added Red Event Added Blue Command Event Handler Make Purple Command

  21. Events Event Handler Added Red Event Added Blue Event

  22. Events Event Handler Added Blue Event

  23. Domain Model

  24. Aggregate

  25. Commands Command Handler Make Red Command

  26. Commands Command Handler Make Red Command

  27. Aggregate Aggregate REST Service Repository Query Query Query Event Store Endpoint

  28. Event Store Row ID Events

  29. Event Store Row ID Events

  30. Event Store Events Row ID e 2 e 3 e 4 e 5 e 6 e 7 e 1 Aggregate id 1 Aggregate id 2

  31. Aggregate Event Store Query Repository

  32. Aggregate Event Store Query Repository select * from events where rowId =

  33. e 2 e 3 e 4 e 5 e 6 e 7 e 1 Aggregate Event Store Repository Response

  34. Aggregate Repository e 2 e 3 e 4 e 5 e 6 e 7 e 1 Aggregate id 1 Aggregate id 2 e 2 e 5 e 6 e 3 e 4 e 7 e 1

  35. Aggregate Repository Aggregate id 1 e 2 e 5 e 6 e 1 Aggregate 1 Aggregate id 2 Aggregate 2 e 3 e 4 e 7

  36. Aggregate Repository Aggregate id 1 e 2 e 5 e 6 Aggregate 1 e 1 Aggregate id 2 Aggregate 2 e 3 e 4 e 7

  37. Aggregate Repository Aggregate id 1 e 5 e 6 Aggregate 1 e 2 Aggregate id 2 Aggregate 2 e 3 e 7

  38. Aggregate Repository Aggregate id 1 e 6 Aggregate 1 e 5 Aggregate id 2 Aggregate 2 e 7

  39. Aggregate Repository Aggregate id 1 Aggregate 1 e 6 Aggregate id 2 Aggregate 2

  40. Aggregate Repository Aggregate 1 Aggregate 2

  41. Aggregate Repository Aggregate 1 Command Handler Command

  42. Aggregate Repository Command e 8 e 9 Handler

  43. Aggregate Repository Aggregate 1 e 8 e 9

  44. Aggregate Repository Aggregate 1 e 8 e 9

  45. Aggregate Repository Aggregate 1 e 9

  46. Aggregate Repository Aggregate 1

  47. Aggregate Update Event Store Repository append events e 8 e 9 where rowId =

  48. Event Store Events Row ID e 2 e 3 e 4 e 5 e 6 e 7 e 8 e 9 e 1 Aggregate id 1 Aggregate id 2

  49. Get all aggregates for a customer Aggregate Aggregate Service Repository Query

  50. Aggregate 1 Aggregate 2 Aggregate Aggregate Service Repository Response

  51. Aggregate License Downloaded Aggregate Aggregate

  52. customerId: Bayley titleId: GlowS01E01 Acquire License License Query Service Endpoint

  53. isAllowed? customerId: Bayley titleId: GlowS01E01 License Downloaded Service Service Query

  54. getAggregates Downloaded Downloaded customerId: Bayley Service Repository titleId: GlowS01E01 since: 6/27/2016 Query

  55. Downloaded Downloaded Aggregate Aggregate customerId: Bayley customerId: Bayley titleId: GlowS01E01 titleId: GlowS01E01 date: 2/15/2017 date: 5/25/2017 Downloaded Downloaded Repository Service Response

  56. Downloaded Service isAllowed? License Service Response aggregates.size() < yearly limit

  57. Downloaded Service isAllowed? License True Service Response aggregates.size() < yearly limit (2) < (3)

  58. Create Aggregate License Aggregate customerId: titleId: expires: released: License License Service Repository Create License Command customerId: Bayley titleId: GlowS01E01 date: 6/27/2017 Update

  59. License Repository License Aggregate customerId: titleId: expires: released: Command Handler Create License Command customerId: Bayley titleId: GlowS01E01 date: 6/27/2017

  60. License Repository License Aggregate customerId: titleId: expires: License Created released: Event Command customerId: Bayley Handler Create License titleId: GlowS01E01 Command date: 6/27/2017 customerId: Bayley titleId: GlowS01E01 date: 6/27/2017

  61. License Repository License Aggregate customerId: titleId: expires: License Aggregate released: Event customerId: Bayley Handler License Created titleId: GlowS01E01 Event expires: 7/27/2017 released: false customerId: Bayley titleId: GlowS01E01 date: 6/27/2017

  62. License Created Event customerId: Bayley titleId: GlowS01E01 date: 6/27/2017 License Save Repository Event Store

  63. Create Aggregate Acquire License License Response License Created Service Repository Endpoint

  64. isAllowed? License License Service Repository aggregates.filter(GlowS01E01) Get all licenses .size() < yearly limit Response

  65. Table Partition Keys Clustering Columns Columns

  66. Event Table rowId Aggregate Id Event Time Event Data Event Mapper text text timestamp blob String

  67. ● A fast and efficient object graph serialization framework for Java ○ https://github.com/EsotericSoftware/kryo ● Able to preconfigure the library to your data models for extra compaction ● Custom serializers

  68. rowId AggregateId Event Time Event Data text text timestamp blob House of Cards 0 LicenseCreated Matt:LicenseAggregate Buddy 1 LicenseCreated Thunderstruck The Hardy Boys 2 LicenseCreated Jeff:LicenseAggregate

  69. rowId AggregateId Event Time Event Data text text timestamp blob House of Cards 0 LicenseCreated Matt:LicenseAggregate House of Cards 3 LicenseReleased Buddy 1 LicenseCreated Thunderstruck The Hardy Boys 2 LicenseCreated Jeff:LicenseAggregate

  70. rowId AggregateId Event Time Event Data text text timestamp blob House of Cards 0 LicenseCreated Matt:LicenseAggregate House of Cards 3 LicenseReleased Buddy 1 LicenseCreated Thunderstruck The Hardy Boys 2 LicenseCreated Jeff:LicenseAggregate

  71. rowId AggregateId Event Time Event Data text text timestamp blob House of Cards 0 LicenseCreated Matt:LicenseAggregate House of Cards 3 LicenseReleased Buddy 1 LicenseCreated Thunderstruck The Hardy Boys 2 LicenseCreated Jeff:LicenseAggregate

  72. Snapshotting Matt:LicenseAggregate House of Cards 0 LicenseCreated House of Cards 3 LicenseReleased Buddy Thunderstruck 1 LicenseCreated Master of None 0 LicenseCreated Master of None 3 LicenseReleased Bojack 1 LicenseCreated Lucha Underground 0 LicenseCreated Lucha Underground 3 LicenseReleased Grace & Frankie 1 LicenseCreated House of Cards 0 LicenseCreated

  73. Snapshot Table rowId version Snapshot Data text int blob

  74. rowId Version Event Data text int blob 1 binaryData Matt:LicenseAggregate

  75. rowId AggregateId Event Time Event Data text text timestamp blob House of Cards 0 LicenseCreated Matt:LicenseAggregate:0 Jessica Jones 1 LicenseCreated House of Cards 3 Matt:LicenseAggregate:1 LicenseReleased The Hardy Boys 2 LicenseCreated Jeff:LicenseAggregate:0

  76. Working With Event Sourcing

  77. Flexibility in Practice ● Changes to the Data Model are trivial! ○ Device deactivation

  78. New Device Deactivation Requirement Device Deactivate Device Device Aggregate Device Service Repository Endpoint Device Deactivated Event Deactivate Device Command

Recommend


More recommend