SlideShare a Scribd company logo
PRESENTED BY
Using Redis Streams to build
Event-driven Microservices and
User Interface in Clojure(Script)
Bobby Calderwood
Evident Systems, Founder
bobby@evidentsystems.com
@bobbycalderwood
PRESENTED BY
• Software Engineer @Cognitect for 4+ years, Consulting and Datomic
• Distinguished Engineer @CapitalOne for 3+ years, helping redesign and move
mission-critical banking systems to the cloud
• Founder @Evident_Systems, helping smaller banks redesign and move
mission-critical banking systems to the cloud
• Meet with me! http://meet.evident.systems/founder
Hello, I’m Bobby Calderwood!
PRESENTED BY
1 Story of a real customer system
Event-Sourcing + Redis + Clojure(Script) = Joy
2 Aside: Memoir of an occasional Open Source contributor
How we got Clojure’s Carmine to speak Redis Streams
3 Our Story Continues: The (not so) Big Refactor
Retrofitting Redis Streams into a working system
Agenda:
4 Demo System
Let’s pretend we have to build a system, and then modify it with an asynchronous integration.
PRESENTED BY
• Major automobile manufacturer
• Greenfield system for new capability, political proving ground for stack and process
• Highly asynchronous image processing and significant UI display/manipulation
• Possible need for data re-processing/re-play, undo/redo, audit, and sharing with
other teams
• We decided to architect it using Event Sourcing on Streaming Data using
Redis, and implemented in Clojure(Script)
I was solving a customer problem
PRESENTED BY
Why Event Sourcing
& Streaming?
PRESENTED BY
• At very least, we knew we had to
process images asynchronously
• We suspected that we’d need to
keep this pipeline flexible, to try
different processing steps and
techniques
• We knew we’d need to convey
the results of this pipeline back
to the UI (the oft-forgotten
participant in the distributed
system)
To facilitate our asynchronous processing pipeline
PRESENTED BY
• Integration among microservices becomes complex and burdensome
– Balkanization of data stores
– Data “owner” determines data access pattern
– Non-determinism == impossibility of reasoning about system:
• state
• causality/time
• modes of failure
Because HTTP APIs aren’t enough
AWS Death Star diagram, circa 2008 as per Werner Vogels tweet
PRESENTED BY
• Request/response protocols face a fundamental epistemological problem
– What is happening, anything new?
– When should I check for new data?
– Who’s responsible to tell me?
Because HTTP APIs aren’t enough
PRESENTED BY
• Event Sourcing provides as-of
consistency across distributed
participants
• Streaming Data protocols convey new
data/events to interested participants
(subscribers)
• Any participant can simulate
synchrony and consistency by
blocking and waiting for a specific
event
Streaming Data + Event Sourcing Facilitate Distributed Consistency
Image by Alan Light CC BY-SA 3.0
PRESENTED BY
• “Situated Programs” a la Rich Hickey:
– interact with other systems
– often interact with humans
– remain in use for long periods of time
– are situated in a changing world
– use other people’s code
• In large enterprises
– audit/compliance/governance
– certain eventual integration with many new possible systems and data
consumers
– across many teams and organizational units who (basically) trust each other
More generally, to solve a specific type of problem
Nasa, Public Domain
Using Redis Streams To Build Event Driven Microservices And User Interface In Clojure Bobby Calderwood
PRESENTED BY
Why Redis?
(for streaming data)
PRESENTED BY
‘cause your last slide
definitely said “Kafka”
PRESENTED BY
• Redis is ubiquitous: you (or your customer) already has it in the stack
• Redis is battle-tested, and Ops is comfortable with it
• Redis is (often) easier to operate than Kafka (with some tradeoffs)
Redis is Already There, and Just Works
PRESENTED BY
• After Kafka Popularized, Salvatore noticed gap in Redis, as he described: http://
antirez.com/news/114
• Existing data structures got almost there
– Sorted Sets: memory hungry, clients can’t block awaiting new records, order not
stable
– Lists: linear time to scan, can’t seek to specific position, no fan-out to multiple
consumers
– Pub/Sub: doesn’t maintain history, can’t do windowed aggregation, etc.
• Redis Streams maintains range-queryable history, and efficiently conveys to
awaiting clients
Redis recently added Streams
PRESENTED BY
Why Clojure?
PRESENTED BY
• Clojure is a fantastic all-purpose programming language whose philosophy aligns
well with event sourcing, streaming data
• We needed to build all components quickly, with a small team of Clojurists:
– UI in ClojureScript
– React + Reagent + re-frame
– Access to JavaScript libraries with Clojure language semantics
– HTTP API in Clojure + Pedestal (+ GraphQL via Lacinia)
– Workers in Clojure
• Clojure’s core.async library provide in-process semantics aligned with streaming data
Clojure(Script) is powerful and full-stack
PRESENTED BY
• Very solid, simple Redis client
• Generated from Redis artifacts (on which more to come)
• Stays close to Redis semantics
Clojure has Carmine
PRESENTED BY
But Carmine didn’t have Streams…
PRESENTED BY
• ~1 hour after Salvatore’s blog post dropped, I filed https://github.com/
ptaoussanis/carmine/issues/208
• But I felt Open Source guilt, so I opened https://github.com/ptaoussanis/
carmine/pull/210
• But Carmine is generated from Redis Docs JSON, which didn’t yet include
Streams operations, so I filed https://github.com/antirez/redis-doc/issues/943,
and opened https://github.com/antirez/redis-doc/pull/963
…so we added support for Streams
PRESENTED BY
And support for all the above was
added incredibly quickly!
PRESENTED BY
• We had already built the HTTP API and processing pipeline
• Both components were producers and consumers of events
• Our implementation was limited in its scalability/fault-tolerance, so we needed
to re-work
• Ugh, how much re-work to support Streams?!?
…but not quickly enough to prevent re-work
PRESENTED BY
…including re-tooled deployment pipeline to support multiple workers
How much rework?
$ git diff --stat master
<snip>
16 files changed, 576 insertions(+), 598 deletions(-)
PRESENTED BY
• XADD — Produce to a Stream
• XRANGE, XREVRANGE — Query stream per range of existing offsets, non-
blocking, batch-ish
• XREAD — Optionally-blocking read (conveys novelty), realtime-ish
• XREADGROUP — Optionally-blocking read by a group of consumers, ack-ing
messages to advance consumer offset (but watch message ordering!)
But How to Redis Stream?
https://redis.io/topics/streams-intro
PRESENTED BY
And Now,
A Completely Unrelated
Demo App!
PRESENTED BY
• Always use Clojure, so that your major distributed systems refactorings can be
a net code reduction!
• Sharpen your tools: contribute to open source!
• Use Event Sourcing!
– Kafka for big/important/durable/expensive things
– Redis for smaller things https://redis.io/topics/streams-intro
• Check out my demo app! https://github.com/bobby/redisconf19-demo
Conclusion
Thank you!
bobby@evidentsystems.com
@bobbycalderwood
PRESENTED BY

