presenters - qcon new york · presenters phillipa avery senior software engineer project technical...

96

Upload: others

Post on 25-May-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery
Page 2: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Presenters

Phillipa AverySenior Software Engineer

Project Technical Lead and EngineerDownloads License Accounting

[email protected] / @PhillipaAvery

Robert RetaSenior Software Engineer

Event Sourcing System ArchitectDownloads License Accounting

[email protected] / @rreta04

Page 3: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Phillipa

Robert

Page 4: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

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?

Page 5: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

LICENSE

CREATE PLAYBACK CONTEXT

SESSION EVENTS(START, PAUSE,

RESUME, KEEPALIVE)

Streaming Playback Lifecycle

Page 6: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

RELEASELICENSE

SESSION EVENT(STOP)

STOP

Streaming Playback Lifecycle

Page 7: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

LICENSE

CREATE PLAYBACK CONTEXT

DOWNLOADED ENCODED MOVIE

Downloads Playback Lifecycle

Page 8: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

~ 1 year

SESSION EVENTS(START, PAUSE, RESUME,

KEEPALIVE, STOP)

RENEWLICENSE?

X

RELEASELICENSE

Downloads Playback Lifecycle

Page 9: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Download Business Requirements

● Devices with downloads

Page 10: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Download Business Requirements

● Devices with downloads● Downloads per studio

Page 11: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Download Business Requirements

● Devices with downloads● Downloads per studio● Movie downloads or playback over year

~ 1 year

Page 12: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

License Accounting Service Requirements

❏ Flexible

❏ Debuggable

❏ Reliable

❏ Scalable

Flexibility

Debuggability

Scalability

Reliability

Page 13: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

License Accounting Service Requirements...

✓ Flexible: data model can be changed❏ RDBMS❏ Document Model

Page 14: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

License Accounting Service Requirements...

✓ Flexible: data model can be changed❏ RDBMS❏ Document Model

✓ Debuggable❏ Event Sourcing

Page 15: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

License Accounting Service Requirements...

✓ Flexible: data model can be changed❏ RDBMS❏ Document Model

✓ Debuggable❏ Event Sourcing

✓ Reliable❏ Fallbacks

Page 16: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

License Accounting Service Requirements...

✓ Flexible: data model can be changed❏ RDBMS❏ Document Model

✓ Debuggable❏ Event Sourcing

✓ Reliable❏ Fallbacks

✓ Scalable

Page 17: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Event Sourcing

Page 18: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Domain Model

Page 19: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Make Purple

Command

Commands

Page 20: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Commands

Make Purple

Command

Command Handler

Page 21: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Added Red Event

Added Blue Event

Make Purple

Command

Command Handler

Commands

Page 22: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Events

Added Red Event

Added Blue Event

Event Handler

Page 23: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Events

Added Blue Event

Event Handler

Page 24: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Domain Model

Page 25: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Aggregate

Page 26: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Commands

Make Red Command

Command Handler

Page 27: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Command Handler

Commands

Make Red Command

Page 28: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Aggregate ServiceREST

Endpoint

Aggregate Repository

Event StoreQuery Query Query

Page 29: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Event Store

Row ID Events

Page 30: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Event Store

Row ID Events

Page 31: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Row ID Events

e1 e2 e3 e5 e6 e7e4

Event Store

Aggregate id 1 Aggregate id 2

Page 32: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Aggregate Repository

Query Event Store

Page 33: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Aggregate Repository

Event StoreQuery

select * from eventswhere rowId =

Page 34: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Aggregate Repository Event StoreResponse

e1 e2 e3 e5 e6 e7e4

Page 35: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Aggregate Repository

e1 e2 e3 e5 e6 e7e4

Aggregate id 1 Aggregate id 2

e1 e2 e5 e6 e3 e4 e7

Page 36: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Aggregate Repository

Aggregate id 2

Aggregate id 1

e1 e2 e5 e6

e3 e4 e7

Aggregate 1

Aggregate 2

Page 37: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Aggregate Repository

Aggregate 2

Aggregate 1

Aggregate id 2

Aggregate id 1

e1e2 e5 e6

e3 e4 e7

Page 38: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Aggregate Repository

Aggregate 2

Aggregate 1

Aggregate id 2

Aggregate id 1

e2e5 e6

e3 e7

Page 39: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Aggregate Repository

Aggregate 2

Aggregate 1

Aggregate id 2

Aggregate id 1

e5e6

e7

Page 40: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Aggregate Repository

Aggregate 2

Aggregate 1

Aggregate id 2

Aggregate id 1

e6

Page 41: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Aggregate Repository

Aggregate 2

Aggregate 1

Page 42: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Aggregate Repository

Command

Aggregate 1

Command Handler

Page 43: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Aggregate Repository

Command Handler

e8 e9

Page 44: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Aggregate Repository

e8 e9Aggregate 1

