Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... ·...

45
Aurelijus Banelis Not drowning in the stream of events

Transcript of Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... ·...

Page 1: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Aurelijus Banelis

Not drowningin the stream

of events

Page 2: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Aurelijus Banelis

[email protected] developer

Page 3: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Not drowningin the stream

of events

Page 4: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Not

dr

owni

ng

in th

e st

ream

of

even

ts

Page 5: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Not

dr

owni

ng

in th

e st

ream

of

even

ts

Nee

dsC

halle

nges

Tool

s

WHAT

HOW

WHY Business needs

For developers

Tools & practices

Page 6: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

in th

e st

ream

of

even

ts

Nee

dsC

halle

nges

Tool

s

WHY Business needs

Page 7: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Nee

dsC

halle

nges

Tool

s

Web pagevs

Web systemIn old days: to be in the Internet meant: Have contacts page about physical shop, company or organization

Page 8: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Nee

dsC

halle

nges

Tool

s

Web pagevs

Web systemToday, being in the Internet means: whole company is based on digital solutions. For example online retailer without physical shops

Page 9: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Nee

dsC

halle

nges

Tool

s

Being genius(example of recommendations)

Modal window with close button: Closing modal, not browser window. So user can still be interested in related products/information. Similar example is using links to particular tweets.

Page 10: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Nee

dsC

halle

nges

Tool

s

Data driven company

To be genius every day, shifting from profit/customer driven companies to data driven. So solutions could be chosen based on historical/predicted data, not based on Rule of Thumb

Page 11: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Nee

dsC

halle

nges

Tool

s

Historical datafor developers are

Event streams

Between developers term “Event stream” is more common, than “Historical data”. It is not about WordWar 2 in the books, it is about time series and changes of values

Page 12: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Nee

dsC

halle

nges

Tool

s

Data driven technologies usually end up in 3 major groups

Page 13: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Nee

dsC

halle

nges

Tool

s

Tracking What users were doing

Logs What system was doing

History User interface:Yes/No→Undo

For product managers: where user struggles. For developers: which part works better/worse. For users when saving document: Ask to save/discard versus Allowing to restore old version

Page 14: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Nee

dsC

halle

nges

Tool

s

WHYBeing genius

by usingdata driven solutions

in company likeWeb systems

Business needs

stre

am o

f eve

nts

To summarize Business needs part: Implementation of data driven solutions is actually streams of events

Page 15: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Not

dr

owni

ng

in th

e st

ream

of

even

ts

Nee

dsC

halle

nges

Tool

s

WHAT

HOW

WHY Business needs

For developers

Tools & practicesTalked about “event streams” from business perspective. Let’s go deeper into technical parts: why we can drown in the stream of events.

Page 16: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

drow

ning

in

the

stre

am o

f ev

ents

Nee

dsC

halle

nges

Tool

s

WHAT For developers

Page 17: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Nee

dsC

halle

nges

Tool

s

Current state(E.g. basket size=5)

538

029

Page 18: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Nee

dsC

halle

nges

Tool

s

Event stream(E.g. basket size = +2 +6 -4 +1)

538

029

+1-4+6+2-2+5

+1+1+4+1+1

-1-1-1+1-1+1+2

+9

+2 +1 +3

-3

+1

Page 19: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Nee

dsC

halle

nges

Tool

s

More traffic(TV advertisement, hacker)

Page 20: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Nee

dsC

halle

nges

Tool

s

RAM

Storage

Network

Page 21: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Nee

dsC

halle

nges

Tool

s

RAM

Storage

Network

Page 22: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Nee

dsC

halle

nges

Tool

s

RAM

Storage

Network

Page 23: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Nee

dsC

halle

nges

Tool

s

RAM

Storage

Network

Page 24: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Nee

dsC

halle

nges

Tool

s

RAM

Storage

Network

Page 25: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

drow

ning

in

the

stre

am o

f ev

ents

Nee

dsC

halle

nges

Tool

s

WHAT

WHY Business needs

For developers

Growing amount of eventsgenerates undesired load formemory, storage and network

Page 26: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Not

dr

owni

ng

in th

e st

ream

of

even

ts

Nee

dsC