More Related Content

What's hot (20)

PDF
이벤트 기반 분산 시스템을 향한 여정
Arawn Park
 
PDF
MLflow Model Serving
Databricks
 
PDF
Spark Streaming | Twitter Sentiment Analysis Example | Apache Spark Training ...
Edureka!
 
PDF
Event Driven-Architecture from a Scalability perspective
Jonas Bonér
 
PPTX
Redis Streams for Event-Driven Microservices
Redis Labs
 
PDF
Presto At Treasure Data
Taro L. Saito
 
PDF
DMS와 SCT를 활용한 Oracle에서 Open Source DB로의 전환
Amazon Web Services Korea
 
PDF
통신사의 차별화된 메시징 서비스 아키텍처를 소개합니다 - 정영준 AWS 솔루션즈 아키텍트 / 강성원, 나상화 소프트웨어 엔지니어 무선사업부...
Amazon Web Services Korea
 
PDF
데이터 분석가를 위한 신규 분석 서비스 - 김기영, AWS 분석 솔루션즈 아키텍트 / 변규현, 당근마켓 소프트웨어 엔지니어 :: AWS r...
Amazon Web Services Korea
 
PPTX
Kafka PPT.pptx
SRIRAMKIRAN9
 
PDF
ELK, a real case study
Paolo Tonin
 
PDF
Kafka Streams State Stores Being Persistent
confluent
 
PDF
그래프에서 대시보드까지, 서비스를 위한 데이터 시각화
Minho Lee
 
PDF
End-to-End Spark/TensorFlow/PyTorch Pipelines with Databricks Delta
Databricks
 
PDF
Thiết kế hệ thống E-Commerce yêu cầu mở rộng
Nguyen Minh Quang
 
PDF
Ray: Enterprise-Grade, Distributed Python
Databricks
 
PDF
Bigquery 101
Cesar Orozco Manotas
 
