SlideShare a Scribd company logo
Darach	
  Ennis	
  (darach@streambase.com)	
  @darachennis                   	
  
                       StreamBase	
  Systems            	
  
          Erlang	
  Factory	
  London	
  -­‐	
  	
  June	
  10th	
  2011	
  




 Complex	
  Er[jl]ang	
  Processing	
  with	
  StreamBase:      	
  
A	
  DSL	
  for	
  Low	
  Latency	
  High	
  Frequency	
  CompuOng   	
  


                   +                              +                       =
                              Copyright 2011 © StreamBase Systems, Inc.             1	
  
Agenda	
  

  What	
  is	
  ‘Complex	
  Event	
  Processing’	
  
     •  Specifically	
  flow	
  oriented	
  event	
  processing	
  (there	
  are	
  others)	
  
     •  Streams	
  &	
  Operators.	
  Windowing,	
  Branching,	
  Combining,	
  Extending	
  
  A	
  day	
  in	
  the	
  life	
  of	
  a	
  flow	
  programmer	
  
     •    RelaOvity	
  -­‐	
  Data	
  parallelism,	
  concurrency,	
  latency	
  &	
  throughput	
  
     •    ConOnuity	
  -­‐	
  ConOnuous	
  Streaming	
  Map	
  Reduce	
  
     •    Reliability	
  –	
  High	
  availability,	
  the	
  low	
  latency	
  way	
  
     •    Flow,	
  meets	
  FuncOon.	
  Embed	
  Erlang	
  in	
  process	
  via	
  Erjang	
  
  Integra?on.	
  Erlang	
  –	
  the	
  ecosystem.	
  
     •  Calling	
  Erlang	
  from	
  StreamBase	
  –	
  Simple	
  &	
  windowed	
  funcOons	
  
     •  Client/Server	
  –	
  Pushing	
  events	
  to/from	
  StreamBase	
  
     •  RabbitMQ	
  -­‐	
  Messaging	
  
  TheC.	
  Erlang	
  –	
  the	
  inspira?on.	
  Paxos,	
  in	
  StreamBase	
  

                                            Copyright 2011 © StreamBase Systems, Inc.                  2	
  
High	
  Level	
  DSLs	
  :	
  Myth	
  Vs	
  Reality	
  

Myth:	
  High	
  level	
  domain	
  
specific	
  languages	
  are	
  
too	
  slow	
  for	
  HFT.	
  

Reality:	
  High	
  level	
  domain	
  
specific	
  languages	
  can	
  deliver	
  
beLer	
  performance	
  than	
  
system	
  programming	
  languages	
  
when	
  tailored	
  to	
  a	
  specific	
  task.	
  
                                     Copyright 2011 © StreamBase Systems, Inc.   3	
  
Complex	
  Event	
  Processing	
  aka	
  Event	
  Processing	
  

  SoCware	
  organized	
  by	
  events	
  (cf:	
  object/func?on	
  oriented)	
  
     •  What’s	
  an	
  event?	
  What’s	
  an	
  object?	
  
           •  Something	
  that	
  can	
  trigger	
  processing,	
  can	
  include	
  data.	
  
     •  Naturally	
  but	
  not	
  usually	
  represents	
  a	
  “real	
  world”	
  events	
  &	
  observaOons.	
  
  Complex	
  Event	
  Processing	
  PlaTorms	
  
     •  Soeware	
  stack	
  for	
  event	
  based	
  systems,	
  event	
  driven	
  architectures	
  
     •  Event	
  Programming	
  Language	
  –	
  SQL-­‐based,	
  Rules-­‐based,	
  or	
  State-­‐based	
  
     •  Commercial	
  and	
  open	
  source:	
  StreamBase,	
  Progress,	
  Microsoe,	
  IBM,	
  
        Oracle,	
  SAP,	
  Esper,	
  Drools	
  and	
  many	
  more	
  
  Adopted	
  in	
  financial	
  services	
  and	
  other	
  markets	
  
     •  System	
  monitoring,	
  industrial	
  process	
  control,	
  logisOcs,	
  defense/
        intelligence	
  
  Other	
  Event	
  Processing	
  Approaches:	
  
     •  Erlang,	
  Scala/Akka,	
  Actors,	
  node.js,	
  .NET	
  Rx	
  
                                               Copyright 2011 © StreamBase Systems, Inc.                              4	
  
What	
  does	
  a	
  CEP	
  DSL	
  or	
  Language	
  offer?	
  

  Con?nuously	
  Observe,	
  Orient,	
  Decide	
  Act	
  (OODA)	
  on	
  event	
  
   streams	
  
                                                                                                   Wikipedia:	
  
    •    ConOnuous	
  Incremental	
  Query	
                                                       John	
  Boyd,	
  
    •    Pajern	
  matching	
  within	
  or	
  across	
  streams	
                                 OODA	
  Loop	
  

    •    Branch	
  –	
  Split,	
  Causal	
  Split,	
  Filter.	
  
    •    Combine	
  -­‐	
  Semi-­‐Join,	
  Union,	
  Gather,	
  Merge,	
  Join,	
  Pajern	
  
    •    Windows	
  –	
  Process	
  sets	
  of	
  streaming	
  data	
  
           •  Sliding	
  or	
  Tumbling,	
  Overlapping	
  or	
  Non-­‐Overlapping,	
  Gaps	
  or	
  No	
  Gaps	
  
           •  Finite	
  (1	
  second,	
  1000	
  tuples),	
  Infinite	
  
           •  Emission	
  Policies:	
  On	
  Close,	
  Every	
  odd	
  message	
  
           •  Predicate	
  based	
  –	
  Roll	
  your	
  own	
  window	
  type	
  
    •  State	
  Management	
  –	
  In	
  memory,	
  CSV	
  files,	
  CSV	
  sockets,	
  RDBMS,	
  Parallel	
  
       DBMSs,	
  Column	
  Stores,	
  KV	
  stores,	
  NoSQL,	
  NewSQL…	
  
    •  Nice	
  to	
  have:	
  	
  
           •  DeclaraOve	
  concurrency,	
  Interface	
  Polymorphism,	
  DistribuOon,	
  Extensible	
  
                                               Copyright 2011 © StreamBase Systems, Inc.                               5	
  
Challenges	
  for	
  CEP	
  

  ‘Über’	
  Ultra	
  Low	
  Latency?	
  
     •  Sub-­‐milli	
  is	
  standard,	
  sub-­‐100-­‐micro	
  is	
  desirable.	
  Less	
  is	
  more!	
  
  Large	
  Data	
  Volumes	
  
     •  Hundreds	
  of	
  thousands	
  of	
  events,	
  thousands	
  of	
  decisions,	
  per	
  thread.	
  
     •  Big	
  Data.	
  ~Hundreds	
  of	
  SMP	
  CEP	
  nodes.	
  
  Demanding	
  Opera?onal	
  Environment	
  
     •  24x7,	
  365	
  –	
  in	
  criOcal	
  environments	
  (trading,	
  surveillance,	
  uOliOes)	
  
  Sophis?cated	
  Data	
  Processing	
  (some?mes)	
  
     •  OpOons	
  pricing,	
  yield	
  curves,	
  risk	
  metrics,	
  smart	
  grid	
  capacity	
  planning,	
  
        fraud	
  detecOon.	
  
  How	
  it’s	
  done	
  (QCON	
  London	
  2011):	
  
     •  How	
  LMAX	
  did	
  it?	
  hjp://bit.ly/fUeS0P	
  
     •  How	
  we	
  did	
  it?	
  hjp://bit.ly/hM6NAP	
  <-­‐	
  Our	
  CTO	
  Richard	
  Tibbejs	
  talk	
  

                                               Copyright 2011 © StreamBase Systems, Inc.                           6	
  