halle

nges

Tool

s

WHAT

HOW

WHY Business needs

For developers

Tools & practices

Page 27: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Not

dr

owni

ng

in th

e st

ream

of

even

ts

Nee

dsC

halle

nges

Tool

s HOW Tools & practices

Page 28: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Nee

dsC

halle

nges

Tool

s

Commonsolutions

Page 29: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Nee

dsC

halle

nges

Tool

s

Limit Active connectionsConnection / second

Remove Log rotationTTL / record

Page 30: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Nee

dsC

halle

nges

Tool

s

Limit Active connectionsConnection / second

mpm_prefork_moduleApache

ngx_http_limit_conn_moduleNgnix

Page 31: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Nee

dsC

halle

nges

Tool

s Remove Log rotationTTL / record

Logrotate*Linux

ElasticSearch, Mongodb, CassandraDatabases

* - usually people forgot, that logrotate can be configured to act by size, not only by time limit

Page 32: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Nee

dsC

halle

nges

Tool

s

Limit Active connectionsConnection / second

Remove Log rotationTTL / record

Does not adapt(need to define before)

Page 33: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Nee

dsC

halle

nges

Tool

s

Limit Back pressure

Remove Capacity constraint

Auto adaptive(but more exotic solutions)

Page 34: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Nee

dsC

halle

nges

Tool

s

Back pressure(flood only when agreed)

Page 35: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Nee

dsC

halle

nges

Tool

s

Back pressure(examples)

Akka streams

TCP Window field

Page 36: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Nee

dsC

halle

nges

Tool

s

Limit Back pressure

Remove Capacity constraint

Auto adaptive(but more exotic solutions)

Page 37: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Nee

dsC

halle

nges

Tool

s

Capacity constraint(rewrite oldest)

Page 38: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Nee

dsC

halle

nges

Tool

s

Capacity constraint(examples)

ArangoDB Cap constraint

CircularFifoQueue

Page 39: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Not

dr

owni

ng

in th

e st

ream

of

even

ts

Nee

dsC

halle

nges

Tool

s HOW

Start with easy solutions:● Connection limit● Log rotation/TTL

End with exotic ones:● Back pressure● Capacity constraint

Tools & practices

Page 40: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Not

dr

owni

ng

in th

e st

ream

of

even

ts

Nee

dsC

halle

nges

Tool

s

WHAT

HOW

WHY Business needs

For developers

Tools & practices

Page 41: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Summary

Page 42: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Simple, but useful principles

Self-adapt

Priority

Page 43: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

● http://spray.io/vienna ● http://doc.akka.io/docs/akka/2.4.2/general/stream/stream-design.html ● https://www.youtube.com/watch?v=N-n1n6WKmRs ● https://docs.arangodb.com/IndexHandling/Cap.html ● https://www.oreilly.com/ideas/bla-bla-microservices-bla-bla ● https://github.com/pkinsky/akka-streams-example ● http://doc.akka.io/docs/akka/2.4.3/scala/stream/stream-customize.html● https://en.wikipedia.org/wiki/Comet_%28programming%29 ● http://www.html5rocks.com/en/tutorials/eventsource/basics/ ● https://en.wikipedia.org/wiki/Kernel_same-page_merging ● https://github.com/Auginte/scarango/● https://youtu.be/TZ4aSx7T3r8?t=37m51s● http://spray.io/msug/ ● http://stackoverflow.com/questions/20162176/centos-linux-setting-logrotate-to-maximum-file-size-for-all-

logs ● http://jmeter.apache.org/ ● https://github.com/firehol/netdata ● http://blog.lancearlaus.com/akka/streams/scala/2015/05/27/Akka-Streams-Balancing-Buffer/ ● http://slides.com/lancearlaus/akka-streams-http-intro

References

Page 44: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

● See https://gist.github.com/aurelijusb/6052754236e90b9d70854b5c42c2120c ● https://www.youtube.com/watch?v=FUpSLAQ2d2o

Demo

Page 45: Not drowning of events - Aurelijus Banelisaurelijus.banelis.lt/prezentations/ndrown-in-event... · Event streams Between developers term “Event stream” is more common, than “Historical

Questions?