PDF
Amazon Redshift의 이해와 활용 (김용우) - AWS DB Day
Amazon Web Services Korea
 
PDF
How to build an ETL pipeline with Apache Beam on Google Cloud Dataflow
Lucas Arruda
 
PDF
Meetup: Streaming Data Pipeline Development
Timothy Spann
 
이벤트 기반 분산 시스템을 향한 여정
Arawn Park
 
MLflow Model Serving
Databricks
 
Spark Streaming | Twitter Sentiment Analysis Example | Apache Spark Training ...
Edureka!
 
Event Driven-Architecture from a Scalability perspective
Jonas Bonér
 
Redis Streams for Event-Driven Microservices
Redis Labs
 
Presto At Treasure Data
Taro L. Saito
 
DMS와 SCT를 활용한 Oracle에서 Open Source DB로의 전환
Amazon Web Services Korea
 
통신사의 차별화된 메시징 서비스 아키텍처를 소개합니다 - 정영준 AWS 솔루션즈 아키텍트 / 강성원, 나상화 소프트웨어 엔지니어 무선사업부...
Amazon Web Services Korea
 
데이터 분석가를 위한 신규 분석 서비스 - 김기영, AWS 분석 솔루션즈 아키텍트 / 변규현, 당근마켓 소프트웨어 엔지니어 :: AWS r...
Amazon Web Services Korea
 
Kafka PPT.pptx
SRIRAMKIRAN9
 
ELK, a real case study
Paolo Tonin
 
Kafka Streams State Stores Being Persistent
confluent
 
그래프에서 대시보드까지, 서비스를 위한 데이터 시각화
Minho Lee
 
End-to-End Spark/TensorFlow/PyTorch Pipelines with Databricks Delta
Databricks
 
Thiết kế hệ thống E-Commerce yêu cầu mở rộng
Nguyen Minh Quang
 
Ray: Enterprise-Grade, Distributed Python
Databricks
 
Bigquery 101
Cesar Orozco Manotas
 
Amazon Redshift의 이해와 활용 (김용우) - AWS DB Day
Amazon Web Services Korea
 
How to build an ETL pipeline with Apache Beam on Google Cloud Dataflow
Lucas Arruda
 
Meetup: Streaming Data Pipeline Development
Timothy Spann
 

Similar to Using Redis Streams To Build Event Driven Microservices And User Interface In Clojure Bobby Calderwood (20)

PPTX
How Open Source Embiggens Salesforce.com
Salesforce Engineering
 
PDF
apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...
apidays
 
PPTX
Sps toronto introduction to azure functions microsoft flow
Vincent Biret
 
PPTX
Cloud Services Powered by IBM SoftLayer and NetflixOSS
aspyker
 
PPTX
Lessons learned on the Azure API Stewardship Journey.pptx
apidays
 
PDF
Status Quo on the automation support in SOA Suite OGhTech17
Jon Petter Hjulstad
 
PPTX
DockerCon 15 Keynote - Day 2
Docker, Inc.
 
PDF
Stateful Interaction In Serverless Architecture With Redis: Pyounguk Cho
Redis Labs
 
PDF
Alluxio 2.0 & Near Real-time Big Data Platform w/ Spark & Alluxio
Alluxio, Inc.
 
PPTX
Building a [micro]services platform on AWS
Shaun Pearce
 
PDF
Alluxio+Presto: An Architecture for Fast SQL in the Cloud
Alluxio, Inc.
 
PDF
Interactive Analytics with the Starburst Presto + Alluxio stack for the Cloud
Alluxio, Inc.
 
PDF
Puppet Keynote by Ralph Luchs
NETWAYS
 
PPTX
Docker for the enterprise
Bert Poller
 
PDF
Containers, microservices and serverless for realists
Karthik Gaekwad
 
PPTX
Docker-N-Beyond
santosh007
 
PPSX
Building Modern Digital Services on Scalable Private Government Infrastructur...
Andrés Colón Pérez
 
PDF
Code for Startup MVP (Ruby on Rails) Session 1
Henry S
 
PDF
Patterns of the Lambda Architecture -- 2015 April -- Hadoop Summit, Europe
Flip Kromer
 
PPTX
Data for all: Empowering teams with scalable Shiny applications @ useR 2019
Ruan Pearce-Authers
 
How Open Source Embiggens Salesforce.com
Salesforce Engineering
 
apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...
apidays
 
Sps toronto introduction to azure functions microsoft flow
Vincent Biret
 