Page 45: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Aggregate Repository

Aggregate 1e8 e9

Page 46: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Aggregate Repository

Aggregate 1e9

Page 47: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Aggregate Repository

Aggregate 1

Page 48: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Aggregate Repository Event StoreUpdate

append events

where rowId =

e8 e9

Page 49: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Event Store

Aggregate id 1 Aggregate id 2

Row ID Events

e1 e2 e3 e5 e6 e7e4 e8 e9

Page 50: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Aggregate RepositoryQuery

Aggregate Service

Get all aggregates for a customer

Page 51: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Aggregate Repository

Aggregate Service Response

Aggregate 2Aggregate 1

Page 52: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Aggregate

DownloadedAggregate

License Aggregate

Page 53: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

License Service

Acquire License

EndpointQuery

customerId: BayleytitleId: GlowS01E01

Page 54: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

License Service

Query

customerId: BayleytitleId: GlowS01E01

Downloaded Service

isAllowed?

Page 55: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Query

customerId: BayleytitleId: GlowS01E01since: 6/27/2016

Downloaded Service

Downloaded Repository

getAggregates

Page 56: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Downloaded Service

Downloaded Repository

Response

DownloadedAggregate

customerId: BayleytitleId: GlowS01E01date: 2/15/2017

DownloadedAggregate

customerId: BayleytitleId: GlowS01E01date: 5/25/2017

Page 57: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

License Service

Downloaded Service

Response

isAllowed?

aggregates.size() < yearly limit

Page 58: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

License Service

Downloaded Service

Response

isAllowed?

Trueaggregates.size() < yearly limit

(2) < (3)

Page 59: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

License Service

Update

License Repository

Create Aggregate

Create License Command

customerId: BayleytitleId: GlowS01E01date: 6/27/2017

License Aggregate

customerId:titleId:expires:released:

Page 60: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

License Repository

Command HandlerCreate License

CommandcustomerId: BayleytitleId: GlowS01E01date: 6/27/2017

License Aggregate

customerId:titleId:expires:released:

Page 61: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

License Repository

Command HandlerCreate License

CommandcustomerId: BayleytitleId: GlowS01E01date: 6/27/2017

License Aggregate

customerId:titleId:expires:released: License Created

Event

customerId: BayleytitleId: GlowS01E01date: 6/27/2017

Page 62: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

License Repository

Event Handler

License Aggregate

customerId:titleId:expires:released:

License Created Event

customerId: BayleytitleId: GlowS01E01date: 6/27/2017

License Aggregate

customerId: BayleytitleId: GlowS01E01expires: 7/27/2017released: false

Page 63: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

License Repository Event StoreSave

License Created Event

customerId: BayleytitleId: GlowS01E01date: 6/27/2017

Page 64: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

License Service

License Repository

Create Aggregate

CreatedAcquire License

EndpointResponse

Page 65: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

License Service License Repository

Response

isAllowed?

aggregates.filter(GlowS01E01) .size()

< yearly limit

Get all licenses

Page 66: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Table

Partition Keys Clustering Columns Columns

Page 67: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Event Table

rowIdtext

Event Timetimestamp

Event Datablob

Aggregate Idtext

Event MapperString

Page 68: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

● 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

Page 69: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

AggregateIdtext

Event Datablob

rowIdtext

Event Timetimestamp

House of Cards LicenseCreatedMatt:LicenseAggregate 0

Buddy Thunderstruck LicenseCreated1

The Hardy Boys LicenseCreatedJeff:LicenseAggregate 2

Page 70: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

AggregateIdtext

Event Datablob

rowIdtext

Event Timetimestamp

House of Cards LicenseCreatedMatt:LicenseAggregate 0

House of Cards LicenseReleased3

Buddy Thunderstruck LicenseCreated1

The Hardy Boys LicenseCreatedJeff:LicenseAggregate 2

Page 71: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

AggregateIdtext

Event Datablob

rowIdtext

Event Timetimestamp

House of Cards LicenseCreatedMatt:LicenseAggregate 0

House of Cards LicenseReleased3

Buddy Thunderstruck LicenseCreated1

The Hardy Boys LicenseCreatedJeff:LicenseAggregate 2

Page 72: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

AggregateIdtext

Event Datablob

rowIdtext

Event Timetimestamp

House of Cards LicenseCreatedMatt:LicenseAggregate 0

House of Cards LicenseReleased3

Buddy Thunderstruck LicenseCreated1

The Hardy Boys LicenseCreatedJeff:LicenseAggregate 2

Page 73: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Snapshotting

House of Cards LicenseCreatedMatt:LicenseAggregate 0

House of Cards LicenseReleased3

Buddy Thunderstruck LicenseCreated1

Master of None LicenseCreated0

Master of None LicenseReleased3

Bojack LicenseCreated1

Lucha Underground LicenseCreated0

