+ All Categories
Home > Software > Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

Date post: 15-Aug-2015
Category:
Upload: bhasker-kode
View: 220 times
Download: 0 times
Share this document with a friend
79
#ka fka #storm @FifthEl ‘15 I’m @bhaskerkode aka Bosky Product Engg at Helpshift
Transcript
Page 1: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

#kafka#storm

@FifthEl ‘15

I’m @bhaskerkode aka BoskyProduct Engg at Helpshift

Page 2: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

you’re here at a bigdata, & analytics conference to …

Page 3: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

mobile

webnumbers

insights

predictiot

internal

?

this talk

Page 4: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

mobile

webnumbers

insights

predictiot

internal

your jobyour raise?

this talk really is about sleep

goodsleep

Page 5: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

Kafka is your glue to have different teams break down complex end-to-end problems into smaller more manageable oneslike a “checkpoint” in a long hike/game/drive

seperation of concerns helps you design distributed systems

Page 6: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

kafka & stream processingpower combo <insert quote to impress friend>

Page 7: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

developedworld

wiredcommunication

wireless / mobile

developing world

wireless / mobile

Page 8: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift
Page 9: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

the same may happen with bigdata & analyticsdataingestion

offline processing

streamprocessing

dataingestion

streamprocessing

Page 10: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

Linkedinhttp://kafka.apache.org/

Page 11: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

Twitterhttps://storm.apache.org/

Page 12: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

mobile

webHA

iot

internal

biz logic

typical analytics ingestion architecture

dbcachesearchinfra

Page 13: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

mo

web

HAiot

inte

auth logic

task #1

kafkaproducer

dbcachesearchinfra

kafkaconsumer

consumer storm spark samza

Page 14: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

how kafka helps me sleep betterhow? let’s talk numbers

Page 15: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

~300 millionrequests/day to our events kafka producer; ekaf

served by 22 coresor 11 servers

running on auto-pilotfor 1+ years little maintenance, only scale serverszero-downtime support plenty of metrics

(started with 3 servers replacing 14 JVM producers)

separate auth logic from producer logic

erlang

= peaceful sleepopen source

(scalable)

Page 16: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

mo

web

iot

inte

modular design

kafboy

ekaf

auth logic

HTTP 500unauthorizedwrong api’s

metrics

HTTP 200

Page 17: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

modular design

kafboy

ekaf

auth logic

HTTP 500unauthorizedwrong api’s

metrics

HTTP 200

Page 18: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

one thing particularly distinguishes kafkasecret sauce? let’s take wild guesses

Page 19: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

community?NO let’s take more wild guesses at the secret sauce

Page 20: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

let’s illustrate with some examples

Page 21: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

You: “Create topic foo with 3 partitions”

Page 22: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

kafka: “OK! each partition is set on a different broker. one of the brokers is an elected leader,

push your messages to the leader host, port please. if leader goes down, other broker is elected.”

Page 23: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

is it the fault-tolerance you get?

NO let’s take more wild guesses at the secret sauce

You: “create topic foo” with 3 partitions

partitionsleaders

election

Page 24: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

You: “hey broker1, where should i push to?”

Page 25: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

kafka: please dial 1-800-metadata to any broker. we all maintain this

data. you can make a metadata request with topic(s) you want, and

we will return it s partitions, and their broker hosts, ports, leader

info, etc

Page 26: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

is it the separation of concerns?

NO let’s take more wild guesses at the secret sauce

You: “hey broker1, where should i push to?”

metadata on all brokers

gives host & port of leader for partitions + more info

Page 27: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

You: “hey partition1 on broker1, for topic1here are 10 messages.”

Page 28: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

kafka: “thank you for calling partition1. i will append it to a dir/file called topic1/

partition1.log.

Since its append only like a commit log, you get ordering within partition free!”

Page 29: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

is it the producer speed you get?

NO let’s take more wild guesses at the secret sauce

You: “hey partition1 on broker1, for topic1here are 10 messages.”

append only commit-logordering within partition