Cloud Services Powered by IBM SoftLayer and NetflixOSS
aspyker
 
Lessons learned on the Azure API Stewardship Journey.pptx
apidays
 
Status Quo on the automation support in SOA Suite OGhTech17
Jon Petter Hjulstad
 
DockerCon 15 Keynote - Day 2
Docker, Inc.
 
Stateful Interaction In Serverless Architecture With Redis: Pyounguk Cho
Redis Labs
 
Alluxio 2.0 & Near Real-time Big Data Platform w/ Spark & Alluxio
Alluxio, Inc.
 
Building a [micro]services platform on AWS
Shaun Pearce
 
Alluxio+Presto: An Architecture for Fast SQL in the Cloud
Alluxio, Inc.
 
Interactive Analytics with the Starburst Presto + Alluxio stack for the Cloud
Alluxio, Inc.
 
Puppet Keynote by Ralph Luchs
NETWAYS
 
Docker for the enterprise
Bert Poller
 
Containers, microservices and serverless for realists
Karthik Gaekwad
 
Docker-N-Beyond
santosh007
 
Building Modern Digital Services on Scalable Private Government Infrastructur...
Andrés Colón Pérez
 
Code for Startup MVP (Ruby on Rails) Session 1
Henry S
 
Patterns of the Lambda Architecture -- 2015 April -- Hadoop Summit, Europe
Flip Kromer
 
Data for all: Empowering teams with scalable Shiny applications @ useR 2019
Ruan Pearce-Authers
 
Ad

More from Redis Labs (20)

PPTX
Redis Day Bangalore 2020 - Session state caching with redis
Redis Labs
 
PPTX
Protecting Your API with Redis by Jane Paek - Redis Day Seattle 2020
Redis Labs
 
PPTX
The Happy Marriage of Redis and Protobuf by Scott Haines of Twilio - Redis Da...
Redis Labs
 
PPTX
SQL, Redis and Kubernetes by Paul Stanton of Windocks - Redis Day Seattle 2020
Redis Labs
 
PPTX
Rust and Redis - Solving Problems for Kubernetes by Ravi Jagannathan of VMwar...
Redis Labs
 
PPTX
Redis for Data Science and Engineering by Dmitry Polyakovsky of Oracle
Redis Labs
 
PPTX
Practical Use Cases for ACLs in Redis 6 by Jamie Scott - Redis Day Seattle 2020
Redis Labs
 
PPTX
Moving Beyond Cache by Yiftach Shoolman Redis Labs - Redis Day Seattle 2020
Redis Labs
 
PPTX
Leveraging Redis for System Monitoring by Adam McCormick of SBG - Redis Day S...
Redis Labs
 
PPTX
JSON in Redis - When to use RedisJSON by Jay Won of Coupang - Redis Day Seatt...
Redis Labs
 
PPTX
Highly Available Persistent Session Management Service by Mohamed Elmergawi o...
Redis Labs
 
PPTX
Anatomy of a Redis Command by Madelyn Olson of Amazon Web Services - Redis Da...
Redis Labs
 
PPTX
Building a Multi-dimensional Analytics Engine with RedisGraph by Matthew Goos...
Redis Labs
 
PPTX
RediSearch 1.6 by Pieter Cailliau - Redis Day Bangalore 2020
Redis Labs
 
PPTX
RedisGraph 2.0 by Pieter Cailliau - Redis Day Bangalore 2020
Redis Labs
 
PPTX
RedisTimeSeries 1.2 by Pieter Cailliau - Redis Day Bangalore 2020
Redis Labs
 
PPTX
RedisAI 0.9 by Sherin Thomas of Tensorwerk - Redis Day Bangalore 2020
Redis Labs
 
PPTX
Rate-Limiting 30 Million requests by Vijay Lakshminarayanan and Girish Koundi...
Redis Labs
 
PDF
Three Pillars of Observability by Rajalakshmi Raji Srinivasan of Site24x7 Zoh...
Redis Labs
 
PPTX
Solving Complex Scaling Problems by Prashant Kumar and Abhishek Jain of Myntr...
Redis Labs
 
Redis Day Bangalore 2020 - Session state caching with redis
Redis Labs
 
Protecting Your API with Redis by Jane Paek - Redis Day Seattle 2020
Redis Labs
 
The Happy Marriage of Redis and Protobuf by Scott Haines of Twilio - Redis Da...
Redis Labs
 
SQL, Redis and Kubernetes by Paul Stanton of Windocks - Redis Day Seattle 2020
Redis Labs
 
