Slide 1

Slide 1 text

SCALE processing events at Mariusz Gil

Slide 2

Slide 2 text

WROCŁAW, POLAND

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

SCALE processing events at Who is working on application which is runnig on more than X servers?

Slide 6

Slide 6 text

SCALE SCALE SCALE SCALE at

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

user browser &

Slide 9

Slide 9 text

user browser & data processing, rendering request, routing

Slide 10

Slide 10 text

faster is better slower is unusable

Slide 11

Slide 11 text

requests sometimes are heavy… …too heavy

Slide 12

Slide 12 text

requests sometimes are heavy… …too heavy

Slide 13

Slide 13 text

event processing logic should be moved out from request-response loop

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

RabbitMQ is a platform to send and receive messages

Slide 16

Slide 16 text

producer consumer Firstly

Slide 17

Slide 17 text

producer consumer1 consumer2 Basic QoS settings

Slide 18

Slide 18 text

producer consumer1 consumer2

Slide 19

Slide 19 text

producer consumer1 consumer2

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

handleRequest($request); if ($form->isValid()) { $this->get('tweet_feed_producer')->publish(array( 'user' => $user, 'tweet' => 'Lorem ipsum dolor sit amet...' )); } // ... } }

Slide 22

Slide 22 text

getFriends(); foreach ($friends as $friend) { $friend->getFeed()->push($tweet); } return true; } }

Slide 23

Slide 23 text

How to know if our consumers layer is efficient or not?

Slide 24

Slide 24 text

producer consumer producer consumer producer consumer Directed Acyclic Graphs

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

Apache Storm is a distributed realtime computation system

Slide 27

Slide 27 text

doing for realtime processing what Hadoop did for batch processing

Slide 28

Slide 28 text

written in Clojure, but language agnostic

Slide 29

Slide 29 text

use cases realtime analytics online machine learning continous computations distributed RPC Storm's small set of primitives satisfy a stunning number of use cases.

Slide 30

Slide 30 text

unbouded sequence of tuples stream

Slide 31

Slide 31 text

spout source of streams Joke about TCP and UDP connections

Slide 32

Slide 32 text

bolt process input stream and produce new one

Slide 33

Slide 33 text

bolt process input stream and produce new one

Slide 34

Slide 34 text

Topology is a network of spouts and bolts Directed Acyclic Multi-Graphs

Slide 35

Slide 35 text

Infrastructure level nimbus, supervisors, workers Apache Zookeepers

Slide 36

Slide 36 text

public class RandomSentenceSpout extends BaseRichSpout { SpoutOutputCollector _collector; Random _rand; @Override public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) { _collector = collector; _rand = new Random(); } @Override public void nextTuple() { Utils.sleep(100); String[] sentences = new String[] { "the cow jumped over the moon", "an apple a day keeps the doctor away", "four score and seven years ago", "snow white and the seven dwarfs", "i am at two with nature"}; String sentence = sentences[_rand.nextInt(sentences.length)]; _collector.emit(new Values(sentence)); } @Override public void ack(Object id) { } @Override public void fail(Object id) { } @Override public void declareOutputFields(OutputFieldsDeclarer declarer) { declarer.declare(new Fields("word")); } }

Slide 37

Slide 37 text

public static class WordCount extends BaseBasicBolt { Map counts = new HashMap(); @Override public void execute(Tuple tuple, BasicOutputCollector collector) { String word = tuple.getString(0); Integer count = counts.get(word); if (count == null) count = 0; count++; counts.put(word, count); collector.emit(new Values(word, count)); } @Override public void declareOutputFields(OutputFieldsDeclarer declarer) { declarer.declare(new Fields("word", "count")); } }

Slide 38

Slide 38 text

public class WordCountTopology { public static void main(String[] args) throws Exception { TopologyBuilder builder = new TopologyBuilder(); builder.setSpout("spout", new RandomSentenceSpout(), 5); builder.setBolt("split", new SplitSentence(), 8) .shuffleGrouping("spout"); builder.setBolt("count", new WordCount(), 12) .fieldsGrouping("split", new Fields("word")); Config conf = new Config(); conf.setDebug(true); if (args != null && args.length > 0) { conf.setNumWorkers(3); StormSubmitter.submitTopology(args[0], conf, builder.createTopology()); } else { conf.setMaxTaskParallelism(3); LocalCluster cluster = new LocalCluster(); cluster.submitTopology("word-count", conf, builder.createTopology()); Thread.sleep(10000); cluster.shutdown(); } } }

Slide 39

Slide 39 text

high-level abstraction Trident for realtime processing

Slide 40

Slide 40 text

FixedBatchSpout spout = new FixedBatchSpout(new Fields("sentence"), 3, new Values("the cow jumped over the moon"), new Values("the man went to the store and bought some candy"), new Values("four score and seven years ago"), new Values("how many apples can you eat")); spout.setCycle(true); TridentTopology topology = new TridentTopology(); TridentState wordCounts = topology.newStream("spout1", spout) .each(new Fields("sentence"), new Split(), new Fields("word")) .groupBy(new Fields("word")) .persistentAggregate( new MemoryMapState.Factory(), new Count(), new Fields("count") ).parallelismHint(6);

Slide 41

Slide 41 text

events after all ? Where are my

Slide 42

Slide 42 text

NOWHERE unfortunately…

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

+

Slide 45

Slide 45 text

+

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

DO o

Slide 48

Slide 48 text

DO verengineering on’t Redis pub/sub

Slide 49

Slide 49 text

@mariuszgil

Slide 50

Slide 50 text

THANKS

Slide 51

Slide 51 text

( it depends )