make 1 partition for global ordering

Page 30: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

You: “hey broker2, where should i consume from?

Page 31: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

kafka: “thank you for connecting to the right broker. you can now read any

partition you want, and from any offset. All i care about is which offset

to start reading from in a topic/partition.log file”

Page 32: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

You: “hey broker1, topic1, partition1i want all data from message offset ….10(from ZK) onwards”

Page 33: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

kafka: “thank you for calling partition1. i’m going to sendfile the bytes you asked from kernel-space directly to the socket

of a consumer using zero copy, thus reducing context switches & minimal garbage collection. yes, i am badass.”

Page 34: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

is it the consumer speed you get?

NO let’s take more wild guesses at the secret sauce

You: “hey broker1, topic1, partition1i want all data from message offset ….10(from ZK) onwards”

offset bytessendfile bytes from offset to socket

kernel space not userspace

Page 35: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

You: “for topic1, i want 3 consumers all reading every msg. for topic2, i want the data split between 3 consumers”

Page 36: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

kafka: “3 different pipelines/actions on the same input topic1? Nice!

I can see your team is growing.

Thank you for grokking the concept of consumer groups topic2. Make sure all

3 of your use the same group-id, and i’ll take of the rest!”

Page 37: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

is it the consumer parallelism?

NO let’s take more wild guesses at the secret sauce

You: “for topic1, i want 3 consumers all reading every msg.for topic2, i want the data split between 3 consumers”

can broadcast to all consumerscan split b/w a group of consumers

Page 38: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

binary protocol.but importantly a documented spec of what goes/comes over-the-wire

the one thing particularly distinguishes kafka & gives it a stellar status in the ecosystem is its

Page 39: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

the creators of kafka built the brokers & the specof how to communicate with it (producers & consumers),

and let the community speak the protocol

a documented spec of what goes/comes over-the-wire

Page 40: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

the creators of kafka built the brokers & the spec

a documented spec of what goes/comes over-the-wire

eg: do you know what is sent by a namenode/jobtracker/datanode over the wire?

(PS: where is the spec? come meet me after)

Page 41: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

protocols win over api’s/drivers

the creators of kafka focussed on the spec

If you knew what data a namenode/jobtracker/datanode actually communicates over the wire. It opens up a new world.

allows diff language clients to express themselves best

its just data over TCP sockets.

more freedom

more integrations & faster adoption

Page 42: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

000300000000000 10007636c69656e7 4310000000100066

576656e7473

0,3,0,0,0,0,0,1,0,7,99,108,

105,101,110,116,49,0,0,0,1,0,

6,101,118,101,110,116,115

1. open a tcp socket to any kafka 0.8+ broker:port2. send these 29 bytes that asks for metadata for topic

“events”

these 29 bytes

(or in hex)

and you’llget backmetadata

for the topic“events”

always.

Page 43: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

0,3, 0,0,

0,0,0,1, 0,7,

99,108,105,101,110,116,49, 0,0,0,1,

0,6, 101,118,101,110,116,115

[2 bytes] metadata code = 3 [2 bytes] api version = 0 [4 bytes] int id (for replies) [2 bytes] client id length = 7 [7 bytes] “client1” [4 bytes] no# of topics = 1 [2 bytes] topic[0] length = 6 [6 bytes] “events”

what this packet means

Page 44: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

<<0,0,0,0,0,0,0,3,0,0,0,3,0,25,118,97,103,114,97,110,116, 45,117,98,117,110,116,117,45,112,114,101,99,105,115,101,

45,54,52,0,0,35,133,0,0,0,1,0,25,118,97,103,114,97,110, 116,45,117,98,117,110,116,117,45,112,114,101,99,105,115,

101,45,54,52,0,0,35,131,0,0,0,2,0,25,118,97,103,114,97, 110,116,45,117,98,117,110,116,117,45,112,114,101,99,105,