Rust and Redis - Solving Problems for Kubernetes by Ravi Jagannathan of VMwar...
Redis Labs
 
Redis for Data Science and Engineering by Dmitry Polyakovsky of Oracle
Redis Labs
 
Practical Use Cases for ACLs in Redis 6 by Jamie Scott - Redis Day Seattle 2020
Redis Labs
 
Moving Beyond Cache by Yiftach Shoolman Redis Labs - Redis Day Seattle 2020
Redis Labs
 
Leveraging Redis for System Monitoring by Adam McCormick of SBG - Redis Day S...
Redis Labs
 
JSON in Redis - When to use RedisJSON by Jay Won of Coupang - Redis Day Seatt...
Redis Labs
 
Highly Available Persistent Session Management Service by Mohamed Elmergawi o...
Redis Labs
 
Anatomy of a Redis Command by Madelyn Olson of Amazon Web Services - Redis Da...
Redis Labs
 
Building a Multi-dimensional Analytics Engine with RedisGraph by Matthew Goos...
Redis Labs
 
RediSearch 1.6 by Pieter Cailliau - Redis Day Bangalore 2020
Redis Labs
 
RedisGraph 2.0 by Pieter Cailliau - Redis Day Bangalore 2020
Redis Labs
 
RedisTimeSeries 1.2 by Pieter Cailliau - Redis Day Bangalore 2020
Redis Labs
 
RedisAI 0.9 by Sherin Thomas of Tensorwerk - Redis Day Bangalore 2020
Redis Labs
 
Rate-Limiting 30 Million requests by Vijay Lakshminarayanan and Girish Koundi...
Redis Labs
 
Three Pillars of Observability by Rajalakshmi Raji Srinivasan of Site24x7 Zoh...
Redis Labs
 
Solving Complex Scaling Problems by Prashant Kumar and Abhishek Jain of Myntr...
Redis Labs
 
Ad

Recently uploaded (20)

PDF
July Patch Tuesday
Ivanti
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
Python basic programing language for automation
DanialHabibi2
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
July Patch Tuesday
Ivanti
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Python basic programing language for automation
DanialHabibi2
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 