StreamBase	
  Event	
  Processing	
  Plauorm	
  
                                                                      Studio	
  Integrated	
  Development	
  Environment	
                                     Visualiza?on	
  
          Developer	
  Studio	
  
          Graphical	
  StreamSQL	
  for	
  developing,	
  	
  
          back	
  tesOng	
  and	
  deploying	
  applicaOons.	
  	
  	
  

                                              StreamBase	
  
               StreamBase	
  
                                              Component	
  
               Frameworks	
  	
  
                                               Exchange	
  
                                                                                             ApplicaOons	
  




Input	
  Adapter(s)	
  
Inject	
  streaming	
  (market	
  data)	
  
                                                    Adapters	
                                                                    Adapters	
  
and	
  staOc	
  (reference	
  data)	
                                         StreamBase	
  Server	
  
                                                                                                  	
  
sources.	
  




                                                                           Event	
  Processing	
  Server	
                                       Output	
  Adapter(s)	
  
                                                                           High	
  performance	
  opOmized	
  engine	
                           Send	
  results	
  to	
  systems,	
  users,	
  user	
  
                                                                           can	
  process	
  events	
  at	
  market	
  data	
                    screens	
  and	
  databases.	
  
                                                                           speeds.	
  

                                                                                Copyright 2011 © StreamBase Systems, Inc.                                                                            7	
  
How	
  did	
  we	
  do	
  it?	
  
  Compila?on	
  and	
  Sta?c	
  Analysis	
  
     •  Design	
  the	
  language	
  for	
  it	
  
  Modular	
  abstrac?on,	
  interfaces	
  
     •  Quants	
  and	
  Developers	
  Collaborate,	
  share	
  code	
  
  Bytecode	
  genera?on	
  and	
  the	
  Janino	
  compiler	
  
     •  OpOmized	
  bytecodes,	
  in-­‐memory	
  generaOon	
  	
  
  Garbage	
  op?miza?on	
  
     •  Pooling,	
  data	
  class,	
  invasive	
  collecOons	
  
  Integra?ons,	
  C++	
  and	
  Java	
  plugins	
  
     •  Efficient	
  naOve	
  interfaces,	
  Hardware	
  acceleraOon	
  
  Adapter	
  API,	
  FIX	
  Messaging	
  
     •  Threading	
  and	
  API	
  structure	
  for	
  ultra	
  low	
  latency	
  
  Parallelism,	
  Clustering,	
  Lanes	
  and	
  Tiers	
  
     •  Scalability,	
  with	
  a	
  latency	
  bias.	
  
  Modularity	
  through	
  Named	
  Data	
  Formats,	
  Schemas	
  
     •  Sharing	
  data	
  and	
  semanOcs	
  between	
  apps	
  
                                               Copyright 2011 © StreamBase Systems, Inc.   8	
  
StreamBase	
  StreamSQL	
  EventFlow	
  



                                                           Rapid	
  Deployment	
  
                                                             &	
  Unit	
  TesOng	
  
                Modularity	
  &	
  
                Polymorphism	
  




                                                           Interfaces	
  &	
            Off	
  The	
  Shelf	
  
                Off	
  The	
  Shelf	
                     Extension	
  Points	
         Business	
  Logic	
  
                ConnecOvity	
  



                                         Copyright 2011 © StreamBase Systems, Inc.                               9	
  
Operators	
  –	
  Hi	
  Erlang.	
  Hello	
  StreamBase	
  




 Did	
  you	
  just	
  tell	
  
  me	
  to	
  go	
  flow	
  
        myself?	
  




                                  Copyright 2011 © StreamBase Systems, Inc.   10	
  
Agenda	
  

  What	
  is	
  ‘Complex	
  Event	
  Processing’	
  
     •  Specifically	
  flow	
  oriented	
  event	
  processing	
  (there	
  are	
  others)	
  
     •  Streams	
  &	
  Operators.	
  Windowing,	
  Branching,	
  Combining,	
  Extending	
  
  A	
  day	
  in	
  the	
  life	
  of	
  a	
  flow	
  programmer	
  
     •    RelaOvity	
  -­‐	
  Data	
  parallelism,	
  concurrency,	
  latency	
  &	
  throughput	
  
     •    ConOnuity	
  -­‐	
  ConOnuous	
  Streaming	
  Map	
  Reduce	
  
     •    Reliability	
  –	
  High	
  availability,	
  the	
  low	
  latency	
  way	
  
     •    Flow,	
  meets	
  FuncOon.	
  Embed	
  Erlang	
  in	
  process	
  via	
  Erjang	
  
  Integra?on.	
  Erlang	
  –	
  the	
  ecosystem.	
  
     •  Calling	
  Erlang	
  from	
  StreamBase	
  –	
  Simple	
  &	
  windowed	
  funcOons	
  
     •  Client/Server	
  –	
  Pushing	
  events	
  to/from	
  StreamBase	
  
     •  RabbitMQ	
  -­‐	
  Messaging	
  
  TheC.	
  Erlang	
  –	
  the	
  inspira?on.	
  Paxos,	
  in	
  StreamBase	
  

                                            Copyright 2011 © StreamBase Systems, Inc.                  11	
  
A	
  day	
  in	
  the	
  life…	
  Why	
  a	
  DSL?	
  

  High	
  level	
  –	
  Windowing,	
  Combina?on	
  &	
  PaLern	
  Matching	
  
   Streams	
  
  Graphical	
  –	
  ‘See’	
  the	
  flow,	
  dependencies,	
  pathways	
  
  Fast,	
  Flexible	
  SDLC	
  –	
  Deploy	
  new	
  algorithms,	
  con?nuously	
  
  Understandable	
  –	
  Rise	
  to	
  the	
  abstrac?on	
  
  Flexible	
  




                                         Copyright 2011 © StreamBase Systems, Inc.     12	
  
A	
  day	
  in	
  the	
  life..	
  More	
  is	
  more!	
  




                                         Copyright 2011 © StreamBase Systems, Inc.   13	
  
Make	
  it	
  work.	
  Measure	
  it.	
  -­‐	
  Baseline	
  ‘Noop’	
  Performance	
  




          WARNING:	
  Micro-­‐
            benchmark.	
  
              YMMV	
  

                                 Copyright 2011 © StreamBase Systems, Inc.              14	
  
Concurrency	
  –	
  Baseline	
  -­‐	
  Results	
  



                                                                              Nice.	
  1.1	
  million	
  
                                                                                 events/sec	
  




                                  Copyright 2011 © StreamBase Systems, Inc.                                 15	
  