115,101,45,54,52,0,0,35,132,0,0,0,3,0,0,0,2,97,49,0,0,0, 2,0,0,0,0,0,0,0,0,0,3,0,0,0,1,0,0,0,3,0,0,0,1,0,0,0,3,0, 0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0, 2,97,50,0,0,0,2,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0, 0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,2,0,0,0,1, 0,0,0,2,0,0,0,2,97,51,0,0,0,2,0,0,0,0,0,0,0,0,0,3,0,0,0, 2,0,0,0,3,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,1,0,0,0,0,0,1,0, 0,0,1,0,0,0,2,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,1,0,0,0,2>>

% 0,0,0,1, % this is a response to req id 1 % 0,0,0,2, % number of brokers % 0,0,0,1, % broker[0] id % then broker name, host, port % 0,0,0,3, % topics len % 0,0,0,6, % topic[0] name len % ……………….. % topic[0] name events % 0,0,0,2, % topic[0] partitions len

% 0,0, % topic[0] partition1 error code % 0,0,0,0, % topic[0] partition1 % 0,0,0,1 % topic[0] partition1 leaderid % 0,0,0,1, % topic[0] partition1 replicas len % 0,0,0,3, % topic[0] partition1 replica1 % 0,0,0,1, % topic[0] partition1 isr len % 0,0,0,3, % topic[0] partition1 isr1

% another partition data here % etc

metadataresponsedecoded

Page 45: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

similiarly all other operationsencode the request as a packet send over tcp socket

sync produce handle response<<0,0,0,0,0,0,0,3,0,0,0,3,0,25,118,97,103,114,97,110,116,

45,117,98,117,110,116,117,45,112,114,101,99,105,115,101, 45,54,52,0,0,35,133,0,0,0,1,0,25,118,97,103,114,97,110,

116,45,117,98,117,110,116,117,45,112,114,101,99,105,115, 101,45,54,52,0,0,35,131,0,0,0,2,0,25,118,97,103,114,97,

110,116,45,117,98,117,110,116,117,45,112,114,101,99,105, 115,101,45,54,52,0,0,35,132,0,0,0,3,0,0,0,2,97,49,0,0,0,

2,0,0,0,0,0,0,0,0,0,3,0,0,0,1,0,0,0,3,0,0,0,1,0,0,0,3,0, 0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0, 2,97,50,0,0,0,2,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0, 0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,2,0,0,0,1, 0,0,0,2,0,0,0,2,97,51,0,0,0,2,0,0,0,0,0,0,0,0,0,3,0,0,0, 2,0,0,0,3,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,1,0,0,0,0,0,1,0, 0,0,1,0,0,0,2,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,1,0,0,0,2>>

<<0,0,0,0,0,0,0,3,0,0,0,3,0,25,118,97,103,114,97,110,116, 45,117,98,117,110,116,117,45,112,114,101,99,105,115,101,

45,54,52,0,0,35,133,0,0,0,1,0,25,118,97,103,114,97,110, 116,45,117,98,117,110,116,117,45,112,114,101,99,105,115,

101,45,54,52,0,0,35,131,0,0,0,2,0,25,118,97,103,114,97, 110,116,45,117,98,117,110,116,117,45,112,114,101,99,105,

115,101,45,54,52,0,0,35,132,0,0,0,3,0,0,0,2,97,49,0,0,0, 2,0,0,0,0,0,0,0,0,0,3,0,0,0,1,0,0,0,3,0,0,0,1,0,0,0,3,0, 0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0, 2,97,50,0,0,0,2,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0, 0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,2,0,0,0,1, 0,0,0,2,0,0,0,2,97,51,0,0,0,2,0,0,0,0,0,0,0,0,0,3,0,0,0, 2,0,0,0,3,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,1,0,0,0,0,0,1,0, 0,0,1,0,0,0,2,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,1,0,0,0,2>>

async produce<<0,0,0,0,0,0,0,3,0,0,0,3,0,25,118,97,103,114,97,110,116,

45,117,98,117,110,116,117,45,112,114,101,99,105,115,101, 45,54,52,0,0,35,133,0,0,0,1,0,25,118,97,103,114,97,110,

