Slide 1

Slide 1 text

Do you really need that relational DB?

Slide 2

Slide 2 text

Do you begin coding from DB structure?

Slide 3

Slide 3 text

Do you begin coding from user's perspective?

Slide 4

Slide 4 text

Why do we constantly select data that doesn't change? https://commons.wikimedia.org/wiki/File:Man-scratching-head.gif

Slide 5

Slide 5 text

Reading same content from same source for each view. Why?

Slide 6

Slide 6 text

It's all in the roots

Slide 7

Slide 7 text

Context: Medium - High traffic

Slide 8

Slide 8 text

Perceived speed is important • Pinterest increased search engine traffic and sign-ups by 15% when they reduced perceived wait times by 40%. • COOK increased conversions by 7%, decreased bounce rates by 7%, and increased pages per session by 10% when they reduced average page load time by 850ms. • Source: https://developers.google.com/web/fundamentals/performance/ why-performance-matters/

Slide 9

Slide 9 text

RDBMS is slow - bbc.com

Slide 10

Slide 10 text

RDBMS is slow - coolblue.nl

Slide 11

Slide 11 text

How to stop relying on RDBMS in User facing apps?

Slide 12

Slide 12 text

The setup

Slide 13

Slide 13 text

Typical news portal

Slide 14

Slide 14 text

Multiple slices of same data

Slide 15

Slide 15 text

Multiple slices of same data

Slide 16

Slide 16 text

Multiple slices of same data

Slide 17

Slide 17 text

Multiple slices of same data

Slide 18

Slide 18 text

Multiple slices of same data

Slide 19

Slide 19 text

But it can be cached?

Slide 20

Slide 20 text

But it can be cached? • Difficult to determine how long

Slide 21

Slide 21 text

But it can be cached? • Difficult to determine how long • Big news - short cache

Slide 22

Slide 22 text

But it can be cached? • Difficult to determine how long • Big news - short cache • Regular news - long cache

Slide 23

Slide 23 text

But it can be cached? • Difficult to determine how long • Big news - short cache • Regular news - long cache • Too small TTL - more hardware needed

Slide 24

Slide 24 text

But it can be cached? • Difficult to determine how long • Big news - short cache • Regular news - long cache • Too small TTL - more hardware needed • Too big TTL - the news are outdated of include mistakes

Slide 25

Slide 25 text

No control over cached data https://commons.wikimedia.org/wiki/File:Emblem-evil-computer.svg

Slide 26

Slide 26 text

Multiple users generating same cache because it expired

Slide 27

Slide 27 text

Caching didn't save my project

Slide 28

Slide 28 text

Static HTML file saved it

Slide 29

Slide 29 text

So what else?

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

Read Model

Slide 33

Slide 33 text

Read model?

Slide 34

Slide 34 text

Read model? • Read model in CQRS

Slide 35

Slide 35 text

Read model? • Read model in CQRS • Aggregate root in DDD

Slide 36

Slide 36 text

Read model? • Read model in CQRS • Aggregate root in DDD • A view in RDBMS

Slide 37

Slide 37 text

A dataset crafted specifically for a single use case on the website

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

You don't need RDBMS for a news portal

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

Create seams

Slide 48

Slide 48 text

Projector?

Slide 49

Slide 49 text

Projector? • Comes from Event Sourcing

Slide 50

Slide 50 text

Projector? • Comes from Event Sourcing • Responsible to project an event stream to any structural representation

Slide 51

Slide 51 text

The Projector

Slide 52

Slide 52 text

The Projector

Slide 53

Slide 53 text

Projected Read Model

Slide 54

Slide 54 text

No need for Event Sourcing

Slide 55

Slide 55 text

Unlimited possibilities

Slide 56

Slide 56 text

Unlimited possibilities • Convert straight to HTML

Slide 57

Slide 57 text

Unlimited possibilities • Convert straight to HTML • Add a queue for big amounts of data

Slide 58

Slide 58 text

Unlimited possibilities • Convert straight to HTML • Add a queue for big amounts of data • Hook up external services for integrations

Slide 59

Slide 59 text

Unlimited possibilities • Convert straight to HTML • Add a queue for big amounts of data • Hook up external services for integrations • Project as many different formats as you want

Slide 60

Slide 60 text

But...

Slide 61

Slide 61 text

But... • Costly mistakes - a need to regenerate everything