Parallelize	
  it	
  –	
  The	
  ‘Convenient,	
  but	
  incorrect’	
  way	
  




    Execution Order & Concurrency:

    Rule 1 –            Each event processed to completion left-right
    Rule 2 –            Branches processed sequentially
    Rule 3 –            Outputs are processed sequentially
    Rule 4 –            Module output processed to completion immediately
    Rule 5 –            One operator executed at a time




                                  Copyright 2011 © StreamBase Systems, Inc.     16	
  
Gah!	
  WTF?!	
  




                    Copyright 2011 © StreamBase Systems, Inc.   17	
  
OpOmize	
  it!	
  ObservaOon	
  #1	
  




                                                                          Measure	
  the	
  cost	
  
                                                                          of	
  thread	
  context	
  
                                                                          switches.	
  Dodge	
  
                                                                                  &	
  Burn!	
  




                              Copyright 2011 © StreamBase Systems, Inc.                                 18	
  
OpOmize	
  it!	
  ObservaOon	
  #2	
  –	
  It’s	
  Map/Combine/Reduce	
  




                             Copyright 2011 © StreamBase Systems, Inc.      19	
  
CSMR	
  –	
  A	
  ‘pajern’	
  for	
  low	
  latency	
  high	
  throughput?	
  




                                 Copyright 2011 © StreamBase Systems, Inc.       20	
  
CSMR	
  –	
  A	
  ‘pajern’	
  for	
  low	
  latency	
  high	
  throughput?	
  Yup!	
  

                                                25	
  




                                                                                                20	
                                                                                         20	
  
                                                20	
  
                                                                                                                                                              18	
  
  Millions	
  of	
  tuples	
  /	
  second	
  
      Throughput	
  (Mtps)	
  	
  




                                                15	
  



                                                                                                                                                                                                                   Across	
  Region	
  
                                                                                                                                                                                    10	
  
                                                10	
                                                                           9.4	
                                                                               Within	
  Region	
  
                                                                  8	
                   8	
  



                                                  5	
     4	
                                                          4	
                            4	
  




                                                  0	
  
                                                          Gather	
                      Merge	
                   Branch	
  &	
  Join	
      Filter	
  Even	
  Random	
        Baseline	
  (Noop)	
  
                                                                          Benchmark	
  HW:	
  Dell	
  RS510,	
  8	
  core,	
  32	
  GB	
  RAM,	
  2.4GHz	
  IA-­‐64,	
  OS:	
  RHEL	
  5u3,	
  SB	
  7.0.1.2	
  




                                                                                                                     Copyright 2011 © StreamBase Systems, Inc.                                                                            21	
  
CSMR	
  +	
  GPUs	
  /	
  FPGAs?	
  Sure!	
  




We can build on SMP and cluster wide distribution algorithms to further optimize interactions with
accelerated compute technologies. We can exploit accelerated hardware messaging where regular
network IO is insufficient for distribution results over 1Ge or regular networking technologies.
The pattern above is a continuous streaming variant of Map/Reduce in EventFlow.

                                        Copyright 2011 © StreamBase Systems, Inc.                    22	
  
Similar	
  OpOmizaOon’s	
  apply	
  to	
  GPUs	
  too!	
  




                               Copyright 2011 © StreamBase Systems, Inc.   23	
  
A	
  day	
  in	
  the	
  life..	
  Reliability	
  




                                         Copyright 2011 © StreamBase Systems, Inc.   24	
  
A	
  day	
  in	
  the	
  life..	
  Reliability	
  

  Hot/Hot,	
  Hot/Warm,	
  Hot/Cold,	
  None?!	
  




                                         Copyright 2011 © StreamBase Systems, Inc.   25	
  
A	
  day	
  in	
  the	
  life..	
  Reliability	
  




                                         Copyright 2011 © StreamBase Systems, Inc.   26	
  
A	
  day	
  in	
  the	
  life..	
  Reliable	
  CSMR	
  




                                      Copyright 2011 © StreamBase Systems, Inc.   27	
  
Agenda	
  

  What	
  is	
  ‘Complex	
  Event	
  Processing’	
  
     •  Specifically	
  flow	
  oriented	
  event	
  processing	
  (there	
  are	
  others)	
  
     •  Streams	
  &	
  Operators.	
  Windowing,	
  Branching,	
  Combining,	
  Extending	
  
  A	
  day	
  in	
  the	
  life	
  of	
  a	
  flow	
  programmer	
  
     •  RelaOvity	
  -­‐	
  Data	
  parallelism,	
  concurrency,	
  latency	
  &	
  throughput	
  
     •  ConOnuity	
  -­‐	
  ConOnuous	
  Streaming	
  Map	
  Reduce	
  
     •  Reliability	
  –	
  High	
  availability,	
  the	
  low	
  latency	
  way	
  
  Integra?on.	
  Erlang	
  –	
  the	
  ecosystem.	
  
     •  Calling	
  Erlang	
  from	
  StreamBase	
  –	
  Simple	
  &	
  windowed	
  funcOons	
  
     •  Client/Server	
  –	
  Pushing	
  events	
  to/from	
  StreamBase	
  
     •  RabbitMQ	
  -­‐	
  Messaging	
  
  TheC.	
  Erlang	
  –	
  the	
  inspira?on.	
  Paxos,	
  in	
  StreamBase	
  


                                           Copyright 2011 © StreamBase Systems, Inc.                 28	
  
Operators	
  –	
  Hi	
  Erlang.	
  Hello	
  StreamBase	
  

  Aggregate	
  –	
  A	
  window	
  of	
  moving	
  data	
  
     •    Time	
  based	
  –	
  eg:	
  the	
  last	
  10	
  seconds,	
  .001	
  seconds,	
  day	
  
     •    Field	
  based	
  –	
  eg:	
  historical	
  Ome	
  (Omestamp,	
  …)	
  
     •    Tuple	
  based	
  –	
  eg:	
  the	
  last	
  1000	
  tuples	
  
     •    Predicate	
  based	
  –	
  expressions	
  determine	
  when	
  to	
  open,	
  close	
  and/or	
  emit	
  
          interesOng	
  results	
  from	
  a	
  window	
  
  Mul?-­‐dimensional	
  
     •  Give	
  me	
  the	
  last	
  seconds	
  worth	
  of	
  events	
  or	
  the	
  last	
  10000,	
  whichever	
  
        happens	
  first	
  
  Grouping	
  
     •  ParOOon	
  by	
  Symbol	
  implies	
  a	
  window	
  per	
  Symbol	
  ‘concurrently	
  –	
  on	
  the	
  
        same	
  thread’	
  




                                              Copyright 2011 © StreamBase Systems, Inc.                                 29	
  
Windows	
  in	
  the	
  Wild	
  -­‐	
  #1	
  Riak	
  

  Riak	
  Core:	
  hLps://github.com/basho/riak_core	
  
     •  Mixes	
  the	
  ‘when’	
  window	
  dimension	
  (Ome)	
  with	
  the	
  what	
  ‘aggregaOon’	
  




                                         Copyright 2011 © StreamBase Systems, Inc.                          30	
  