Using Redis Streams To Build Event Driven Microservices And User Interface In Clojure Bobby Calderwood

  • 1. PRESENTED BY Using Redis Streams to build Event-driven Microservices and User Interface in Clojure(Script) Bobby Calderwood Evident Systems, Founder [email protected] @bobbycalderwood
  • 2. PRESENTED BY • Software Engineer @Cognitect for 4+ years, Consulting and Datomic • Distinguished Engineer @CapitalOne for 3+ years, helping redesign and move mission-critical banking systems to the cloud • Founder @Evident_Systems, helping smaller banks redesign and move mission-critical banking systems to the cloud • Meet with me! http://meet.evident.systems/founder Hello, I’m Bobby Calderwood!
  • 3. PRESENTED BY 1 Story of a real customer system Event-Sourcing + Redis + Clojure(Script) = Joy 2 Aside: Memoir of an occasional Open Source contributor How we got Clojure’s Carmine to speak Redis Streams 3 Our Story Continues: The (not so) Big Refactor Retrofitting Redis Streams into a working system Agenda: 4 Demo System Let’s pretend we have to build a system, and then modify it with an asynchronous integration.
  • 4. PRESENTED BY • Major automobile manufacturer • Greenfield system for new capability, political proving ground for stack and process • Highly asynchronous image processing and significant UI display/manipulation • Possible need for data re-processing/re-play, undo/redo, audit, and sharing with other teams • We decided to architect it using Event Sourcing on Streaming Data using Redis, and implemented in Clojure(Script) I was solving a customer problem
  • 5. PRESENTED BY Why Event Sourcing & Streaming?
  • 6. PRESENTED BY • At very least, we knew we had to process images asynchronously • We suspected that we’d need to keep this pipeline flexible, to try different processing steps and techniques • We knew we’d need to convey the results of this pipeline back to the UI (the oft-forgotten participant in the distributed system) To facilitate our asynchronous processing pipeline
  • 7. PRESENTED BY • Integration among microservices becomes complex and burdensome – Balkanization of data stores – Data “owner” determines data access pattern – Non-determinism == impossibility of reasoning about system: • state • causality/time • modes of failure Because HTTP APIs aren’t enough
  • 8. AWS Death Star diagram, circa 2008 as per Werner Vogels tweet
  • 9. PRESENTED BY • Request/response protocols face a fundamental epistemological problem – What is happening, anything new? – When should I check for new data? – Who’s responsible to tell me? Because HTTP APIs aren’t enough
  • 10. PRESENTED BY • Event Sourcing provides as-of consistency across distributed participants • Streaming Data protocols convey new data/events to interested participants (subscribers) • Any participant can simulate synchrony and consistency by blocking and waiting for a specific event Streaming Data + Event Sourcing Facilitate Distributed Consistency Image by Alan Light CC BY-SA 3.0
  • 11. PRESENTED BY • “Situated Programs” a la Rich Hickey: – interact with other systems – often interact with humans – remain in use for long periods of time – are situated in a changing world – use other people’s code • In large enterprises – audit/compliance/governance – certain eventual integration with many new possible systems and data consumers – across many teams and organizational units who (basically) trust each other More generally, to solve a specific type of problem
  • 14. PRESENTED BY Why Redis? (for streaming data)
  • 15. PRESENTED BY ‘cause your last slide definitely said “Kafka”
  • 16. PRESENTED BY • Redis is ubiquitous: you (or your customer) already has it in the stack • Redis is battle-tested, and Ops is comfortable with it • Redis is (often) easier to operate than Kafka (with some tradeoffs) Redis is Already There, and Just Works
  • 17. PRESENTED BY • After Kafka Popularized, Salvatore noticed gap in Redis, as he described: http:// antirez.com/news/114 • Existing data structures got almost there – Sorted Sets: memory hungry, clients can’t block awaiting new records, order not stable – Lists: linear time to scan, can’t seek to specific position, no fan-out to multiple consumers – Pub/Sub: doesn’t maintain history, can’t do windowed aggregation, etc. • Redis Streams maintains range-queryable history, and efficiently conveys to awaiting clients Redis recently added Streams
  • 19. PRESENTED BY • Clojure is a fantastic all-purpose programming language whose philosophy aligns well with event sourcing, streaming data • We needed to build all components quickly, with a small team of Clojurists: – UI in ClojureScript – React + Reagent + re-frame – Access to JavaScript libraries with Clojure language semantics – HTTP API in Clojure + Pedestal (+ GraphQL via Lacinia) – Workers in Clojure • Clojure’s core.async library provide in-process semantics aligned with streaming data Clojure(Script) is powerful and full-stack
  • 20. PRESENTED BY • Very solid, simple Redis client • Generated from Redis artifacts (on which more to come) • Stays close to Redis semantics Clojure has Carmine
  • 21. PRESENTED BY But Carmine didn’t have Streams…
  • 22. PRESENTED BY • ~1 hour after Salvatore’s blog post dropped, I filed https://github.com/ ptaoussanis/carmine/issues/208 • But I felt Open Source guilt, so I opened https://github.com/ptaoussanis/ carmine/pull/210 • But Carmine is generated from Redis Docs JSON, which didn’t yet include Streams operations, so I filed https://github.com/antirez/redis-doc/issues/943, and opened https://github.com/antirez/redis-doc/pull/963 …so we added support for Streams
  • 23. PRESENTED BY And support for all the above was added incredibly quickly!
  • 24. PRESENTED BY • We had already built the HTTP API and processing pipeline • Both components were producers and consumers of events • Our implementation was limited in its scalability/fault-tolerance, so we needed to re-work • Ugh, how much re-work to support Streams?!? …but not quickly enough to prevent re-work
  • 25. PRESENTED BY …including re-tooled deployment pipeline to support multiple workers How much rework? $ git diff --stat master <snip> 16 files changed, 576 insertions(+), 598 deletions(-)
  • 26. PRESENTED BY • XADD — Produce to a Stream • XRANGE, XREVRANGE — Query stream per range of existing offsets, non- blocking, batch-ish • XREAD — Optionally-blocking read (conveys novelty), realtime-ish • XREADGROUP — Optionally-blocking read by a group of consumers, ack-ing messages to advance consumer offset (but watch message ordering!) But How to Redis Stream? https://redis.io/topics/streams-intro
  • 27. PRESENTED BY And Now, A Completely Unrelated Demo App!
  • 28. PRESENTED BY • Always use Clojure, so that your major distributed systems refactorings can be a net code reduction! • Sharpen your tools: contribute to open source! • Use Event Sourcing! – Kafka for big/important/durable/expensive things – Redis for smaller things https://redis.io/topics/streams-intro • Check out my demo app! https://github.com/bobby/redisconf19-demo Conclusion