Slide 1

Slide 1 text

Event Sourcing In Node.js Tamar Twena-Stern

Slide 2

Slide 2 text

Tamar Twena-Stern • Software Engineer - manager and architect • Architect @PaloAltoNetworks • Was a CTO of my own startup • Passionate about Node.js ! • Twitter: @SternTwena

Slide 3

Slide 3 text

Tamar Tena-Stern • On Maternity Leave • Have 3 kids • Loves to play my violin

Slide 4

Slide 4 text

Let’s Write Twitter !

Slide 5

Slide 5 text

Building Newsfeed

Slide 6

Slide 6 text

And We Get

Slide 7

Slide 7 text

How Will That Work ?

Slide 8

Slide 8 text

Why Does This Happen?

Slide 9

Slide 9 text

Can I Add One More Index? username firstName lastName @johnsmith John Smith @tamarstern Tamar Stern @urishaked Uri Shaked Eventually, it breaks …

Slide 10

Slide 10 text

Lets Introduce You To Our Frustrated System Administrator

Slide 11

Slide 11 text

Event Sourcing

Slide 12

Slide 12 text

Event Sourcing

Slide 13

Slide 13 text

Demo - Node.js Event Sourcing Server

Slide 14

Slide 14 text

Advantages • Each View has its own storage which is the most optimised for its specific queries • Can scale up to 10^8 of concurrent users • Schema migration is much simpler, Schema is much more flexible • System recovery is easier

Slide 15

Slide 15 text

Event Log

Slide 16

Slide 16 text

Where To Store Events ? • Event Store Database • Hadoop Cluster • node-webhdfs • Couchbase eventing service • npm couchbase • Implement in serverless architecture

Slide 17

Slide 17 text

NPM Libraries • eventstore - Node.js event log pattern implementation • nest-cqrs

Slide 18

Slide 18 text

Batch Consumer

Slide 19

Slide 19 text

Evolution Of Architecture (So Far) The State Of The Entities In DB Actions in immutable log Consumers prepare results in batch

Slide 20

Slide 20 text

What Is Happening In The Real World ?

Slide 21

Slide 21 text

Stream Processing

Slide 22

Slide 22 text

Stream Processing • Apache Kafka • Kafka-node • Amazon Kinesis

Slide 23

Slide 23 text

Implementing Transactions With Event Sourcing • Databases have event log to implement transactions • I built a transaction engine for banking system in node.js using event sourcing • Each transaction was saved in an event log • Validation was done versus the event log to make sure the banking activity can be performed.

Slide 24

Slide 24 text

• Twitter: @SternTwena