Windows	
  in	
  the	
  Wild	
  -­‐	
  #2	
  tlack	
  on	
  BitBucket	
  

  Thomas	
  Lackner	
  -­‐	
  tlack	
  -­‐	
  EMA:	
  
     •  hjps://bitbucket.org/tlack/erlang-­‐exponenOal-­‐moving-­‐average/overview              	
  
     •  Mixes	
  the	
  ‘when’	
  window	
  dimension	
  (Ome)	
  with	
  the	
  what	
  ‘aggregaOon’	
  
        and	
  number	
  of	
  occurrences	
  ‘how	
  many’	
  




                                          Copyright 2011 © StreamBase Systems, Inc.                         31	
  
Embedding	
  Erlang	
  (Erjang)	
  




                                                                         Prepend the dir defining our
                                                                         behaviors to the code path




                             Copyright 2011 © StreamBase Systems, Inc.                                  32	
  
Define	
  Behavioral	
  Contracts	
  




                             Copyright 2011 © StreamBase Systems, Inc.   33	
  
Implement	
  &	
  Test	
  in	
  Erlang	
  (or	
  Erjang!)	
  




                                                                               Duh!	
  
                                                                               Typo!	
  




                                   Copyright 2011 © StreamBase Systems, Inc.       34	
  
Expose	
  to	
  StreamBase	
  [	
  Call	
  by	
  Behaviour/Mod]	
  #1	
  




                                Copyright 2011 © StreamBase Systems, Inc.   35	
  
Expose	
  To	
  StreamBase	
  [Call	
  by	
  Behaviour/Mod]	
  #2	
  




                              Copyright 2011 © StreamBase Systems, Inc.   36	
  
Use,	
  Deploy	
  &	
  Run	
  
                                                                                                   Wikipedia:	
  
                                                                                                    MACD	
  




                                                                             Example:

                                                                             Continuous Streaming
                                                                             Map/Reduce with 1-second
                                                                             MACD compression.
                                                                             Linearly SMP scalable.

                                                                             Just add boxes to scale!

                                 Copyright 2011 © StreamBase Systems, Inc.                                  37	
  
Run,	
  Rabbit,	
  Run,	
  Rabbit,	
  …	
  




                                   Copyright 2011 © StreamBase Systems, Inc.   38	
  
Agenda	
  

  What	
  is	
  ‘Complex	
  Event	
  Processing’	
  
     •  Specifically	
  flow	
  oriented	
  event	
  processing	
  (there	
  are	
  others)	
  
     •  Streams	
  &	
  Operators.	
  Windowing,	
  Branching,	
  Combining,	
  Extending	
  
  A	
  day	
  in	
  the	
  life	
  of	
  a	
  flow	
  programmer	
  
     •  RelaOvity	
  -­‐	
  Data	
  parallelism,	
  concurrency,	
  latency	
  &	
  throughput	
  
     •  ConOnuity	
  -­‐	
  ConOnuous	
  Streaming	
  Map	
  Reduce	
  
     •  Reliability	
  –	
  High	
  availability,	
  the	
  low	
  latency	
  way	
  
  Integra?on.	
  Erlang	
  –	
  the	
  ecosystem.	
  
     •  Calling	
  Erlang	
  from	
  StreamBase	
  –	
  Simple	
  &	
  windowed	
  funcOons	
  
     •  Client/Server	
  –	
  Pushing	
  events	
  to/from	
  StreamBase	
  
     •  RabbitMQ	
  -­‐	
  Messaging	
  
  TheC.	
  Erlang	
  –	
  the	
  inspira?on.	
  Paxos,	
  in	
  StreamBase	
  


                                           Copyright 2011 © StreamBase Systems, Inc.                 39	
  
SB	
  Paxos	
  –	
  Entrypoint	
  (cc	
  @kevsmith!)	
  




                                Copyright 2011 © StreamBase Systems, Inc.   40	
  
SB	
  Paxos	
  –	
  Autonomic,	
  Self	
  Healing	
  Ring	
  




                                  Copyright 2011 © StreamBase Systems, Inc.   41	
  
SB	
  Paxos	
  –	
  Generic	
  FSM	
  ‘Behaviour’	
  




                                 Copyright 2011 © StreamBase Systems, Inc.   42	
  
SB	
  Paxos	
  –	
  Generic	
  FSM	
  ‘Behaviour’	
  –	
  Paxos	
  FSM	
  
StateMap,State,TransiOon,NextState,AcOon,DescripOon,	
  
BasicPaxosMap,IniOal,Bootstrap,Proposer,Prepare,"..."	
  
BasicPaxosMap,IniOal,PromiseOk,Accepter,PromiseOk,"..."	
  
BasicPaxosMap,IniOal,PromiseNotOk,Done,PromiseNotOk,"..."	
  
BasicPaxosMap,IniOal,Accepted,Learner,Response,"When	
  ..."	
  
BasicPaxosMap,Proposer,Accept,Proposer,Accept,"..."	
  
BasicPaxosMap,Proposer,PromiseNotOk,Proposer,DoNothing,"..."	
  
BasicPaxosMap,Proposer,Response,Done,Gone,DoStop,"..."	
  
BasicPaxosMap,Accepter,Accept,Learner,Accept,"..."	
  
BasicPaxosMap,Accepter,Accepted,Learner,Response,"..."	
  
BasicPaxosMap,Learner,Accepted,Done,Response,"..."	
  
BasicPaxosMap,Learner,Done,Gone,DoStop,"..."	
  




                                    Copyright 2011 © StreamBase Systems, Inc.   43	
  
Shameless	
  Plugs	
  

  StreamBase	
  
     •  You	
  could	
  build	
  one	
  of	
  these	
  yourself,	
  or	
  use	
  ours…	
  
     •  Download	
  and	
  test	
  out	
  the	
  full	
  product	
  hjp:/www.streambase.com	
  
     •  Build	
  something	
  and	
  submit	
  to	
  the	
  StreamBase	
  Component	
  Exchange	
  
        hjp://sbx.streambase.com	
  	
  	
  
     •  Contact	
  us	
  to	
  buy	
  or	
  to	
  an	
  OEM	
  partner,	
  offices	
  London,	
  Boston,	
  New	
  York	
  
     •  We’re	
  hiring	
  
     •  We’re	
  training	
  
           •  hjp://www.streambase.com/developers-­‐training-­‐events.htm	
  

  DEBS	
  –	
  Distributed	
  Event	
  Based	
  Systems	
  
     •  Academic	
  (ACM)	
  Conference	
  outside	
  NYC	
  in	
  July	
  
  EPTS	
  –	
  Event	
  Processing	
  Technology	
  Society	
  
     •  hjp://ep-­‐ts.org	
  industry	
  consorOum	
  

                                         Ques?ons?	
  
                                              Copyright 2011 © StreamBase Systems, Inc.                                 44	
  