Lucha Underground LicenseReleased3

Grace & Frankie LicenseCreated1

House of Cards LicenseCreated0

Page 74: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Snapshot Table

rowIdtext

versionint

Snapshot Datablob

Page 75: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Versionint

Event Datablob

rowIdtext

1 binaryDataMatt:LicenseAggregate

Page 76: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

AggregateIdtext

Event Datablob

rowIdtext

Event Timetimestamp

House of Cards LicenseCreatedMatt:LicenseAggregate:0 0

House of Cards LicenseReleasedMatt:LicenseAggregate:1 3

Jessica Jones LicenseCreated1

The Hardy Boys LicenseCreatedJeff:LicenseAggregate:0 2

Page 77: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Working With Event Sourcing

Page 78: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Flexibility in Practice

● Changes to the Data Model are trivial!○ Device deactivation

Page 79: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

New Device Deactivation Requirement

Deactivate Device

EndpointDevice Service

Device Repository

Device Aggregate

Device Deactivated

EventDeactivate

Device Command

Page 80: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

New Device Deactivation Requirement...

Deactivate Device

Endpoint

Device ServiceDeactivate Device

Can Deactivate?

DeviceRepository

Response

DeviceAggregate

CustomerId: BayleyDeviceId: iPhoneDeactivations: 1

Page 81: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

New Device Deactivation Requirement...

Deactivate Device

Endpoint

Device ServiceDeactivate Device

Can Deactivate

License ServiceRelease Licenses

Page 82: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Device Repository

Command Handler

Deactivate Device CommandcustomerId: BayleydeviceId: iPhone

Device Deactivated Event

customerId: BayleydeviceId: iPhone

DeviceAggregate

CustomerId: BayleyDeviceId: iPhoneDeactivations: 1

New Device Deactivation Requirement...

Page 83: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Debugging

● Possibly the biggest win

● Current tooling is rudimentary

{ "Event" : "LicenseAcquiredEvent", "Event Time" : "2017-06-25 05:23:00 PM", "aggregateId" : "aggregateId1", "committed" : true, "eventTimeStamp" : 1498411380903, "eventOrderNumber" : 0}

Page 84: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Debugging...

Acquire License Event

customerId: BayleydeviceId: iPhonedate: 01/05/2017

Release License Event

customerId: BayleydeviceId: iPhonedate: 01/05/2017

Renew License Event

customerId: BayleydeviceId: iPhonedate: 01/06/2017

License Aggregate

customerId:Bayleyexpires: 01/07/2017released: True

Page 85: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Reliability: Fallbacks

Edge API Layer

License Accounting Service Client

License Accounting

Service CassandraFallback Response

Page 86: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

How Did it Scale?

Predictive Scaling

Page 87: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Scalability with Cassandra SSD (I2) Nodes

Page 88: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Scalability with Cassandra SSD Nodes...

● Could handle much higher loads● Storage use ramping up very quickly

Page 89: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Storage Optimizations

● TTLs● HDD (D2) clusters:

○ More storage○ Higher latency (up to 1 second)

Page 90: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Storage Optimizations...

● Partitioned approach○ Snapshot and subsequent events saved to i2 (SSD) cluster○ Archive events to D2 (HDD) cluster

Snapshot DataVersion 3

Event DataVersion 3

Event DataVersion <= 2

i2

D2

Page 91: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Storage Optimizations...Partitioned approach using CQRS (Command Query Responsibility Segregation)

● Write segregation○ Event handlers that determine partitioned usage

● Query segregation○ Query SSD or HDD (or both)○ Uninterrupted event stream

Event Data

i2

D2

Snapshot + Events

Event Handler

Page 92: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Key Event Sourcing Take-Aways

● Flexible: Adapting to change can be simple

Page 93: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Key Event Sourcing Take-Aways

● Flexible: Adapting to change can be simple

● Debugging: Debugging data / state transitions greatly simplified

Page 94: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Key Event Sourcing Take-Aways

● Flexible: Adapting to change can be simple

● Debugging: Debugging data / state transitions greatly simplified

● Reliable: Fallbacks provide service reliability

Page 95: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Key Event Sourcing Take-Aways

● Flexible: Adapting to change can be simple

● Debugging: Debugging data / state transitions greatly simplified

● Reliable: Fallbacks provide service reliability

● Scalable: Service scaled well, but good architectural solutions for data storage solutions should be considered.

Page 96: Presenters - QCon New York · Presenters Phillipa Avery Senior Software Engineer Project Technical Lead and Engineer Downloads License Accounting pavery@Netflix.com / @PhillipaAvery

Questions?

Phillipa AverySenior Software Engineer

Project Technical Lead and EngineerDownloads License Accounting

[email protected] / @PhillipaAvery

Robert RetaSenior Software Engineer

Event Sourcing System ArchitectDownloads License Accounting

[email protected] / @rreta04