SlideShare a Scribd company logo
1 of 44
Download to read offline
FUNCTIONAL
DEVOPSEVENT PROCESSING IN CLOJURE
Andy Marks
@andee_marks
amarks@thoughtworks.com
Background
we all code!
(prn “Hello World”)
(ns hello.core)
(defn -main []
(prn “Hello World”))
Jetty
(ns hello.core)
(defn -main []
(prn “Hello World”))
✓access requests
✓queues
✓sessions
AWS EC2
Jetty
(ns hello.core)
(defn -main []
(prn “Hello World”))
✓disk
✓network interfaces
✓memory
✓cores/cpus
AWS EC2
Jetty
AWS EC2
Jetty
AWS EC2
Jetty
DNS
(Master)
DNS
(Slave)
✓records
✓replication
✓resolution
WS EC2
Jetty
AWS EC2
Jetty
AWS EC2
Jetty
DNS
(Master)
DNS
DB
✓performance
✓indexing
✓locking
✓connections
WS EC2
Jetty
AWS EC2
Jetty
AWS EC2
Jetty
DNS
(Master)
DNS
DB
Load Balancer
AWS EC2
Jetty
AWS EC2
Jetty
✓connections
✓DoS
✓Clients
WS EC2
Jetty
AWS EC2
Jetty
AWS EC2
Jetty
DNS
(Master)
DNS
DB
Load Balancer
AWS EC2
Jetty
AWS EC2
Jetty
MessageQueue
✓queues
✓timeouts
that is a lot of
information…
from a lot of
different places
this is a problem
this is the problem
Riemann helps
solve
Riemann is
written in
Clojure
52 source files
7256 lines
377 functions
30 macros
Riemann is written
and configured
in Clojure
And so… to Riemann
kylekingsbury(@aphyr)
OVERVIEW
Correlate events from disparate
sources
What is the latency of the web servers when the DB
servers are generating timeouts?
Filter events based on key criteria Ignore all network events with a normal status
Aggregate events to perform
statistical analysis (e.g., percentiles)
What is the average response rate for 95% of requests?
Monitor status of sources by
availability of events
Which services haven’t sent any events for the last 5
minutes?
Route event streams to multiple
consumers
Send all error events from DB servers to the DBA team
as well as the main operational dashboards
SAMPLE RIEMANN USE CASES
i = f(e)
e: thundering herd of events
i: information ready for downstream processing
Hypothesis
Event processing is function
application at large scale… using
Clojure to build/configure Riemann is a
logical choice.
(defrecord Event
[
service
state
description
metric
tags
time
ttl
KEY CONCEPTS: EVENTS
“reg1.foo.bar”
“reg-service http”
“ok”
“apache-log”
201
[“reg1” “http”]
104534892
60
riemannsource
KEY CONCEPTS: STREAMS
(logging/init {:file "riemann.log" :console true})
(instrumentation {:interval 5}) ;; self monitor every 5 seconds
(periodically-expire 1) ;; check for expired events every second
(tcp-server)
(repl-server)
(streams
;; insert magic here!!!
prn)
riemannconfig
KEY CONCEPTS: INDEX
flow of events
index
riemann
process
General FP goodness
HOMOICONICITY
“[It] is where a program's source code is written
as a basic data structure that the
programming language knows how to access.”
Wikipedia
(defn validate-config
[file]
(try
(read-strings (slurp file))
(catch clojure.lang.LispReader$ReaderException e
(throw (logging/nice-syntax-error e file)))))
riemannsource
HIGHER ORDER FUNCTIONS
“A stream is just a function that takes a variable
number of child streams and returns a function
that takes an event and responds to the event it is passed
when it is invoked.”
http://riemann.io/quickstart.html
“a higher-order function… does at least one of the
following:
[1] takes one or more functions as an input,
[2] outputs a function”
Wikipedia
HIGHER ORDER FUNCTIONS
“A stream is just a function that takes a variable
number of child streams and returns a function
that takes an event and responds to the event it is passed
when it is invoked.”
http://riemann.io/quickstart.html
(streams
(rate 5 prn)
)
riemannconfig
IMMUTABILITY
“Streams ‘change’ events by sending altered,
shared-structure *copies* of events
downstream.”
http://riemann.io/howto.html#split-streams
(streams
(where (host "db04")
(with :service "foo" prn)
(with :service "bar" prn))
)
riemannconfig
Specific Clojure
goodness
“clojure's remarkably fast for
what it is, sexprs make the
tree structure of the streams
visually apparent, it makes
writing the concurrent algos
much simpler, and macros
allow us to express things
like 'by and 'pipe in ways
that would be awkward in
other languages without
building our own AST &
interpreter or transpiler,
etc.”
“clojure's remarkably fast for
what it is, sexprs make the
tree structure of the streams
visually apparent, it makes
writing the concurrent algos
much simpler, and macros
allow us to express things
like 'by and 'pipe in ways
that would be awkward in
other languages without
building our own AST &
interpreter or transpiler,
etc.”
@APHYR SAID…
S-EXPRESSIONS
“a notation for nested list (tree-structured)
data… popularised by the programming
language Lisp”
Wikipedia
S-EXPRESSIONS
(streams
(where (and (service #"^riak")
(state “critical”))
(email “delacroix@vonbraun.com"))
)
1 Filter certain events…
2 Let people know…
1
2
riemannconfig
“make the tree structure of the
streams visually apparent”
3
1
2
S-EXPRESSIONS
1 Split on event fields…
2 Detect state changes…
3 Collate and email
(streams
(by [:host :service]
(changed :state
(rollup 5 3600
(email “delacroix@vonbraun.com"))))
)
riemannconfig
“make the tree structure of the
streams visually apparent”
MACROS
(defmacro pipe
[marker & stages]
`(let [~@(->> stages
reverse
(interpose marker)
(cons marker))]
~marker))
(streams
(pipe -
(splitp = service
"http req rate" -
"0mq req rate" (scale 2 -))
(rate 5
(graphite {:host “127.0.0.1” :port 2003})))
)
riemannconfig
riemannsource
MACROS: PIPE
(streams
(let [aggregate
(rate 5
(graphite {:host “127.0.0.1” :port 2003}))]
(splitp = service
"http req rate" aggregate
"0mq req rate" (scale 2 aggregate)))
)
or
riemannconfigriemannconfig
(streams
(pipe -
(splitp = service
"http req rate" -
"0mq req rate" (scale 2 -))
(rate 5
(graphite {:host “127.0.0.1” :port 2003})))
)
Conclusion
Hypothesis
Event processing is function
application at large scale: using Clojure
to build/configure Riemann is a logical
choice.
homoiconicity
higherorderfunctions
s-expressions
macros
immutability
CLOJURE AD ABSURDUM
(defn do-you-trust-me? [event]
(prn (load-string (:description event))))
(streams
(where (service "event-gen")
do-you-trust-me?)
)
(ns event-gen.core
(:require [riemann.client :refer :all])
(:gen-class :main true))
(defn -main [& args]
(let [c (tcp-client {:host "127.0.0.1"})]
(send-event c
{:service "event-gen" :description "(+ 1 1)"})
(close-client c)))
riemannclientriemannconfig
CLOJURE AD ABSURDUM
(defrecord Event
[service
description
])
“event-gen”
“(+ 1 1)”
Riemann
(Clojure)
riemann.config
(Clojure)
Client
(Clojure)
Clojure
=> “2”
THANKS
Andy Marks
@andee_marks
amarks@thoughtworks.com

More Related Content

What's hot

Terraform 0.9 + good practices
Terraform 0.9 + good practicesTerraform 0.9 + good practices
Terraform 0.9 + good practicesRadek Simko
 
Mito, a successor of Integral
Mito, a successor of IntegralMito, a successor of Integral
Mito, a successor of Integralfukamachi
 
Streams are Awesome - (Node.js) TimesOpen Sep 2012
Streams are Awesome - (Node.js) TimesOpen Sep 2012 Streams are Awesome - (Node.js) TimesOpen Sep 2012
Streams are Awesome - (Node.js) TimesOpen Sep 2012 Tom Croucher
 
PowerShell Technical Overview
PowerShell Technical OverviewPowerShell Technical Overview
PowerShell Technical Overviewallandcp
 
CQL: SQL In Cassandra
CQL: SQL In CassandraCQL: SQL In Cassandra
CQL: SQL In CassandraEric Evans
 
What's new in Ansible 2.0
What's new in Ansible 2.0What's new in Ansible 2.0
What's new in Ansible 2.0Allan Denot
 
Hopping in clouds: a tale of migration from one cloud provider to another
Hopping in clouds: a tale of migration from one cloud provider to anotherHopping in clouds: a tale of migration from one cloud provider to another
Hopping in clouds: a tale of migration from one cloud provider to anotherMichele Orselli
 
Docker tips & tricks
Docker  tips & tricksDocker  tips & tricks
Docker tips & tricksDharmit Shah
 
Dexador Rises
Dexador RisesDexador Rises
Dexador Risesfukamachi
 
Fluentd - CNCF Paris
Fluentd - CNCF ParisFluentd - CNCF Paris
Fluentd - CNCF ParisHorgix
 
Php assíncrono com_react_php
Php assíncrono com_react_phpPhp assíncrono com_react_php
Php assíncrono com_react_phpRenato Lucena
 
Phoenix for Rails Devs
Phoenix for Rails DevsPhoenix for Rails Devs
Phoenix for Rails DevsDiacode
 
Git/Github/Bitbucket@TalkIt. Humber college.
Git/Github/Bitbucket@TalkIt. Humber college.Git/Github/Bitbucket@TalkIt. Humber college.
Git/Github/Bitbucket@TalkIt. Humber college.Andrew Romanenco
 
From nothing to Prometheus : one year after
From nothing to Prometheus : one year afterFrom nothing to Prometheus : one year after
From nothing to Prometheus : one year afterAntoine Leroyer
 
Node.js - A practical introduction (v2)
Node.js  - A practical introduction (v2)Node.js  - A practical introduction (v2)
Node.js - A practical introduction (v2)Felix Geisendörfer
 
Fluentd v0.12 master guide
Fluentd v0.12 master guideFluentd v0.12 master guide
Fluentd v0.12 master guideN Masahiro
 

What's hot (20)

Terraform 0.9 + good practices
Terraform 0.9 + good practicesTerraform 0.9 + good practices
Terraform 0.9 + good practices
 
Mito, a successor of Integral
Mito, a successor of IntegralMito, a successor of Integral
Mito, a successor of Integral
 
Streams are Awesome - (Node.js) TimesOpen Sep 2012
Streams are Awesome - (Node.js) TimesOpen Sep 2012 Streams are Awesome - (Node.js) TimesOpen Sep 2012
Streams are Awesome - (Node.js) TimesOpen Sep 2012
 
PowerShell Technical Overview
PowerShell Technical OverviewPowerShell Technical Overview
PowerShell Technical Overview
 
CQL: SQL In Cassandra
CQL: SQL In CassandraCQL: SQL In Cassandra
CQL: SQL In Cassandra
 
What's new in Ansible 2.0
What's new in Ansible 2.0What's new in Ansible 2.0
What's new in Ansible 2.0
 
Hopping in clouds: a tale of migration from one cloud provider to another
Hopping in clouds: a tale of migration from one cloud provider to anotherHopping in clouds: a tale of migration from one cloud provider to another
Hopping in clouds: a tale of migration from one cloud provider to another
 
Docker tips & tricks
Docker  tips & tricksDocker  tips & tricks
Docker tips & tricks
 
Tuning Solr for Logs
Tuning Solr for LogsTuning Solr for Logs
Tuning Solr for Logs
 
Dexador Rises
Dexador RisesDexador Rises
Dexador Rises
 
Fluentd - CNCF Paris
Fluentd - CNCF ParisFluentd - CNCF Paris
Fluentd - CNCF Paris
 
Php assíncrono com_react_php
Php assíncrono com_react_phpPhp assíncrono com_react_php
Php assíncrono com_react_php
 
Phoenix for Rails Devs
Phoenix for Rails DevsPhoenix for Rails Devs
Phoenix for Rails Devs
 
Using Logstash, elasticsearch & kibana
Using Logstash, elasticsearch & kibanaUsing Logstash, elasticsearch & kibana
Using Logstash, elasticsearch & kibana
 
Git/Github/Bitbucket@TalkIt. Humber college.
Git/Github/Bitbucket@TalkIt. Humber college.Git/Github/Bitbucket@TalkIt. Humber college.
Git/Github/Bitbucket@TalkIt. Humber college.
 
Subversion To Mercurial
Subversion To MercurialSubversion To Mercurial
Subversion To Mercurial
 
From nothing to Prometheus : one year after
From nothing to Prometheus : one year afterFrom nothing to Prometheus : one year after
From nothing to Prometheus : one year after
 
Node.js - A practical introduction (v2)
Node.js  - A practical introduction (v2)Node.js  - A practical introduction (v2)
Node.js - A practical introduction (v2)
 
Nodejs - A quick tour (v6)
Nodejs - A quick tour (v6)Nodejs - A quick tour (v6)
Nodejs - A quick tour (v6)
 
Fluentd v0.12 master guide
Fluentd v0.12 master guideFluentd v0.12 master guide
Fluentd v0.12 master guide
 

Similar to Lambda Jam 2015: Event Processing in Clojure

Apache Spark Workshop, Apr. 2016, Euangelos Linardos
Apache Spark Workshop, Apr. 2016, Euangelos LinardosApache Spark Workshop, Apr. 2016, Euangelos Linardos
Apache Spark Workshop, Apr. 2016, Euangelos LinardosEuangelos Linardos
 
From Zero to Stream Processing
From Zero to Stream ProcessingFrom Zero to Stream Processing
From Zero to Stream ProcessingEventador
 
Node.js - async for the rest of us.
Node.js - async for the rest of us.Node.js - async for the rest of us.
Node.js - async for the rest of us.Mike Brevoort
 
Declarative & workflow based infrastructure with Terraform
Declarative & workflow based infrastructure with TerraformDeclarative & workflow based infrastructure with Terraform
Declarative & workflow based infrastructure with TerraformRadek Simko
 
Unix And Shell Scripting
Unix And Shell ScriptingUnix And Shell Scripting
Unix And Shell ScriptingJaibeer Malik
 
Big Data Scala by the Bay: Interactive Spark in your Browser
Big Data Scala by the Bay: Interactive Spark in your BrowserBig Data Scala by the Bay: Interactive Spark in your Browser
Big Data Scala by the Bay: Interactive Spark in your Browsergethue
 
PuppetDB: Sneaking Clojure into Operations
PuppetDB: Sneaking Clojure into OperationsPuppetDB: Sneaking Clojure into Operations
PuppetDB: Sneaking Clojure into Operationsgrim_radical
 
Introduction to Apache Flink - Fast and reliable big data processing
Introduction to Apache Flink - Fast and reliable big data processingIntroduction to Apache Flink - Fast and reliable big data processing
Introduction to Apache Flink - Fast and reliable big data processingTill Rohrmann
 
Functional (web) development with Clojure
Functional (web) development with ClojureFunctional (web) development with Clojure
Functional (web) development with ClojureHenrik Eneroth
 
Apache Flink internals
Apache Flink internalsApache Flink internals
Apache Flink internalsKostas Tzoumas
 
Andrzej Ludwikowski - Event Sourcing - what could possibly go wrong? - Codemo...
Andrzej Ludwikowski - Event Sourcing - what could possibly go wrong? - Codemo...Andrzej Ludwikowski - Event Sourcing - what could possibly go wrong? - Codemo...
Andrzej Ludwikowski - Event Sourcing - what could possibly go wrong? - Codemo...Codemotion
 
Microsoft 2014 Dev Plataform - Roslyn -& ASP.NET vNext
Microsoft 2014 Dev Plataform -  Roslyn -& ASP.NET vNextMicrosoft 2014 Dev Plataform -  Roslyn -& ASP.NET vNext
Microsoft 2014 Dev Plataform - Roslyn -& ASP.NET vNextRodolfo Finochietti
 
Data Streaming Technology Overview
Data Streaming Technology OverviewData Streaming Technology Overview
Data Streaming Technology OverviewDan Lynn
 
Why and How Powershell will rule the Command Line - Barcamp LA 4
Why and How Powershell will rule the Command Line - Barcamp LA 4Why and How Powershell will rule the Command Line - Barcamp LA 4
Why and How Powershell will rule the Command Line - Barcamp LA 4Ilya Haykinson
 
Real-Time Web Programming with PrismTech Vortex Web
Real-Time Web Programming with PrismTech Vortex WebReal-Time Web Programming with PrismTech Vortex Web
Real-Time Web Programming with PrismTech Vortex WebADLINK Technology IoT
 
Building Real-Time Web Applications with Vortex-Web
Building Real-Time Web Applications with Vortex-WebBuilding Real-Time Web Applications with Vortex-Web
Building Real-Time Web Applications with Vortex-WebAngelo Corsaro
 
Event Sourcing - what could possibly go wrong?
Event Sourcing - what could possibly go wrong?Event Sourcing - what could possibly go wrong?
Event Sourcing - what could possibly go wrong?Andrzej Ludwikowski
 

Similar to Lambda Jam 2015: Event Processing in Clojure (20)

Apache Spark Workshop, Apr. 2016, Euangelos Linardos
Apache Spark Workshop, Apr. 2016, Euangelos LinardosApache Spark Workshop, Apr. 2016, Euangelos Linardos
Apache Spark Workshop, Apr. 2016, Euangelos Linardos
 
From Zero to Stream Processing
From Zero to Stream ProcessingFrom Zero to Stream Processing
From Zero to Stream Processing
 
Node.js - async for the rest of us.
Node.js - async for the rest of us.Node.js - async for the rest of us.
Node.js - async for the rest of us.
 
Declarative & workflow based infrastructure with Terraform
Declarative & workflow based infrastructure with TerraformDeclarative & workflow based infrastructure with Terraform
Declarative & workflow based infrastructure with Terraform
 
Unix And Shell Scripting
Unix And Shell ScriptingUnix And Shell Scripting
Unix And Shell Scripting
 
Big Data Scala by the Bay: Interactive Spark in your Browser
Big Data Scala by the Bay: Interactive Spark in your BrowserBig Data Scala by the Bay: Interactive Spark in your Browser
Big Data Scala by the Bay: Interactive Spark in your Browser
 
PuppetDB: Sneaking Clojure into Operations
PuppetDB: Sneaking Clojure into OperationsPuppetDB: Sneaking Clojure into Operations
PuppetDB: Sneaking Clojure into Operations
 
Play framework
Play frameworkPlay framework
Play framework
 
Introduction to Apache Flink - Fast and reliable big data processing
Introduction to Apache Flink - Fast and reliable big data processingIntroduction to Apache Flink - Fast and reliable big data processing
Introduction to Apache Flink - Fast and reliable big data processing
 
Functional (web) development with Clojure
Functional (web) development with ClojureFunctional (web) development with Clojure
Functional (web) development with Clojure
 
Apache Flink internals
Apache Flink internalsApache Flink internals
Apache Flink internals
 
Andrzej Ludwikowski - Event Sourcing - what could possibly go wrong? - Codemo...
Andrzej Ludwikowski - Event Sourcing - what could possibly go wrong? - Codemo...Andrzej Ludwikowski - Event Sourcing - what could possibly go wrong? - Codemo...
Andrzej Ludwikowski - Event Sourcing - what could possibly go wrong? - Codemo...
 
Microsoft 2014 Dev Plataform - Roslyn -& ASP.NET vNext
Microsoft 2014 Dev Plataform -  Roslyn -& ASP.NET vNextMicrosoft 2014 Dev Plataform -  Roslyn -& ASP.NET vNext
Microsoft 2014 Dev Plataform - Roslyn -& ASP.NET vNext
 
Data Streaming Technology Overview
Data Streaming Technology OverviewData Streaming Technology Overview
Data Streaming Technology Overview
 
Why and How Powershell will rule the Command Line - Barcamp LA 4
Why and How Powershell will rule the Command Line - Barcamp LA 4Why and How Powershell will rule the Command Line - Barcamp LA 4
Why and How Powershell will rule the Command Line - Barcamp LA 4
 
Real-Time Web Programming with PrismTech Vortex Web
Real-Time Web Programming with PrismTech Vortex WebReal-Time Web Programming with PrismTech Vortex Web
Real-Time Web Programming with PrismTech Vortex Web
 
Building Real-Time Web Applications with Vortex-Web
Building Real-Time Web Applications with Vortex-WebBuilding Real-Time Web Applications with Vortex-Web
Building Real-Time Web Applications with Vortex-Web
 
Event Sourcing - what could possibly go wrong?
Event Sourcing - what could possibly go wrong?Event Sourcing - what could possibly go wrong?
Event Sourcing - what could possibly go wrong?
 
About Node.js
About Node.jsAbout Node.js
About Node.js
 
Tml for Laravel
Tml for LaravelTml for Laravel
Tml for Laravel
 

More from Andy Marks

YOW! Perth 2022 - Reviving the Art of Software Design
YOW! Perth 2022 - Reviving the Art of Software DesignYOW! Perth 2022 - Reviving the Art of Software Design
YOW! Perth 2022 - Reviving the Art of Software DesignAndy Marks
 
Top 5 Software Purchasing Fails for an Agile Environment
Top 5 Software Purchasing Fails for an Agile EnvironmentTop 5 Software Purchasing Fails for an Agile Environment
Top 5 Software Purchasing Fails for an Agile EnvironmentAndy Marks
 
"Kata" your way to better architecture skills
"Kata" your way to better architecture skills"Kata" your way to better architecture skills
"Kata" your way to better architecture skillsAndy Marks
 
"Kata" your way to better architecture skills
"Kata" your way to better architecture skills"Kata" your way to better architecture skills
"Kata" your way to better architecture skillsAndy Marks
 
IT Sociopath Bingo
IT Sociopath BingoIT Sociopath Bingo
IT Sociopath BingoAndy Marks
 
Developer Experience (DX) as a Fitness Function for Platform Teams
Developer Experience (DX) as a Fitness Function for Platform TeamsDeveloper Experience (DX) as a Fitness Function for Platform Teams
Developer Experience (DX) as a Fitness Function for Platform TeamsAndy Marks
 
Melbourne Clojure Meetup Jan 2018 - ClojureBridge
Melbourne Clojure Meetup Jan 2018  - ClojureBridgeMelbourne Clojure Meetup Jan 2018  - ClojureBridge
Melbourne Clojure Meetup Jan 2018 - ClojureBridgeAndy Marks
 
YOW WEST 2014: "Adopting Functional Programming Languages"
YOW WEST 2014: "Adopting Functional Programming Languages"YOW WEST 2014: "Adopting Functional Programming Languages"
YOW WEST 2014: "Adopting Functional Programming Languages"Andy Marks
 
YOW West 2015: "Macromonitoring for Microservices"
YOW West 2015: "Macromonitoring for Microservices"YOW West 2015: "Macromonitoring for Microservices"
YOW West 2015: "Macromonitoring for Microservices"Andy Marks
 
ThoughtWorks Live 2014: "Building Systems That Pivot"
ThoughtWorks Live 2014: "Building Systems That Pivot"ThoughtWorks Live 2014: "Building Systems That Pivot"
ThoughtWorks Live 2014: "Building Systems That Pivot"Andy Marks
 
YOW West 2016: "A Rose By Any Other Name: Monoglot Microservices"
YOW West 2016: "A Rose By Any Other Name: Monoglot Microservices"YOW West 2016: "A Rose By Any Other Name: Monoglot Microservices"
YOW West 2016: "A Rose By Any Other Name: Monoglot Microservices"Andy Marks
 
2017 Melb.JVM: "The Hills are alive with the Sound of your Crappy Code! "
2017 Melb.JVM: "The Hills are alive with the Sound of your Crappy Code! "2017 Melb.JVM: "The Hills are alive with the Sound of your Crappy Code! "
2017 Melb.JVM: "The Hills are alive with the Sound of your Crappy Code! "Andy Marks
 
2017 YOW West: "Does Smelly Code Also Sound Bad?"
2017 YOW West: "Does Smelly Code Also Sound Bad?"2017 YOW West: "Does Smelly Code Also Sound Bad?"
2017 YOW West: "Does Smelly Code Also Sound Bad?"Andy Marks
 
1st conference 2015 devops
1st conference 2015   devops1st conference 2015   devops
1st conference 2015 devopsAndy Marks
 
Quality versus-speed-tradeoffs
Quality versus-speed-tradeoffsQuality versus-speed-tradeoffs
Quality versus-speed-tradeoffsAndy Marks
 
Agile Methods for NTU Software Engineers
Agile Methods for NTU Software EngineersAgile Methods for NTU Software Engineers
Agile Methods for NTU Software EngineersAndy Marks
 
Aws map-reduce-aws
Aws map-reduce-awsAws map-reduce-aws
Aws map-reduce-awsAndy Marks
 

More from Andy Marks (17)

YOW! Perth 2022 - Reviving the Art of Software Design
YOW! Perth 2022 - Reviving the Art of Software DesignYOW! Perth 2022 - Reviving the Art of Software Design
YOW! Perth 2022 - Reviving the Art of Software Design
 
Top 5 Software Purchasing Fails for an Agile Environment
Top 5 Software Purchasing Fails for an Agile EnvironmentTop 5 Software Purchasing Fails for an Agile Environment
Top 5 Software Purchasing Fails for an Agile Environment
 
"Kata" your way to better architecture skills
"Kata" your way to better architecture skills"Kata" your way to better architecture skills
"Kata" your way to better architecture skills
 
"Kata" your way to better architecture skills
"Kata" your way to better architecture skills"Kata" your way to better architecture skills
"Kata" your way to better architecture skills
 
IT Sociopath Bingo
IT Sociopath BingoIT Sociopath Bingo
IT Sociopath Bingo
 
Developer Experience (DX) as a Fitness Function for Platform Teams
Developer Experience (DX) as a Fitness Function for Platform TeamsDeveloper Experience (DX) as a Fitness Function for Platform Teams
Developer Experience (DX) as a Fitness Function for Platform Teams
 
Melbourne Clojure Meetup Jan 2018 - ClojureBridge
Melbourne Clojure Meetup Jan 2018  - ClojureBridgeMelbourne Clojure Meetup Jan 2018  - ClojureBridge
Melbourne Clojure Meetup Jan 2018 - ClojureBridge
 
YOW WEST 2014: "Adopting Functional Programming Languages"
YOW WEST 2014: "Adopting Functional Programming Languages"YOW WEST 2014: "Adopting Functional Programming Languages"
YOW WEST 2014: "Adopting Functional Programming Languages"
 
YOW West 2015: "Macromonitoring for Microservices"
YOW West 2015: "Macromonitoring for Microservices"YOW West 2015: "Macromonitoring for Microservices"
YOW West 2015: "Macromonitoring for Microservices"
 
ThoughtWorks Live 2014: "Building Systems That Pivot"
ThoughtWorks Live 2014: "Building Systems That Pivot"ThoughtWorks Live 2014: "Building Systems That Pivot"
ThoughtWorks Live 2014: "Building Systems That Pivot"
 
YOW West 2016: "A Rose By Any Other Name: Monoglot Microservices"
YOW West 2016: "A Rose By Any Other Name: Monoglot Microservices"YOW West 2016: "A Rose By Any Other Name: Monoglot Microservices"
YOW West 2016: "A Rose By Any Other Name: Monoglot Microservices"
 
2017 Melb.JVM: "The Hills are alive with the Sound of your Crappy Code! "
2017 Melb.JVM: "The Hills are alive with the Sound of your Crappy Code! "2017 Melb.JVM: "The Hills are alive with the Sound of your Crappy Code! "
2017 Melb.JVM: "The Hills are alive with the Sound of your Crappy Code! "
 
2017 YOW West: "Does Smelly Code Also Sound Bad?"
2017 YOW West: "Does Smelly Code Also Sound Bad?"2017 YOW West: "Does Smelly Code Also Sound Bad?"
2017 YOW West: "Does Smelly Code Also Sound Bad?"
 
1st conference 2015 devops
1st conference 2015   devops1st conference 2015   devops
1st conference 2015 devops
 
Quality versus-speed-tradeoffs
Quality versus-speed-tradeoffsQuality versus-speed-tradeoffs
Quality versus-speed-tradeoffs
 
Agile Methods for NTU Software Engineers
Agile Methods for NTU Software EngineersAgile Methods for NTU Software Engineers
Agile Methods for NTU Software Engineers
 
Aws map-reduce-aws
Aws map-reduce-awsAws map-reduce-aws
Aws map-reduce-aws
 

Recently uploaded

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 

Recently uploaded (20)

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

Lambda Jam 2015: Event Processing in Clojure

  • 1.
  • 2. FUNCTIONAL DEVOPSEVENT PROCESSING IN CLOJURE Andy Marks @andee_marks amarks@thoughtworks.com
  • 6. (ns hello.core) (defn -main [] (prn “Hello World”))
  • 7. Jetty (ns hello.core) (defn -main [] (prn “Hello World”)) ✓access requests ✓queues ✓sessions
  • 8. AWS EC2 Jetty (ns hello.core) (defn -main [] (prn “Hello World”)) ✓disk ✓network interfaces ✓memory ✓cores/cpus
  • 9. AWS EC2 Jetty AWS EC2 Jetty AWS EC2 Jetty DNS (Master) DNS (Slave) ✓records ✓replication ✓resolution
  • 10. WS EC2 Jetty AWS EC2 Jetty AWS EC2 Jetty DNS (Master) DNS DB ✓performance ✓indexing ✓locking ✓connections
  • 11. WS EC2 Jetty AWS EC2 Jetty AWS EC2 Jetty DNS (Master) DNS DB Load Balancer AWS EC2 Jetty AWS EC2 Jetty ✓connections ✓DoS ✓Clients
  • 12. WS EC2 Jetty AWS EC2 Jetty AWS EC2 Jetty DNS (Master) DNS DB Load Balancer AWS EC2 Jetty AWS EC2 Jetty MessageQueue ✓queues ✓timeouts
  • 13. that is a lot of information…
  • 14. from a lot of different places
  • 15. this is a problem
  • 16. this is the problem Riemann helps solve
  • 17. Riemann is written in Clojure 52 source files 7256 lines 377 functions 30 macros
  • 18. Riemann is written and configured in Clojure
  • 19. And so… to Riemann
  • 22. Correlate events from disparate sources What is the latency of the web servers when the DB servers are generating timeouts? Filter events based on key criteria Ignore all network events with a normal status Aggregate events to perform statistical analysis (e.g., percentiles) What is the average response rate for 95% of requests? Monitor status of sources by availability of events Which services haven’t sent any events for the last 5 minutes? Route event streams to multiple consumers Send all error events from DB servers to the DBA team as well as the main operational dashboards SAMPLE RIEMANN USE CASES
  • 23. i = f(e) e: thundering herd of events i: information ready for downstream processing
  • 24. Hypothesis Event processing is function application at large scale… using Clojure to build/configure Riemann is a logical choice.
  • 25. (defrecord Event [ service state description metric tags time ttl KEY CONCEPTS: EVENTS “reg1.foo.bar” “reg-service http” “ok” “apache-log” 201 [“reg1” “http”] 104534892 60 riemannsource
  • 26. KEY CONCEPTS: STREAMS (logging/init {:file "riemann.log" :console true}) (instrumentation {:interval 5}) ;; self monitor every 5 seconds (periodically-expire 1) ;; check for expired events every second (tcp-server) (repl-server) (streams ;; insert magic here!!! prn) riemannconfig
  • 27. KEY CONCEPTS: INDEX flow of events index riemann process
  • 29. HOMOICONICITY “[It] is where a program's source code is written as a basic data structure that the programming language knows how to access.” Wikipedia (defn validate-config [file] (try (read-strings (slurp file)) (catch clojure.lang.LispReader$ReaderException e (throw (logging/nice-syntax-error e file))))) riemannsource
  • 30. HIGHER ORDER FUNCTIONS “A stream is just a function that takes a variable number of child streams and returns a function that takes an event and responds to the event it is passed when it is invoked.” http://riemann.io/quickstart.html “a higher-order function… does at least one of the following: [1] takes one or more functions as an input, [2] outputs a function” Wikipedia
  • 31. HIGHER ORDER FUNCTIONS “A stream is just a function that takes a variable number of child streams and returns a function that takes an event and responds to the event it is passed when it is invoked.” http://riemann.io/quickstart.html (streams (rate 5 prn) ) riemannconfig
  • 32. IMMUTABILITY “Streams ‘change’ events by sending altered, shared-structure *copies* of events downstream.” http://riemann.io/howto.html#split-streams (streams (where (host "db04") (with :service "foo" prn) (with :service "bar" prn)) ) riemannconfig
  • 34. “clojure's remarkably fast for what it is, sexprs make the tree structure of the streams visually apparent, it makes writing the concurrent algos much simpler, and macros allow us to express things like 'by and 'pipe in ways that would be awkward in other languages without building our own AST & interpreter or transpiler, etc.” “clojure's remarkably fast for what it is, sexprs make the tree structure of the streams visually apparent, it makes writing the concurrent algos much simpler, and macros allow us to express things like 'by and 'pipe in ways that would be awkward in other languages without building our own AST & interpreter or transpiler, etc.” @APHYR SAID…
  • 35. S-EXPRESSIONS “a notation for nested list (tree-structured) data… popularised by the programming language Lisp” Wikipedia
  • 36. S-EXPRESSIONS (streams (where (and (service #"^riak") (state “critical”)) (email “delacroix@vonbraun.com")) ) 1 Filter certain events… 2 Let people know… 1 2 riemannconfig “make the tree structure of the streams visually apparent”
  • 37. 3 1 2 S-EXPRESSIONS 1 Split on event fields… 2 Detect state changes… 3 Collate and email (streams (by [:host :service] (changed :state (rollup 5 3600 (email “delacroix@vonbraun.com")))) ) riemannconfig “make the tree structure of the streams visually apparent”
  • 38. MACROS (defmacro pipe [marker & stages] `(let [~@(->> stages reverse (interpose marker) (cons marker))] ~marker)) (streams (pipe - (splitp = service "http req rate" - "0mq req rate" (scale 2 -)) (rate 5 (graphite {:host “127.0.0.1” :port 2003}))) ) riemannconfig riemannsource
  • 39. MACROS: PIPE (streams (let [aggregate (rate 5 (graphite {:host “127.0.0.1” :port 2003}))] (splitp = service "http req rate" aggregate "0mq req rate" (scale 2 aggregate))) ) or riemannconfigriemannconfig (streams (pipe - (splitp = service "http req rate" - "0mq req rate" (scale 2 -)) (rate 5 (graphite {:host “127.0.0.1” :port 2003}))) )
  • 41. Hypothesis Event processing is function application at large scale: using Clojure to build/configure Riemann is a logical choice. homoiconicity higherorderfunctions s-expressions macros immutability
  • 42. CLOJURE AD ABSURDUM (defn do-you-trust-me? [event] (prn (load-string (:description event)))) (streams (where (service "event-gen") do-you-trust-me?) ) (ns event-gen.core (:require [riemann.client :refer :all]) (:gen-class :main true)) (defn -main [& args] (let [c (tcp-client {:host "127.0.0.1"})] (send-event c {:service "event-gen" :description "(+ 1 1)"}) (close-client c))) riemannclientriemannconfig
  • 43. CLOJURE AD ABSURDUM (defrecord Event [service description ]) “event-gen” “(+ 1 1)” Riemann (Clojure) riemann.config (Clojure) Client (Clojure) Clojure => “2”