Acknowledgements	
  

  Erlang,	
  Erlang	
  Solu?ons,	
  Erlang	
  UG	
  London,	
  &	
  Erlang	
  Factory	
  
         •    hjp://www.erlang.org/	
  
         •    hjp://www.erlang-­‐soluOons.com/	
  	
  
         •    hjp://www.erlang-­‐soluOons.com/etc/usergroup/london	
  	
  
         •    hjp://www.erlang-­‐factory.com/	
  
  Erjang	
  –	
  The	
  Java	
  based	
  Erlang	
  Virtual	
  Machine	
  
         •  hjps://github.com/trifork/erjang/wiki/	
  	
  
  erlIDE	
  
         •  hjp://erlide.sourceforge.net/	
  	
  
  @?bbeLs	
  –	
  I	
  stole	
  borrowed	
  some	
  of	
  his	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  slides!	
  
  Download	
  StreamBase	
  and	
  tell	
  us	
  what	
  you	
  think:	
  
         •  hjp://www.streambase.com	
  


                                                                 Copyright 2011 © StreamBase Systems, Inc.                                                  45	
  
Download	
  StreamBase	
  and	
  More	
  InformaOon	
  
      hjp://www.streambase.com              	
  




           QuesOons?	
  


          +                            +                       =
                   Copyright 2011 © StreamBase Systems, Inc.       46	
  

More Related Content

PPTX
Data distribution in the cloud with Node.js
PDF
Achieving genuine elastic multitenancy with the Waratek Cloud VM for Java : J...
PDF
Communication Patterns Using Data-Centric Publish/Subscribe
PDF
Mobile Development Meets Semantic Technology
PDF
Master agile development and testing
PPTX
Cisco Presentation 1
PDF
Advancing the Traditional Enterprise: An EA Story
PDF
3 12-2013 performance-testing_service_virtualization
Data distribution in the cloud with Node.js
Achieving genuine elastic multitenancy with the Waratek Cloud VM for Java : J...
Communication Patterns Using Data-Centric Publish/Subscribe
Mobile Development Meets Semantic Technology
Master agile development and testing
Cisco Presentation 1
Advancing the Traditional Enterprise: An EA Story
3 12-2013 performance-testing_service_virtualization

What's hot (19)

PPTX
Cloud product presentation
PDF
Anywhere, anytime, any place - embrace the Martini Principle
PDF
Capture is Powerful - Harvey Spencer presentation to AIIM Ottawa Event Oct 27...
PDF
SoftLayer Presentation at Stifel Nicolaus Event Feb 10 2011 vfinal
PPT
Adding intelligence to your dcim solution rf code
PDF
Self-Service Access and Exploration of Big Data
PPTX
SKALI On The Cloud
PDF
Research on big data
PDF
Security data deluge
PDF
HP Storage Works -Clemes Esser
PDF
OMG DDS Interoperability Demo 2009
PDF
Hadoop for shanghai dev meetup
PDF
WebSocket - Enabling Technology for Dynamic Web Applications
PDF
Large-Scale Search Discovery Analytics with Hadoop, Mahout, Solr
PPT
To_Infinity_and_Beyond_Internet_Scale_Workloads_Data_Center_Design_v6
PDF
MarkLittle_EnterpriseMiddlewareForThe21stCentury
PDF
Managing content in_a_mobile_world
PDF
Introduction to Enterprise Cloud Economics
PDF
Tom Krcha - Future of Flash
Cloud product presentation
Anywhere, anytime, any place - embrace the Martini Principle
Capture is Powerful - Harvey Spencer presentation to AIIM Ottawa Event Oct 27...
SoftLayer Presentation at Stifel Nicolaus Event Feb 10 2011 vfinal
Adding intelligence to your dcim solution rf code
Self-Service Access and Exploration of Big Data
SKALI On The Cloud
Research on big data
Security data deluge
HP Storage Works -Clemes Esser
OMG DDS Interoperability Demo 2009
Hadoop for shanghai dev meetup
WebSocket - Enabling Technology for Dynamic Web Applications
Large-Scale Search Discovery Analytics with Hadoop, Mahout, Solr
To_Infinity_and_Beyond_Internet_Scale_Workloads_Data_Center_Design_v6
MarkLittle_EnterpriseMiddlewareForThe21stCentury
Managing content in_a_mobile_world
Introduction to Enterprise Cloud Economics
Tom Krcha - Future of Flash
Ad

Similar to Complex Er[jl]ang Processing with StreamBase (20)

PDF
StreamBase - Embedded Erjang - Erlang User Group London - 20th April 2011
PDF
InfoSphere Streams Technical Overview - Use Cases Big Data - Jerome CHAILLOUX
PPTX
Real-Time Data Flows with Apache NiFi
PDF
Hadoop in the Enterprise - Dr. Amr Awadallah @ Microstrategy World 2011
PDF
21st Century Service Oriented Architecture
PDF
Sybase Complex Event Processing
PDF
21st Century SOA
PPTX
Introducing SQL Server Data Services
PPTX
Introducing SQL Server Data Services
PDF
Łukasz Romaszewski on Internet of Things Raspberry Pi and Java Embedded JavaC...
PDF
Music city data Hail Hydrate! from stream to lake
PDF
SnapLogic corporate presentation
PPTX
Webinar: The Modern Streaming Data Stack with Kinetica & StreamSets
PDF
21st Century SOA
PDF
Jimwebber soa
PDF
Cloud Computing - Making IT Simple
PDF
Streaming Solutions for Real time problems
PPTX
SQL and NoSQL in SQL Server
PDF
Hadoop World 2011: How Hadoop Revolutionized Business Intelligence and Advanc...
PDF
Best Practices For Building and Operating A Managed Data Lake - StampedeCon 2016
StreamBase - Embedded Erjang - Erlang User Group London - 20th April 2011
InfoSphere Streams Technical Overview - Use Cases Big Data - Jerome CHAILLOUX
Real-Time Data Flows with Apache NiFi
Hadoop in the Enterprise - Dr. Amr Awadallah @ Microstrategy World 2011
21st Century Service Oriented Architecture
Sybase Complex Event Processing
21st Century SOA
Introducing SQL Server Data Services
Introducing SQL Server Data Services
Łukasz Romaszewski on Internet of Things Raspberry Pi and Java Embedded JavaC...
Music city data Hail Hydrate! from stream to lake
SnapLogic corporate presentation
Webinar: The Modern Streaming Data Stack with Kinetica & StreamSets
21st Century SOA
Jimwebber soa
Cloud Computing - Making IT Simple
Streaming Solutions for Real time problems
SQL and NoSQL in SQL Server
Hadoop World 2011: How Hadoop Revolutionized Business Intelligence and Advanc...
Best Practices For Building and Operating A Managed Data Lake - StampedeCon 2016
Ad

More from darach (11)

PDF
Thing. An unexpected journey. Devoxx UK 2014
PDF
FunctionalJS - May 2014 - Streams
PDF
Deconstructing Lambda
PDF
Streams and Things
PDF
Big Data, Mob Scale.
PDF
Meta Programming with Streams and Pipes
PDF
Erlang/Sapiens
PDF
QCON London 2013
PDF
EFL Munich - February 2013 - "Conversational Big Data with Erlang"
PDF
Streamy, Pipy, Analyticy
PDF
Tech mesh london 2012
Thing. An unexpected journey. Devoxx UK 2014
FunctionalJS - May 2014 - Streams
Deconstructing Lambda
Streams and Things
Big Data, Mob Scale.
Meta Programming with Streams and Pipes
Erlang/Sapiens
QCON London 2013
EFL Munich - February 2013 - "Conversational Big Data with Erlang"
Streamy, Pipy, Analyticy
Tech mesh london 2012