Slide 62

Slide 62 text

But... • Costly mistakes - a need to regenerate everything • A lot more moving parts, more complexity

Slide 63

Slide 63 text

But... • Costly mistakes - a need to regenerate everything • A lot more moving parts, more complexity • Sounds a bit "backwards" and unusual

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

No content

Slide 66

Slide 66 text

No content

Slide 67

Slide 67 text

No content

Slide 68

Slide 68 text

No content

Slide 69

Slide 69 text

No content

Slide 70

Slide 70 text

No content

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

How about a harder example?

Slide 73

Slide 73 text

No content

Slide 74

Slide 74 text

No content

Slide 75

Slide 75 text

Optimisation for back office

Slide 76

Slide 76 text

Optimisation for back office • Analysts will want every possible slice of your data

Slide 77

Slide 77 text

Optimisation for back office • Analysts will want every possible slice of your data • Very different queries from what you use on production

Slide 78

Slide 78 text

Optimisation for back office • Analysts will want every possible slice of your data • Very different queries from what you use on production • Difficult to find correct indexes to satisfy both worlds

Slide 79

Slide 79 text

Cache

Slide 80

Slide 80 text

Cache • Product?

Slide 81

Slide 81 text

Cache • Product? • Lists?

Slide 82

Slide 82 text

Cache • Product? • Lists? • Both?

Slide 83

Slide 83 text

Cache • Product? • Lists? • Both? • Parts of the product?

Slide 84

Slide 84 text

Cache • Product? • Lists? • Both? • Parts of the product? • Price?

Slide 85

Slide 85 text

Cache • Product? • Lists? • Both? • Parts of the product? • Price? • Users regenerating it on random TTL?

Slide 86

Slide 86 text

You don't need RDBMS to display a product page

Slide 87

Slide 87 text

Multiple Read Models for similar data Storage is Cheap!

Slide 88

Slide 88 text

Be careful of inconsistencies

Slide 89

Slide 89 text

No content

Slide 90

Slide 90 text

No content

Slide 91

Slide 91 text

Dealing with lots of data

Slide 92

Slide 92 text

NoSQL streams to the help

Slide 93

Slide 93 text

NoSQL streams to the help • Store final result into NoSQL

Slide 94

Slide 94 text

NoSQL streams to the help • Store final result into NoSQL • Streams trigger the projections

Slide 95

Slide 95 text

NoSQL streams to the help • Store final result into NoSQL • Streams trigger the projections • AWS DynamoDB

Slide 96

Slide 96 text

NoSQL streams to the help • Store final result into NoSQL • Streams trigger the projections • AWS DynamoDB • MongoDB Change Streams

Slide 97

Slide 97 text

NoSQL streams to the help • Store final result into NoSQL • Streams trigger the projections • AWS DynamoDB • MongoDB Change Streams • Something else?

Slide 98

Slide 98 text

Queues to the help • AWS SQS • RabbitMQ • Kafka

Slide 99

Slide 99 text

No injection points?

Slide 100

Slide 100 text

No injection points? • RDBMS triggers?

Slide 101

Slide 101 text

No injection points? • RDBMS triggers? • Simple microservice that just polls DB

Slide 102

Slide 102 text

No injection points? • RDBMS triggers? • Simple microservice that just polls DB • Slave replication

Slide 103

Slide 103 text

No injection points? • RDBMS triggers? • Simple microservice that just polls DB • Slave replication • Webhook

Slide 104

Slide 104 text

No injection points? • RDBMS triggers? • Simple microservice that just polls DB • Slave replication • Webhook • Anything that can trigger your projector

Slide 105

Slide 105 text

No content

Slide 106

Slide 106 text

No content

Slide 107

Slide 107 text

No content

Slide 108

Slide 108 text

No content

Slide 109

Slide 109 text

No content

Slide 110

Slide 110 text

No content

Slide 111

Slide 111 text

Always start from the use case

Slide 112

Slide 112 text

Read Model + Projector = No Cache

Slide 113

Slide 113 text

Read Model + Projector = No Cache No Cache = Easier & Longer life

Slide 114

Slide 114 text

You don't need a relational database*

Slide 115

Slide 115 text

You don't need a relational database* * for user facing content

Slide 116

Slide 116 text

Questions? Did you like the talk? 
 Was it crap? I wanna know, please share your feedback! https://joind.in/talk/d687d