116,45,117,98,117,110,116,117,45,112,114,101,99,105,115, 101,45,54,52,0,0,35,131,0,0,0,2,0,25,118,97,103,114,97,

110,116,45,117,98,117,110,116,117,45,112,114,101,99,105, 115,101,45,54,52,0,0,35,132,0,0,0,3,0,0,0,2,97,49,0,0,0,

2,0,0,0,0,0,0,0,0,0,3,0,0,0,1,0,0,0,3,0,0,0,1,0,0,0,3,0, 0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0, 2,97,50,0,0,0,2,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0, 0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,2,0,0,0,1, 0,0,0,2,0,0,0,2,97,51,0,0,0,2,0,0,0,0,0,0,0,0,0,3,0,0,0, 2,0,0,0,3,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,1,0,0,0,0,0,1,0, 0,0,1,0,0,0,2,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,1,0,0,0,2>>

no response

Page 46: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

MessageSet => [Offset MessageSize Message] Offset => int64

MessageSize => int32 Messages

Message => Crc MagicByte Attributes Key Value

Crc => int32 MagicByte => int8 Attributes => int8

Key => bytes Value => bytes

Page 47: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

the joy of knowing how your data is encoded and sent over tcp socketkeeps things simple, lets you sleep better easier to debug, test, add middle-wares to audit, etc

MQTT endoded messages crypto encoded <<0,0,0,0,0,0,0,3,0,0,0,3,0,25,118,97,103,114,97,110,116,

45,117,98,117,110,116,117,45,112,114,101,99,105,115,101, 45,54,52,0,0,35,133,0,0,0,1,0,25,118,97,103,114,97,110,

116,45,117,98,117,110,116,117,45,112,114,101,99,105,115, 101,45,54,52,0,0,35,131,0,0,0,2,0,25,118,97,103,114,97,

110,116,45,117,98,117,110,116,117,45,112,114,101,99,105, 115,101,45,54,52,0,0,35,132,0,0,0,3,0,0,0,2,97,49,0,0,0,

2,0,0,0,0,0,0,0,0,0,3,0,0,0,1,0,0,0,3,0,0,0,1,0,0,0,3,0, 0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0, 2,97,50,0,0,0,2,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0, 0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,2,0,0,0,1, 0,0,0,2,0,0,0,2,97,51,0,0,0,2,0,0,0,0,0,0,0,0,0,3,0,0,0, 2,0,0,0,3,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,1,0,0,0,0,0,1,0, 0,0,1,0,0,0,2,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,1,0,0,0,2>>

<<0,0,0,0,0,0,0,3,0,0,0,3,0,25,118,97,103,114,97,110,116, 45,117,98,117,110,116,117,45,112,114,101,99,105,115,101,

45,54,52,0,0,35,133,0,0,0,1,0,25,118,97,103,114,97,110, 116,45,117,98,117,110,116,117,45,112,114,101,99,105,115,

101,45,54,52,0,0,35,131,0,0,0,2,0,25,118,97,103,114,97, 110,116,45,117,98,117,110,116,117,45,112,114,101,99,105,

115,101,45,54,52,0,0,35,132,0,0,0,3,0,0,0,2,97,49,0,0,0, 2,0,0,0,0,0,0,0,0,0,3,0,0,0,1,0,0,0,3,0,0,0,1,0,0,0,3,0, 0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0, 2,97,50,0,0,0,2,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0, 0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,2,0,0,0,1, 0,0,0,2,0,0,0,2,97,51,0,0,0,2,0,0,0,0,0,0,0,0,0,3,0,0,0, 2,0,0,0,3,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,1,0,0,0,0,0,1,0, 0,0,1,0,0,0,2,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,1,0,0,0,2>>

thrift/avro encoded messages<<0,0,0,0,0,0,0,3,0,0,0,3,0,25,118,97,103,114,97,110,116,