Recently uploaded (20)

PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Advanced Soft Computing BINUS July 2025.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPT
Teaching material agriculture food technology
PDF
Advanced IT Governance
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
Unlocking AI with Model Context Protocol (MCP)
Advanced Soft Computing BINUS July 2025.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
Chapter 3 Spatial Domain Image Processing.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
20250228 LYD VKU AI Blended-Learning.pptx
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Dropbox Q2 2025 Financial Results & Investor Presentation
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Teaching material agriculture food technology
Advanced IT Governance
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Advanced methodologies resolving dimensionality complications for autism neur...
Reach Out and Touch Someone: Haptics and Empathic Computing
Spectral efficient network and resource selection model in 5G networks
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Network Security Unit 5.pdf for BCA BBA.

Complex Er[jl]ang Processing with StreamBase

  • 1. Darach  Ennis  (darach@streambase.com)  @darachennis   StreamBase  Systems   Erlang  Factory  London  -­‐    June  10th  2011   Complex  Er[jl]ang  Processing  with  StreamBase:   A  DSL  for  Low  Latency  High  Frequency  CompuOng   + + = Copyright 2011 © StreamBase Systems, Inc. 1  
  • 2. Agenda     What  is  ‘Complex  Event  Processing’   •  Specifically  flow  oriented  event  processing  (there  are  others)   •  Streams  &  Operators.  Windowing,  Branching,  Combining,  Extending     A  day  in  the  life  of  a  flow  programmer   •  RelaOvity  -­‐  Data  parallelism,  concurrency,  latency  &  throughput   •  ConOnuity  -­‐  ConOnuous  Streaming  Map  Reduce   •  Reliability  –  High  availability,  the  low  latency  way   •  Flow,  meets  FuncOon.  Embed  Erlang  in  process  via  Erjang     Integra?on.  Erlang  –  the  ecosystem.   •  Calling  Erlang  from  StreamBase  –  Simple  &  windowed  funcOons   •  Client/Server  –  Pushing  events  to/from  StreamBase   •  RabbitMQ  -­‐  Messaging     TheC.  Erlang  –  the  inspira?on.  Paxos,  in  StreamBase   Copyright 2011 © StreamBase Systems, Inc. 2  
  • 3. High  Level  DSLs  :  Myth  Vs  Reality   Myth:  High  level  domain   specific  languages  are   too  slow  for  HFT.   Reality:  High  level  domain   specific  languages  can  deliver   beLer  performance  than   system  programming  languages   when  tailored  to  a  specific  task.   Copyright 2011 © StreamBase Systems, Inc. 3  
  • 4. Complex  Event  Processing  aka  Event  Processing     SoCware  organized  by  events  (cf:  object/func?on  oriented)   •  What’s  an  event?  What’s  an  object?   •  Something  that  can  trigger  processing,  can  include  data.   •  Naturally  but  not  usually  represents  a  “real  world”  events  &  observaOons.     Complex  Event  Processing  PlaTorms   •  Soeware  stack  for  event  based  systems,  event  driven  architectures   •  Event  Programming  Language  –  SQL-­‐based,  Rules-­‐based,  or  State-­‐based   •  Commercial  and  open  source:  StreamBase,  Progress,  Microsoe,  IBM,   Oracle,  SAP,  Esper,  Drools  and  many  more     Adopted  in  financial  services  and  other  markets   •  System  monitoring,  industrial  process  control,  logisOcs,  defense/ intelligence     Other  Event  Processing  Approaches:   •  Erlang,  Scala/Akka,  Actors,  node.js,  .NET  Rx   Copyright 2011 © StreamBase Systems, Inc. 4  
  • 5. What  does  a  CEP  DSL  or  Language  offer?     Con?nuously  Observe,  Orient,  Decide  Act  (OODA)  on  event   streams   Wikipedia:   •  ConOnuous  Incremental  Query   John  Boyd,   •  Pajern  matching  within  or  across  streams   OODA  Loop   •  Branch  –  Split,  Causal  Split,  Filter.   •  Combine  -­‐  Semi-­‐Join,  Union,  Gather,  Merge,  Join,  Pajern   •  Windows  –  Process  sets  of  streaming  data   •  Sliding  or  Tumbling,  Overlapping  or  Non-­‐Overlapping,  Gaps  or  No  Gaps   •  Finite  (1  second,  1000  tuples),  Infinite   •  Emission  Policies:  On  Close,  Every  odd  message   •  Predicate  based  –  Roll  your  own  window  type   •  State  Management  –  In  memory,  CSV  files,  CSV  sockets,  RDBMS,  Parallel   DBMSs,  Column  Stores,  KV  stores,  NoSQL,  NewSQL…   •  Nice  to  have:     •  DeclaraOve  concurrency,  Interface  Polymorphism,  DistribuOon,  Extensible   Copyright 2011 © StreamBase Systems, Inc. 5  
  • 6. Challenges  for  CEP     ‘Über’  Ultra  Low  Latency?   •  Sub-­‐milli  is  standard,  sub-­‐100-­‐micro  is  desirable.  Less  is  more!     Large  Data  Volumes   •  Hundreds  of  thousands  of  events,  thousands  of  decisions,  per  thread.   •  Big  Data.  ~Hundreds  of  SMP  CEP  nodes.     Demanding  Opera?onal  Environment   •  24x7,  365  –  in  criOcal  environments  (trading,  surveillance,  uOliOes)     Sophis?cated  Data  Processing  (some?mes)   •  OpOons  pricing,  yield  curves,  risk  metrics,  smart  grid  capacity  planning,   fraud  detecOon.     How  it’s  done  (QCON  London  2011):   •  How  LMAX  did  it?  hjp://bit.ly/fUeS0P   •  How  we  did  it?  hjp://bit.ly/hM6NAP  <-­‐  Our  CTO  Richard  Tibbejs  talk   Copyright 2011 © StreamBase Systems, Inc. 6  
  • 7. StreamBase  Event  Processing  Plauorm   Studio  Integrated  Development  Environment   Visualiza?on   Developer  Studio   Graphical  StreamSQL  for  developing,     back  tesOng  and  deploying  applicaOons.       StreamBase   StreamBase   Component   Frameworks     Exchange   ApplicaOons   Input  Adapter(s)   Inject  streaming  (market  data)   Adapters   Adapters   and  staOc  (reference  data)   StreamBase  Server     sources.   Event  Processing  Server   Output  Adapter(s)   High  performance  opOmized  engine   Send  results  to  systems,  users,  user   can  process  events  at  market  data   screens  and  databases.   speeds.   Copyright 2011 © StreamBase Systems, Inc. 7  
  • 8. How  did  we  do  it?     Compila?on  and  Sta?c  Analysis   •  Design  the  language  for  it     Modular  abstrac?on,  interfaces   •  Quants  and  Developers  Collaborate,  share  code     Bytecode  genera?on  and  the  Janino  compiler   •  OpOmized  bytecodes,  in-­‐memory  generaOon       Garbage  op?miza?on   •  Pooling,  data  class,  invasive  collecOons     Integra?ons,  C++  and  Java  plugins   •  Efficient  naOve  interfaces,  Hardware  acceleraOon     Adapter  API,  FIX  Messaging   •  Threading  and  API  structure  for  ultra  low  latency     Parallelism,  Clustering,  Lanes  and  Tiers   •  Scalability,  with  a  latency  bias.     Modularity  through  Named  Data  Formats,  Schemas   •  Sharing  data  and  semanOcs  between  apps   Copyright 2011 © StreamBase Systems, Inc. 8  
  • 9. StreamBase  StreamSQL  EventFlow   Rapid  Deployment   &  Unit  TesOng   Modularity  &   Polymorphism   Interfaces  &   Off  The  Shelf   Off  The  Shelf   Extension  Points   Business  Logic   ConnecOvity   Copyright 2011 © StreamBase Systems, Inc. 9  
  • 10. Operators  –  Hi  Erlang.  Hello  StreamBase   Did  you  just  tell   me  to  go  flow   myself?   Copyright 2011 © StreamBase Systems, Inc. 10  
  • 11. Agenda     What  is  ‘Complex  Event  Processing’   •  Specifically  flow  oriented  event  processing  (there  are  others)   •  Streams  &  Operators.  Windowing,  Branching,  Combining,  Extending     A  day  in  the  life  of  a  flow  programmer   •  RelaOvity  -­‐  Data  parallelism,  concurrency,  latency  &  throughput   •  ConOnuity  -­‐  ConOnuous  Streaming  Map  Reduce   •  Reliability  –  High  availability,  the  low  latency  way   •  Flow,  meets  FuncOon.  Embed  Erlang  in  process  via  Erjang     Integra?on.  Erlang  –  the  ecosystem.   •  Calling  Erlang  from  StreamBase  –  Simple  &  windowed  funcOons   •  Client/Server  –  Pushing  events  to/from  StreamBase   •  RabbitMQ  -­‐  Messaging     TheC.  Erlang  –  the  inspira?on.  Paxos,  in  StreamBase   Copyright 2011 © StreamBase Systems, Inc. 11  
  • 12. A  day  in  the  life…  Why  a  DSL?     High  level  –  Windowing,  Combina?on  &  PaLern  Matching   Streams     Graphical  –  ‘See’  the  flow,  dependencies,  pathways     Fast,  Flexible  SDLC  –  Deploy  new  algorithms,  con?nuously     Understandable  –  Rise  to  the  abstrac?on     Flexible   Copyright 2011 © StreamBase Systems, Inc. 12  
  • 13. A  day  in  the  life..  More  is  more!   Copyright 2011 © StreamBase Systems, Inc. 13  
  • 14. Make  it  work.  Measure  it.  -­‐  Baseline  ‘Noop’  Performance   WARNING:  Micro-­‐ benchmark.   YMMV   Copyright 2011 © StreamBase Systems, Inc. 14  
  • 15. Concurrency  –  Baseline  -­‐  Results   Nice.  1.1  million   events/sec   Copyright 2011 © StreamBase Systems, Inc. 15  
  • 16. Parallelize  it  –  The  ‘Convenient,  but  incorrect’  way   Execution Order & Concurrency: Rule 1 – Each event processed to completion left-right Rule 2 – Branches processed sequentially Rule 3 – Outputs are processed sequentially Rule 4 – Module output processed to completion immediately Rule 5 – One operator executed at a time Copyright 2011 © StreamBase Systems, Inc. 16  
  • 17. Gah!  WTF?!   Copyright 2011 © StreamBase Systems, Inc. 17  
  • 18. OpOmize  it!  ObservaOon  #1   Measure  the  cost   of  thread  context   switches.  Dodge   &  Burn!   Copyright 2011 © StreamBase Systems, Inc. 18  
  • 19. OpOmize  it!  ObservaOon  #2  –  It’s  Map/Combine/Reduce   Copyright 2011 © StreamBase Systems, Inc. 19  
  • 20. CSMR  –  A  ‘pajern’  for  low  latency  high  throughput?   Copyright 2011 © StreamBase Systems, Inc. 20  
  • 21. CSMR  –  A  ‘pajern’  for  low  latency  high  throughput?  Yup!   25   20   20   20   18   Millions  of  tuples  /  second   Throughput  (Mtps)     15   Across  Region   10   10   9.4   Within  Region   8   8   5   4   4   4   0   Gather   Merge   Branch  &  Join   Filter  Even  Random   Baseline  (Noop)   Benchmark  HW:  Dell  RS510,  8  core,  32  GB  RAM,  2.4GHz  IA-­‐64,  OS:  RHEL  5u3,  SB  7.0.1.2   Copyright 2011 © StreamBase Systems, Inc. 21  
  • 22. CSMR  +  GPUs  /  FPGAs?  Sure!   We can build on SMP and cluster wide distribution algorithms to further optimize interactions with accelerated compute technologies. We can exploit accelerated hardware messaging where regular network IO is insufficient for distribution results over 1Ge or regular networking technologies. The pattern above is a continuous streaming variant of Map/Reduce in EventFlow. Copyright 2011 © StreamBase Systems, Inc. 22  
  • 23. Similar  OpOmizaOon’s  apply  to  GPUs  too!   Copyright 2011 © StreamBase Systems, Inc. 23  
  • 24. A  day  in  the  life..  Reliability   Copyright 2011 © StreamBase Systems, Inc. 24  
  • 25. A  day  in  the  life..  Reliability     Hot/Hot,  Hot/Warm,  Hot/Cold,  None?!   Copyright 2011 © StreamBase Systems, Inc. 25  
  • 26. A  day  in  the  life..  Reliability   Copyright 2011 © StreamBase Systems, Inc. 26  
  • 27. A  day  in  the  life..  Reliable  CSMR   Copyright 2011 © StreamBase Systems, Inc. 27  
  • 28. Agenda     What  is  ‘Complex  Event  Processing’   •  Specifically  flow  oriented  event  processing  (there  are  others)   •  Streams  &  Operators.  Windowing,  Branching,  Combining,  Extending     A  day  in  the  life  of  a  flow  programmer   •  RelaOvity  -­‐  Data  parallelism,  concurrency,  latency  &  throughput   •  ConOnuity  -­‐  ConOnuous  Streaming  Map  Reduce   •  Reliability  –  High  availability,  the  low  latency  way     Integra?on.  Erlang  –  the  ecosystem.   •  Calling  Erlang  from  StreamBase  –  Simple  &  windowed  funcOons   •  Client/Server  –  Pushing  events  to/from  StreamBase   •  RabbitMQ  -­‐  Messaging     TheC.  Erlang  –  the  inspira?on.  Paxos,  in  StreamBase   Copyright 2011 © StreamBase Systems, Inc. 28  
  • 29. Operators  –  Hi  Erlang.  Hello  StreamBase     Aggregate  –  A  window  of  moving  data   •  Time  based  –  eg:  the  last  10  seconds,  .001  seconds,  day   •  Field  based  –  eg:  historical  Ome  (Omestamp,  …)   •  Tuple  based  –  eg:  the  last  1000  tuples   •  Predicate  based  –  expressions  determine  when  to  open,  close  and/or  emit   interesOng  results  from  a  window     Mul?-­‐dimensional   •  Give  me  the  last  seconds  worth  of  events  or  the  last  10000,  whichever   happens  first     Grouping   •  ParOOon  by  Symbol  implies  a  window  per  Symbol  ‘concurrently  –  on  the   same  thread’   Copyright 2011 © StreamBase Systems, Inc. 29  
  • 30. Windows  in  the  Wild  -­‐  #1  Riak     Riak  Core:  hLps://github.com/basho/riak_core   •  Mixes  the  ‘when’  window  dimension  (Ome)  with  the  what  ‘aggregaOon’   Copyright 2011 © StreamBase Systems, Inc. 30  
  • 31. Windows  in  the  Wild  -­‐  #2  tlack  on  BitBucket     Thomas  Lackner  -­‐  tlack  -­‐  EMA:   •  hjps://bitbucket.org/tlack/erlang-­‐exponenOal-­‐moving-­‐average/overview   •  Mixes  the  ‘when’  window  dimension  (Ome)  with  the  what  ‘aggregaOon’   and  number  of  occurrences  ‘how  many’   Copyright 2011 © StreamBase Systems, Inc. 31  
  • 32. Embedding  Erlang  (Erjang)   Prepend the dir defining our behaviors to the code path Copyright 2011 © StreamBase Systems, Inc. 32  
  • 33. Define  Behavioral  Contracts   Copyright 2011 © StreamBase Systems, Inc. 33  
  • 34. Implement  &  Test  in  Erlang  (or  Erjang!)   Duh!   Typo!   Copyright 2011 © StreamBase Systems, Inc. 34  
  • 35. Expose  to  StreamBase  [  Call  by  Behaviour/Mod]  #1   Copyright 2011 © StreamBase Systems, Inc. 35  
  • 36. Expose  To  StreamBase  [Call  by  Behaviour/Mod]  #2   Copyright 2011 © StreamBase Systems, Inc. 36  
  • 37. Use,  Deploy  &  Run   Wikipedia:   MACD   Example: Continuous Streaming Map/Reduce with 1-second MACD compression. Linearly SMP scalable. Just add boxes to scale! Copyright 2011 © StreamBase Systems, Inc. 37  
  • 38. Run,  Rabbit,  Run,  Rabbit,  …   Copyright 2011 © StreamBase Systems, Inc. 38  
  • 39. Agenda     What  is  ‘Complex  Event  Processing’   •  Specifically  flow  oriented  event  processing  (there  are  others)   •  Streams  &  Operators.  Windowing,  Branching,  Combining,  Extending     A  day  in  the  life  of  a  flow  programmer   •  RelaOvity  -­‐  Data  parallelism,  concurrency,  latency  &  throughput   •  ConOnuity  -­‐  ConOnuous  Streaming  Map  Reduce   •  Reliability  –  High  availability,  the  low  latency  way     Integra?on.  Erlang  –  the  ecosystem.   •  Calling  Erlang  from  StreamBase  –  Simple  &  windowed  funcOons   •  Client/Server  –  Pushing  events  to/from  StreamBase   •  RabbitMQ  -­‐  Messaging     TheC.  Erlang  –  the  inspira?on.  Paxos,  in  StreamBase   Copyright 2011 © StreamBase Systems, Inc. 39  
  • 40. SB  Paxos  –  Entrypoint  (cc  @kevsmith!)   Copyright 2011 © StreamBase Systems, Inc. 40  
  • 41. SB  Paxos  –  Autonomic,  Self  Healing  Ring   Copyright 2011 © StreamBase Systems, Inc. 41  
  • 42. SB  Paxos  –  Generic  FSM  ‘Behaviour’   Copyright 2011 © StreamBase Systems, Inc. 42  
  • 43. SB  Paxos  –  Generic  FSM  ‘Behaviour’  –  Paxos  FSM   StateMap,State,TransiOon,NextState,AcOon,DescripOon,   BasicPaxosMap,IniOal,Bootstrap,Proposer,Prepare,"..."   BasicPaxosMap,IniOal,PromiseOk,Accepter,PromiseOk,"..."   BasicPaxosMap,IniOal,PromiseNotOk,Done,PromiseNotOk,"..."   BasicPaxosMap,IniOal,Accepted,Learner,Response,"When  ..."   BasicPaxosMap,Proposer,Accept,Proposer,Accept,"..."   BasicPaxosMap,Proposer,PromiseNotOk,Proposer,DoNothing,"..."   BasicPaxosMap,Proposer,Response,Done,Gone,DoStop,"..."   BasicPaxosMap,Accepter,Accept,Learner,Accept,"..."   BasicPaxosMap,Accepter,Accepted,Learner,Response,"..."   BasicPaxosMap,Learner,Accepted,Done,Response,"..."   BasicPaxosMap,Learner,Done,Gone,DoStop,"..."   Copyright 2011 © StreamBase Systems, Inc. 43  
  • 44. Shameless  Plugs     StreamBase   •  You  could  build  one  of  these  yourself,  or  use  ours…   •  Download  and  test  out  the  full  product  hjp:/www.streambase.com   •  Build  something  and  submit  to  the  StreamBase  Component  Exchange   hjp://sbx.streambase.com       •  Contact  us  to  buy  or  to  an  OEM  partner,  offices  London,  Boston,  New  York   •  We’re  hiring   •  We’re  training   •  hjp://www.streambase.com/developers-­‐training-­‐events.htm     DEBS  –  Distributed  Event  Based  Systems   •  Academic  (ACM)  Conference  outside  NYC  in  July     EPTS  –  Event  Processing  Technology  Society   •  hjp://ep-­‐ts.org  industry  consorOum   Ques?ons?   Copyright 2011 © StreamBase Systems, Inc. 44  
  • 45. Acknowledgements     Erlang,  Erlang  Solu?ons,  Erlang  UG  London,  &  Erlang  Factory   •  hjp://www.erlang.org/   •  hjp://www.erlang-­‐soluOons.com/     •  hjp://www.erlang-­‐soluOons.com/etc/usergroup/london     •  hjp://www.erlang-­‐factory.com/     Erjang  –  The  Java  based  Erlang  Virtual  Machine   •  hjps://github.com/trifork/erjang/wiki/       erlIDE   •  hjp://erlide.sourceforge.net/       @?bbeLs  –  I  stole  borrowed  some  of  his                                        slides!     Download  StreamBase  and  tell  us  what  you  think:   •  hjp://www.streambase.com   Copyright 2011 © StreamBase Systems, Inc. 45  
  • 46. Download  StreamBase  and  More  InformaOon   hjp://www.streambase.com   QuesOons?   + + = Copyright 2011 © StreamBase Systems, Inc. 46