45,117,98,117,110,116,117,45,112,114,101,99,105,115,101, 45,54,52,0,0,35,133,0,0,0,1,0,25,118,97,103,114,97,110,

116,45,117,98,117,110,116,117,45,112,114,101,99,105,115, 101,45,54,52,0,0,35,131,0,0,0,2,0,25,118,97,103,114,97,

110,116,45,117,98,117,110,116,117,45,112,114,101,99,105, 115,101,45,54,52,0,0,35,132,0,0,0,3,0,0,0,2,97,49,0,0,0,

2,0,0,0,0,0,0,0,0,0,3,0,0,0,1,0,0,0,3,0,0,0,1,0,0,0,3,0, 0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0, 2,97,50,0,0,0,2,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0, 0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,2,0,0,0,1, 0,0,0,2,0,0,0,2,97,51,0,0,0,2,0,0,0,0,0,0,0,0,0,3,0,0,0, 2,0,0,0,3,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,1,0,0,0,0,0,1,0, 0,0,1,0,0,0,2,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,1,0,0,0,2>>

AOL/YAHOO/* packets<<0,0,0,0,0,0,0,3,0,0,0,3,0,25,118,97,103,114,97,110,116,

45,117,98,117,110,116,117,45,112,114,101,99,105,115,101, 45,54,52,0,0,35,133,0,0,0,1,0,25,118,97,103,114,97,110,

116,45,117,98,117,110,116,117,45,112,114,101,99,105,115, 101,45,54,52,0,0,35,131,0,0,0,2,0,25,118,97,103,114,97,

110,116,45,117,98,117,110,116,117,45,112,114,101,99,105, 115,101,45,54,52,0,0,35,132,0,0,0,3,0,0,0,2,97,49,0,0,0,

2,0,0,0,0,0,0,0,0,0,3,0,0,0,1,0,0,0,3,0,0,0,1,0,0,0,3,0, 0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0, 2,97,50,0,0,0,2,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0, 0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,2,0,0,0,1, 0,0,0,2,0,0,0,2,97,51,0,0,0,2,0,0,0,0,0,0,0,0,0,3,0,0,0, 2,0,0,0,3,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,1,0,0,0,0,0,1,0, 0,0,1,0,0,0,2,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,1,0,0,0,2>>

Page 48: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

brokers focus on the commit logs, etcand delegate several opinionated areas to the client, onus is on the client to make smart decisions

compression queue’ing<<0,0,0,0,0,0,0,3,0,0,0,3,0,25,118,97,103,114,97,110,116,

45,117,98,117,110,116,117,45,112,114,101,99,105,115,101, 45,54,52,0,0,35,133,0,0,0,1,0,25,118,97,103,114,97,110,

116,45,117,98,117,110,116,117,45,112,114,101,99,105,115, 101,45,54,52,0,0,35,131,0,0,0,2,0,25,118,97,103,114,97,

110,116,45,117,98,117,110,116,117,45,112,114,101,99,105, 115,101,45,54,52,0,0,35,132,0,0,0,3,0,0,0,2,97,49,0,0,0,

2,0,0,0,0,0,0,0,0,0,3,0,0,0,1,0,0,0,3,0,0,0,1,0,0,0,3,0, 0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0, 2,97,50,0,0,0,2,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0, 0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,2,0,0,0,1, 0,0,0,2,0,0,0,2,97,51,0,0,0,2,0,0,0,0,0,0,0,0,0,3,0,0,0, 2,0,0,0,3,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,1,0,0,0,0,0,1,0, 0,0,1,0,0,0,2,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,1,0,0,0,2>>

<<0,0,0,0,0,0,0,3,0,0,0,3,0,25,118,97,103,114,97,110,116, 45,117,98,117,110,116,117,45,112,114,101,99,105,115,101,

45,54,52,0,0,35,133,0,0,0,1,0,25,118,97,103,114,97,110, 116,45,117,98,117,110,116,117,45,112,114,101,99,105,115,

101,45,54,52,0,0,35,131,0,0,0,2,0,25,118,97,103,114,97, 110,116,45,117,98,117,110,116,117,45,112,114,101,99,105,

115,101,45,54,52,0,0,35,132,0,0,0,3,0,0,0,2,97,49,0,0,0, 2,0,0,0,0,0,0,0,0,0,3,0,0,0,1,0,0,0,3,0,0,0,1,0,0,0,3,0, 0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0, 2,97,50,0,0,0,2,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0, 0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,2,0,0,0,1, 0,0,0,2,0,0,0,2,97,51,0,0,0,2,0,0,0,0,0,0,0,0,0,3,0,0,0, 2,0,0,0,3,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,1,0,0,0,0,0,1,0, 0,0,1,0,0,0,2,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,1,0,0,0,2>>

detect downtime<<0,0,0,0,0,0,0,3,0,0,0,3,0,25,118,97,103,114,97,110,116,

45,117,98,117,110,116,117,45,112,114,101,99,105,115,101, 45,54,52,0,0,35,133,0,0,0,1,0,25,118,97,103,114,97,110,

116,45,117,98,117,110,116,117,45,112,114,101,99,105,115, 101,45,54,52,0,0,35,131,0,0,0,2,0,25,118,97,103,114,97,

110,116,45,117,98,117,110,116,117,45,112,114,101,99,105, 115,101,45,54,52,0,0,35,132,0,0,0,3,0,0,0,2,97,49,0,0,0,

2,0,0,0,0,0,0,0,0,0,3,0,0,0,1,0,0,0,3,0,0,0,1,0,0,0,3,0, 0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0, 2,97,50,0,0,0,2,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0, 0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,2,0,0,0,1, 0,0,0,2,0,0,0,2,97,51,0,0,0,2,0,0,0,0,0,0,0,0,0,3,0,0,0, 2,0,0,0,3,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,1,0,0,0,0,0,1,0, 0,0,1,0,0,0,2,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,1,0,0,0,2>>

load balancing to partitions<<0,0,0,0,0,0,0,3,0,0,0,3,0,25,118,97,103,114,97,110,116,

45,117,98,117,110,116,117,45,112,114,101,99,105,115,101, 45,54,52,0,0,35,133,0,0,0,1,0,25,118,97,103,114,97,110,

116,45,117,98,117,110,116,117,45,112,114,101,99,105,115, 101,45,54,52,0,0,35,131,0,0,0,2,0,25,118,97,103,114,97,

110,116,45,117,98,117,110,116,117,45,112,114,101,99,105, 115,101,45,54,52,0,0,35,132,0,0,0,3,0,0,0,2,97,49,0,0,0,

2,0,0,0,0,0,0,0,0,0,3,0,0,0,1,0,0,0,3,0,0,0,1,0,0,0,3,0, 0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0, 2,97,50,0,0,0,2,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0, 0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,2,0,0,0,1, 0,0,0,2,0,0,0,2,97,51,0,0,0,2,0,0,0,0,0,0,0,0,0,3,0,0,0, 2,0,0,0,3,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,1,0,0,0,0,0,1,0, 0,0,1,0,0,0,2,0,0,0,1,0,0,0,2,0,0,0,2,0,0,0,1,0,0,0,2>>

Page 49: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

clientskeeps things simplea subset of what clients need to do include:

1. bootstrap 2. open sockets 3. encode packets 4. decode packets 5. send over tcp 6. route responses 7. handle failures, events 8. state machines

Page 50: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

distributed systems need to be built as state machinesdon’t trust a client that blocksuntil an operation is complete

Page 51: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

distributed systems need to be built as state machines

// send// wait for responseBAD even if this thread/processis doing nothing until timeoutthe idling is not efficient

Page 52: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

distributed systems need to be built as state machines

// listening for socket states// listening for responses // send, and continue// on_recv, route response// after_timeout, route timeoutGOOD

Page 53: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

distributed systems need to be built as state machines

set concurrency options for ekaf

set the hostname of a load balancer over your brokers

http://github.com/helpshift/ekaf

Page 54: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

distributed systems need to be built as state machines

ekaf hits the ground running with 1 call // publish(topic, message) if no state machine, it flows from request metadata -> worker pool creation -> socket connecting -> ready state

http://github.com/helpshift/ekaf

Page 55: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

distributed systems need to be built as state machines

if topic state machine has metadatait knows which broker for each partition

if state already has socket, queue it

http://github.com/helpshift/ekaf

Page 56: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

distributed systems need to be built as state machines

all messages in states before ready are queued.

if queue hits size OR hits flush timeout. send it

http://github.com/helpshift/ekaf

Page 57: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

http://github.com/helpshift/ekafGo through docs at

Page 58: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

tests include broker downtime , adding a broker, etc & a mini kafka broker for tests

http://github.com/helpshift/kafkamocker

Page 59: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

flushed queue worker up

worker down downtime saved

downtime replayed time to connect max downtime q

Callbacks used for Metrics

Page 60: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

last year 6k/minnow 6k/sec

only scaled up

servers

Page 61: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

hello worlddriven development

response time against endpoint to just echo

Page 62: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

ekaf @Layer (ex-Apple engineers) “The art of powering the Internet’s next messaging system” https://www.youtube.com/watch?v=mv2MBYU8Yls#t=33m5s

Page 63: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

ekaf@ a chinese social network1 pull request about to be merged

and elsewhere

Page 64: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

back to pipelinesinvolving a kafka producer and consumer

Page 65: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

SDK nginx auth/api#erlang

active user analytics pipeline @helpshift

PGS3

kafkahttpproducer#kafboy (uses ekaf)

to disk

hyperloglogcounts

#clojure

kafka consumer #clj-kafka

~1 billion devices

HA

EMR (internal jobs)

(dashboards)

Page 66: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

mail delivery @helpshift

actually sent

#clj-kafka

kafka consumer#clj-kafka

email

Page 67: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

[WIP] ES indexing @helpshift

actually indexed

#clj-kafka

ES bulk index

docs

Page 68: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

audit/action trails @helpshift

PG

#clj-kafka

kafka consumer#clj-kafka

old objectnew object

diff emit/ignorerows

few rulesobjects are namespace

must have id

Page 69: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

Storm @helpshift

Page 70: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift
Page 71: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

iTunesPlay

reviewsdistributedcrawler #go#master#worker farm#controller

the reviews storm pipeline @helpshift

PG

kafkaproducer#shopify/sarama

deduplication

tokenization

topic extraction

sentiment analysis

stormkafka spout

Page 72: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

example storm topology read up more on spouts and bolts (any Q’s?)

Page 73: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

• PG and multiple bolts tip • Metrics at every bolt • Local statsite -> grafana • Avoid metric explosion

instrumenting tips

Page 74: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

[WIP] segment population

query ESjob tracking

#clj-kafka

kafka consumer / storm

elasticsearch query

representing segment

scheduler

S3

countsin PG

“find users who match level 2 , who did not find the easter egg”

Page 75: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

fit your use case population count

moving average

a note on samza’s state

Page 76: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

Kafka is your glue to have different teams break down complex end-to-end problems into smaller more manageable oneslike a “checkpoint” in a long hike/game/drive

seperation of concerns helps you design distributed systems

Page 77: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

numbers

your job

good sleep

your product

kafka + storm

Page 78: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

Small Snapshot of Helpshift

Hay Day Boom Beach Clash of Clans Deer Hunter High School Story

Family GuyFlipboard Circa Wordpress Misfit Microsoft Outlook

APP + API

DBMONITORING

OTHER

ROUTING

HAProxy

Our SDK is being embedded in a growing list of popular apps

Page 79: Kafka & Storm - FifthElephant 2015 by @bhaskerkode, Helpshift

#kafka#storm

Thanks!

I’m @bhaskerkode aka BoskyProduct Engg @Helpshift [email protected]

Find this talk at http://bit.ly/fifthel15-kafka-storm


Recommended