SlideShare uma empresa Scribd logo
1 de 28
Baixar para ler offline
Redis Streams
@itamarhaber #Tech5 @Fiverr—FEBRUARY 2018
Who We Are
Open source. The leading in-memory database platform,
supporting any high performance operational, analytics or
hybrid use case.
The open source home and commercial provider of Redis
Enterprise (Redise
) technology, platform, products & services.
@itamarhaber, Technology Evangelisthello I am
Redis Streams
‱ 1st class Redis citizens
‱ An abstract data type that is not unlike a log
‱ Designed with time series data in mind
‱ Provide some "Kafkaesque" messaging abilities
This session is about
https://redis.io (emphasis for session context)
Redis is an open source (BSD licensed), in-memory data
structure store, used as a database, cache and message
broker. It supports data structures such as strings,
hashes, lists, sets, sorted sets with range queries,
bitmaps, hyperloglogs and geospatial indexes with
radius queries. Redis has built-in replication, Lua
scripting, LRU eviction, transactions and different levels
of on-disk persistence, and provides high availability via
Redis Sentinel and automatic partitioning with Redis
Cluster.
“
1. REmote DIctionary Server
2. / rɛdÉȘs/, pronounced “red-iss”
3. OSS (BSD3), https://github.com/antirez/redis
4. In-memory, but with optional disk persistence
5. By Salvatore Sanfilippo @antirez circa 27/2/09
6. DSL4ADT: A Domain Specific Language (DSL) for
Abstract Data Types (ADT)
7. Designed for performance and simplicity
Redis is
Necessity is the mother of invention
There ain't no such thing as a free lunch
The existing (i.e. lists, sorted sets, PubSub) isn't
"good enough" for things like:
‱ Log-like data patterns
‱ At-least-once messaging with fan-out
And listpacks, radix trees & reading Kafka :)
Why invent yet another Redis thingamajig?
“
“
A storage abstraction that is:
‱ Append-only, can be truncated
‱ A sequence of records ordered by time
A Logical Log is:
‱ Based on a logical offset, i.e. time (vs. bytes)
‱ Therefore time range queries
‱ Made up of in-memory data structures, naturally
The Log is (hardly a new thing)
A data stream is a sequence of elements. Consider:
‱ Real time sensor readings, e.g. particle colliders
‱ IoT, e.g. the irrigation of avocado groves
‱ User activity in an application
‱ 

‱ Messages in distributed systems
Logging streams of semi-structured data
A distributed system is a model in which
components located on networked computers
communicate and coordinate their actions by
passing messages
Distributed Computing, Wikipedia
Includes: client-server, 3/n-tier, peer to peer, SOA,
micro- & nanoservices, FaaS & serverless

A side note about Distributed Systems
“
There are only two hard problems in
distributed systems:
2. Exactly-once delivery
1. Guaranteed order of messages
2. Exactly-once delivery
Mathias Verraes, on Twitter
An observation
“
Fact #1: you can choose one and only one:
‱ At-most-once delivery, i.e. "shoot and forget"
‱ At-least-once delivery, i.e. explicit ack
Fact #2: exactly-once delivery doesn't exist
Observation: order is usually important (duh)
Refresher on message delivery semantics
Consider the non-exhaustive list at taskqueues.com
‱ 17 message brokers, including: Apache Kafka,
NATS, RabbitMQ and Redis
‱ 17 queue solutions, including: Celery, Kue,
Laravel, Sidekiq, Resque and RQ <- all these use
Redis as their backend btw ;)
And that without considering protocol-based etc...
This isn't exactly a new challenge
Redis (in general and) Streams (in particular) are:
‱ Everywhere, from the IoT's edge to the cloud
‱ Blazing fast, massive throughput
‱ Usable from all(most) languages and platforms
(IoT microcontrollers included)
Note: apropos IoT, they are great async buffers
So again, why "reinvent hot water"?
A stream is a sequence of entries (records). It:
‱ Is "sharded" by key ("topic")
‱ Has 1+ producers
‱ Has 0+ consumers
‱ Can provide at-most- or at-least-once semantics
‱ Enables stream processing/real time pipelines
(as opposed to batch)
Redis Streams "formalism"
A picture of a stream
0 1 2 3 4 5 6 7 8 9 10 11 12 13
Producer
Consumer 1
position
Consumer 2
position
Next entry
("*")
Every entry has a unique ID that is its logical offset.
The ID is in following format:
<epoch-milliseconds>-<sequence>
Note: each ID part is a 64-bit unsigned integer
An entry also has one or more ordered field-value
pairs, allowing for total abstraction (the empty
string is a valid field name, good for time series).
Entries in the Stream
Streamz Demo
Or how I'm graphing my laptop's CPU and battery temperatures
using only bash, iStats, redis-cli, redis-server, docker, grafana &
a browser
https://github.com/itamarhaber/streams-cpubattmp
# Adding entries
redis> XADD <key> <* | id>
[MAXLEN [~] <n>]
<field> <value> [...]
<epoch-milliseconds>-<sequence>
# Stream length
redis> XLEN <key>
(integer) <stream-length>
# Iterating
redis> X[REV]RANGE <key>
<start> <stop>
[COUNT <n>]
1) 1) <entry-id>
2) 1) <field1>
2) <value1>
3) ...
# [Blocking] read
redis> XREAD [BLOCK <milliseconds>]
STREAMS <key> [...]
<start> [...]
1) 1) <entry-id>
2) 1) <field1>
2) <value1>
3) ...
# And the usual Redis goodness, e.g. TX
redis> MULTI
...
# Or server-side processing
redis> EVAL "return 'Lua Rocks!'" 0
...
# Or your own custom module
redis> MODULE LOAD <your-module-here>
OK
A consumer of a stream gets all entries in order,
and will eventually become a bottleneck.
Possible workarounds:
‱ Add a "type" field to each record - that's dumb
‱ Shard the stream to multiple keys - meh
‱ Have the consumer dispatch entries as jobs in
queues
 GOTO 10
The problem with scaling consumers

 allow multiple consumers to cooperate in
processing messages arriving in a stream, so that
each consumers in a given group takes a subset
of the messages.
Shifts the complexity of recovering from consumer
failures and group management to the Redis server
Consumer Groups
“
We are here :)
‱ Groups are named and are explicitly (!) created:
XGROUP CREATE temps agg $
‱ Consumers are also named, and each gets only a
subset of the stream:
XREAD-GROUP GROUP agg CONSUMER
escher-01 STREAMS temps >
‱ XACK/NOACK in XREAD, XCLAIM, XPENDING...
Group orientation
Presently OSS Redis Streams are:
‱ Partially implemented
– Existing commands are relatively stable
– Some API corners still missing, e.g. XTRIM
– Consumer Groups are getting real
‱ A part of the unstable branch
‱ Expected to be GA as v5.0 during April 2018
Up to date status (Jan 26th)
‱ From your browser: https://try.redis.io
‱ Or download it: https://redis.io/download
‱ Or clone it: https://github.com/antirez/redis
‱ Or dockerize it: docker run -it redis
‱ Or try Redis Enterprise by https://redislabs.com
Next, try Redis yourself!
‱ The Redis Manifesto https://github.com/antirez/redis/blob/unstable/MANIFESTO
‱ Salvatore's blog posts http://antirez.com/news/114 and http://antirez.com/news/116
‱ Salvatore's Streams demo https://www.youtube.com/watch?v=ELDzy9lCFHQ
‱ RCP 11 - The stream data type https://github.com/redis/redis-rcp/blob/master/RCP11.md
‱ Reddit discussion
https://www.reddit.com/r/redis/comments/4mmrgr/stream_data_structure_for_redis_lets
_design_it/
‱ Hacker News discussion https://news.ycombinator.com/item?id=15384396
‱ Consumer groups specification
https://gist.github.com/antirez/68e67f3251d10f026861be2d0fe0d2f4
‱ Consumer groups API https://gist.github.com/antirez/4e7049ce4fce4aa61bf0cfbc3672e64d
& https://gist.github.com/antirez/4e7049ce4fce4aa61bf0cfbc3672e64d
‱ Redis Streams and the Unified Log https://brandur.org/redis-streams
‱ Introduction to Redis Streams
https://hackernoon.com/introduction-to-redis-streams-133f1c375cd3
References
Join us next month at
Redis Day Tel Aviv
Thank you,
Questions?

Mais conteĂșdo relacionado

Mais procurados

A Day in the Life of a Druid Implementor and Druid's Roadmap
A Day in the Life of a Druid Implementor and Druid's RoadmapA Day in the Life of a Druid Implementor and Druid's Roadmap
A Day in the Life of a Druid Implementor and Druid's Roadmap
Itai Yaffe
 
Real-Time Integration Between MongoDB and SQL Databases
Real-Time Integration Between MongoDB and SQL Databases Real-Time Integration Between MongoDB and SQL Databases
Real-Time Integration Between MongoDB and SQL Databases
MongoDB
 

Mais procurados (20)

Optimizing Presto Connector on Cloud Storage
Optimizing Presto Connector on Cloud StorageOptimizing Presto Connector on Cloud Storage
Optimizing Presto Connector on Cloud Storage
 
Cassandra vs. ScyllaDB: Evolutionary Differences
Cassandra vs. ScyllaDB: Evolutionary DifferencesCassandra vs. ScyllaDB: Evolutionary Differences
Cassandra vs. ScyllaDB: Evolutionary Differences
 
SAMOA: A Platform for Mining Big Data Streams (Apache BigData North America 2...
SAMOA: A Platform for Mining Big Data Streams (Apache BigData North America 2...SAMOA: A Platform for Mining Big Data Streams (Apache BigData North America 2...
SAMOA: A Platform for Mining Big Data Streams (Apache BigData North America 2...
 
Engineering fast indexes
Engineering fast indexesEngineering fast indexes
Engineering fast indexes
 
Agility and Scalability with MongoDB
Agility and Scalability with MongoDBAgility and Scalability with MongoDB
Agility and Scalability with MongoDB
 
Scaling Cloud-Scale Translytics Workloads with Omid and Phoenix
Scaling Cloud-Scale Translytics Workloads with Omid and PhoenixScaling Cloud-Scale Translytics Workloads with Omid and Phoenix
Scaling Cloud-Scale Translytics Workloads with Omid and Phoenix
 
Elastic{ON} 2017 Recap
Elastic{ON} 2017 RecapElastic{ON} 2017 Recap
Elastic{ON} 2017 Recap
 
Aggregated queries with Druid on terrabytes and petabytes of data
Aggregated queries with Druid on terrabytes and petabytes of dataAggregated queries with Druid on terrabytes and petabytes of data
Aggregated queries with Druid on terrabytes and petabytes of data
 
Imply at Apache Druid Meetup in London 1-15-20
Imply at Apache Druid Meetup in London 1-15-20Imply at Apache Druid Meetup in London 1-15-20
Imply at Apache Druid Meetup in London 1-15-20
 
WEBINAR - Introducing Scylla Open Source 3.0: Materialized Views, Secondary I...
WEBINAR - Introducing Scylla Open Source 3.0: Materialized Views, Secondary I...WEBINAR - Introducing Scylla Open Source 3.0: Materialized Views, Secondary I...
WEBINAR - Introducing Scylla Open Source 3.0: Materialized Views, Secondary I...
 
[Spark meetup] Spark Streaming Overview
[Spark meetup] Spark Streaming Overview[Spark meetup] Spark Streaming Overview
[Spark meetup] Spark Streaming Overview
 
(Berkeley CS186 guest lecture) Big Data Analytics Systems: What Goes Around C...
(Berkeley CS186 guest lecture) Big Data Analytics Systems: What Goes Around C...(Berkeley CS186 guest lecture) Big Data Analytics Systems: What Goes Around C...
(Berkeley CS186 guest lecture) Big Data Analytics Systems: What Goes Around C...
 
Fast NoSQL from HDDs?
Fast NoSQL from HDDs? Fast NoSQL from HDDs?
Fast NoSQL from HDDs?
 
Druid realtime indexing
Druid realtime indexingDruid realtime indexing
Druid realtime indexing
 
GumGum: Multi-Region Cassandra in AWS
GumGum: Multi-Region Cassandra in AWSGumGum: Multi-Region Cassandra in AWS
GumGum: Multi-Region Cassandra in AWS
 
A Day in the Life of a Druid Implementor and Druid's Roadmap
A Day in the Life of a Druid Implementor and Druid's RoadmapA Day in the Life of a Druid Implementor and Druid's Roadmap
A Day in the Life of a Druid Implementor and Druid's Roadmap
 
Cascading introduction
Cascading introductionCascading introduction
Cascading introduction
 
Webinar : Nouveautés de MongoDB 3.2
Webinar : Nouveautés de MongoDB 3.2Webinar : Nouveautés de MongoDB 3.2
Webinar : Nouveautés de MongoDB 3.2
 
Hoodie: How (And Why) We built an analytical datastore on Spark
Hoodie: How (And Why) We built an analytical datastore on SparkHoodie: How (And Why) We built an analytical datastore on Spark
Hoodie: How (And Why) We built an analytical datastore on Spark
 
Real-Time Integration Between MongoDB and SQL Databases
Real-Time Integration Between MongoDB and SQL Databases Real-Time Integration Between MongoDB and SQL Databases
Real-Time Integration Between MongoDB and SQL Databases
 

Semelhante a Redis Streams - Fiverr Tech5 meetup

Webinar: Faster Log Indexing with Fusion
Webinar: Faster Log Indexing with FusionWebinar: Faster Log Indexing with Fusion
Webinar: Faster Log Indexing with Fusion
Lucidworks
 

Semelhante a Redis Streams - Fiverr Tech5 meetup (20)

Redis v5 & Streams
Redis v5 & StreamsRedis v5 & Streams
Redis v5 & Streams
 
TechTalk: Connext DDS 5.2.
TechTalk: Connext DDS 5.2.TechTalk: Connext DDS 5.2.
TechTalk: Connext DDS 5.2.
 
Software architecture for data applications
Software architecture for data applicationsSoftware architecture for data applications
Software architecture for data applications
 
Highlights of AWS ReInvent 2023 (Announcements and Best Practices)
Highlights of AWS ReInvent 2023 (Announcements and Best Practices)Highlights of AWS ReInvent 2023 (Announcements and Best Practices)
Highlights of AWS ReInvent 2023 (Announcements and Best Practices)
 
Speed up your Symfony2 application and build awesome features with Redis
Speed up your Symfony2 application and build awesome features with RedisSpeed up your Symfony2 application and build awesome features with Redis
Speed up your Symfony2 application and build awesome features with Redis
 
Swift at Scale: The IBM SoftLayer Story
Swift at Scale: The IBM SoftLayer StorySwift at Scale: The IBM SoftLayer Story
Swift at Scale: The IBM SoftLayer Story
 
Running Production CDC Ingestion Pipelines With Balaji Varadarajan and Pritam...
Running Production CDC Ingestion Pipelines With Balaji Varadarajan and Pritam...Running Production CDC Ingestion Pipelines With Balaji Varadarajan and Pritam...
Running Production CDC Ingestion Pipelines With Balaji Varadarajan and Pritam...
 
Why databases cry at night
Why databases cry at nightWhy databases cry at night
Why databases cry at night
 
Kafka overview v0.1
Kafka overview v0.1Kafka overview v0.1
Kafka overview v0.1
 
Modern Distributed Messaging and RPC
Modern Distributed Messaging and RPCModern Distributed Messaging and RPC
Modern Distributed Messaging and RPC
 
LinuxONE cavemen mmit 20160505 v1.0
LinuxONE cavemen mmit 20160505 v1.0LinuxONE cavemen mmit 20160505 v1.0
LinuxONE cavemen mmit 20160505 v1.0
 
Timesten Architecture
Timesten ArchitectureTimesten Architecture
Timesten Architecture
 
7. Key-Value Databases: In Depth
7. Key-Value Databases: In Depth7. Key-Value Databases: In Depth
7. Key-Value Databases: In Depth
 
Apache Thrift, a brief introduction
Apache Thrift, a brief introductionApache Thrift, a brief introduction
Apache Thrift, a brief introduction
 
Bigdata meetup dwarak_realtime_score_app
Bigdata meetup dwarak_realtime_score_appBigdata meetup dwarak_realtime_score_app
Bigdata meetup dwarak_realtime_score_app
 
Solving Office 365 Big Challenges using Cassandra + Spark
Solving Office 365 Big Challenges using Cassandra + Spark Solving Office 365 Big Challenges using Cassandra + Spark
Solving Office 365 Big Challenges using Cassandra + Spark
 
Webinar: Faster Log Indexing with Fusion
Webinar: Faster Log Indexing with FusionWebinar: Faster Log Indexing with Fusion
Webinar: Faster Log Indexing with Fusion
 
SpringPeople - Introduction to Cloud Computing
SpringPeople - Introduction to Cloud ComputingSpringPeople - Introduction to Cloud Computing
SpringPeople - Introduction to Cloud Computing
 
Big Data_Architecture.pptx
Big Data_Architecture.pptxBig Data_Architecture.pptx
Big Data_Architecture.pptx
 
How bol.com makes sense of its logs, using the Elastic technology stack.
How bol.com makes sense of its logs, using the Elastic technology stack.How bol.com makes sense of its logs, using the Elastic technology stack.
How bol.com makes sense of its logs, using the Elastic technology stack.
 

Mais de Itamar Haber

Mais de Itamar Haber (16)

Redis Modules API - an introduction
Redis Modules API - an introductionRedis Modules API - an introduction
Redis Modules API - an introduction
 
Redis Lua Scripts
Redis Lua ScriptsRedis Lua Scripts
Redis Lua Scripts
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
How I Implemented the #1 Requested Feature In Redis In Less than 1 Hour with ...
How I Implemented the #1 Requested Feature In Redis In Less than 1 Hour with ...How I Implemented the #1 Requested Feature In Redis In Less than 1 Hour with ...
How I Implemented the #1 Requested Feature In Redis In Less than 1 Hour with ...
 
Developing a Redis Module - Hackathon Kickoff
 Developing a Redis Module - Hackathon Kickoff Developing a Redis Module - Hackathon Kickoff
Developing a Redis Module - Hackathon Kickoff
 
Extend Redis with Modules
Extend Redis with ModulesExtend Redis with Modules
Extend Redis with Modules
 
Leveraging Probabilistic Data Structures for Real Time Analytics with Redis M...
Leveraging Probabilistic Data Structures for Real Time Analytics with Redis M...Leveraging Probabilistic Data Structures for Real Time Analytics with Redis M...
Leveraging Probabilistic Data Structures for Real Time Analytics with Redis M...
 
Power to the People: Redis Lua Scripts
Power to the People: Redis Lua ScriptsPower to the People: Redis Lua Scripts
Power to the People: Redis Lua Scripts
 
What's new in Redis v3.2
What's new in Redis v3.2What's new in Redis v3.2
What's new in Redis v3.2
 
Redis Developers Day 2015 - Secondary Indexes and State of Lua
Redis Developers Day 2015 - Secondary Indexes and State of LuaRedis Developers Day 2015 - Secondary Indexes and State of Lua
Redis Developers Day 2015 - Secondary Indexes and State of Lua
 
Use Redis in Odd and Unusual Ways
Use Redis in Odd and Unusual WaysUse Redis in Odd and Unusual Ways
Use Redis in Odd and Unusual Ways
 
Why Your MongoDB Needs Redis
Why Your MongoDB Needs RedisWhy Your MongoDB Needs Redis
Why Your MongoDB Needs Redis
 
Redis & MongoDB: Stop Big Data Indigestion Before It Starts
Redis & MongoDB: Stop Big Data Indigestion Before It StartsRedis & MongoDB: Stop Big Data Indigestion Before It Starts
Redis & MongoDB: Stop Big Data Indigestion Before It Starts
 
Benchmarking Redis by itself and versus other NoSQL databases
Benchmarking Redis by itself and versus other NoSQL databasesBenchmarking Redis by itself and versus other NoSQL databases
Benchmarking Redis by itself and versus other NoSQL databases
 
Redis Indices (#RedisTLV)
Redis Indices (#RedisTLV)Redis Indices (#RedisTLV)
Redis Indices (#RedisTLV)
 
Redis Use Patterns (DevconTLV June 2014)
Redis Use Patterns (DevconTLV June 2014)Redis Use Patterns (DevconTLV June 2014)
Redis Use Patterns (DevconTLV June 2014)
 

Último

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
Enterprise Knowledge
 
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
Enterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Último (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
[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
 
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
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
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
 
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
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
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
 

Redis Streams - Fiverr Tech5 meetup

  • 1. Redis Streams @itamarhaber #Tech5 @Fiverr—FEBRUARY 2018
  • 2. Who We Are Open source. The leading in-memory database platform, supporting any high performance operational, analytics or hybrid use case. The open source home and commercial provider of Redis Enterprise (Redise ) technology, platform, products & services. @itamarhaber, Technology Evangelisthello I am
  • 3. Redis Streams ‱ 1st class Redis citizens ‱ An abstract data type that is not unlike a log ‱ Designed with time series data in mind ‱ Provide some "Kafkaesque" messaging abilities This session is about
  • 4. https://redis.io (emphasis for session context) Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs and geospatial indexes with radius queries. Redis has built-in replication, Lua scripting, LRU eviction, transactions and different levels of on-disk persistence, and provides high availability via Redis Sentinel and automatic partitioning with Redis Cluster. “
  • 5. 1. REmote DIctionary Server 2. / rɛdÉȘs/, pronounced “red-iss” 3. OSS (BSD3), https://github.com/antirez/redis 4. In-memory, but with optional disk persistence 5. By Salvatore Sanfilippo @antirez circa 27/2/09 6. DSL4ADT: A Domain Specific Language (DSL) for Abstract Data Types (ADT) 7. Designed for performance and simplicity Redis is
  • 6. Necessity is the mother of invention There ain't no such thing as a free lunch The existing (i.e. lists, sorted sets, PubSub) isn't "good enough" for things like: ‱ Log-like data patterns ‱ At-least-once messaging with fan-out And listpacks, radix trees & reading Kafka :) Why invent yet another Redis thingamajig? “ “
  • 7. A storage abstraction that is: ‱ Append-only, can be truncated ‱ A sequence of records ordered by time A Logical Log is: ‱ Based on a logical offset, i.e. time (vs. bytes) ‱ Therefore time range queries ‱ Made up of in-memory data structures, naturally The Log is (hardly a new thing)
  • 8. A data stream is a sequence of elements. Consider: ‱ Real time sensor readings, e.g. particle colliders ‱ IoT, e.g. the irrigation of avocado groves ‱ User activity in an application ‱ 
 ‱ Messages in distributed systems Logging streams of semi-structured data
  • 9. A distributed system is a model in which components located on networked computers communicate and coordinate their actions by passing messages Distributed Computing, Wikipedia Includes: client-server, 3/n-tier, peer to peer, SOA, micro- & nanoservices, FaaS & serverless
 A side note about Distributed Systems “
  • 10. There are only two hard problems in distributed systems: 2. Exactly-once delivery 1. Guaranteed order of messages 2. Exactly-once delivery Mathias Verraes, on Twitter An observation “
  • 11. Fact #1: you can choose one and only one: ‱ At-most-once delivery, i.e. "shoot and forget" ‱ At-least-once delivery, i.e. explicit ack Fact #2: exactly-once delivery doesn't exist Observation: order is usually important (duh) Refresher on message delivery semantics
  • 12. Consider the non-exhaustive list at taskqueues.com ‱ 17 message brokers, including: Apache Kafka, NATS, RabbitMQ and Redis ‱ 17 queue solutions, including: Celery, Kue, Laravel, Sidekiq, Resque and RQ <- all these use Redis as their backend btw ;) And that without considering protocol-based etc... This isn't exactly a new challenge
  • 13. Redis (in general and) Streams (in particular) are: ‱ Everywhere, from the IoT's edge to the cloud ‱ Blazing fast, massive throughput ‱ Usable from all(most) languages and platforms (IoT microcontrollers included) Note: apropos IoT, they are great async buffers So again, why "reinvent hot water"?
  • 14. A stream is a sequence of entries (records). It: ‱ Is "sharded" by key ("topic") ‱ Has 1+ producers ‱ Has 0+ consumers ‱ Can provide at-most- or at-least-once semantics ‱ Enables stream processing/real time pipelines (as opposed to batch) Redis Streams "formalism"
  • 15. A picture of a stream 0 1 2 3 4 5 6 7 8 9 10 11 12 13 Producer Consumer 1 position Consumer 2 position Next entry ("*")
  • 16. Every entry has a unique ID that is its logical offset. The ID is in following format: <epoch-milliseconds>-<sequence> Note: each ID part is a 64-bit unsigned integer An entry also has one or more ordered field-value pairs, allowing for total abstraction (the empty string is a valid field name, good for time series). Entries in the Stream
  • 17. Streamz Demo Or how I'm graphing my laptop's CPU and battery temperatures using only bash, iStats, redis-cli, redis-server, docker, grafana & a browser https://github.com/itamarhaber/streams-cpubattmp
  • 18. # Adding entries redis> XADD <key> <* | id> [MAXLEN [~] <n>] <field> <value> [...] <epoch-milliseconds>-<sequence> # Stream length redis> XLEN <key> (integer) <stream-length>
  • 19. # Iterating redis> X[REV]RANGE <key> <start> <stop> [COUNT <n>] 1) 1) <entry-id> 2) 1) <field1> 2) <value1> 3) ...
  • 20. # [Blocking] read redis> XREAD [BLOCK <milliseconds>] STREAMS <key> [...] <start> [...] 1) 1) <entry-id> 2) 1) <field1> 2) <value1> 3) ...
  • 21. # And the usual Redis goodness, e.g. TX redis> MULTI ... # Or server-side processing redis> EVAL "return 'Lua Rocks!'" 0 ... # Or your own custom module redis> MODULE LOAD <your-module-here> OK
  • 22. A consumer of a stream gets all entries in order, and will eventually become a bottleneck. Possible workarounds: ‱ Add a "type" field to each record - that's dumb ‱ Shard the stream to multiple keys - meh ‱ Have the consumer dispatch entries as jobs in queues
 GOTO 10 The problem with scaling consumers
  • 23. 
 allow multiple consumers to cooperate in processing messages arriving in a stream, so that each consumers in a given group takes a subset of the messages. Shifts the complexity of recovering from consumer failures and group management to the Redis server Consumer Groups “
  • 24. We are here :) ‱ Groups are named and are explicitly (!) created: XGROUP CREATE temps agg $ ‱ Consumers are also named, and each gets only a subset of the stream: XREAD-GROUP GROUP agg CONSUMER escher-01 STREAMS temps > ‱ XACK/NOACK in XREAD, XCLAIM, XPENDING... Group orientation
  • 25. Presently OSS Redis Streams are: ‱ Partially implemented – Existing commands are relatively stable – Some API corners still missing, e.g. XTRIM – Consumer Groups are getting real ‱ A part of the unstable branch ‱ Expected to be GA as v5.0 during April 2018 Up to date status (Jan 26th)
  • 26. ‱ From your browser: https://try.redis.io ‱ Or download it: https://redis.io/download ‱ Or clone it: https://github.com/antirez/redis ‱ Or dockerize it: docker run -it redis ‱ Or try Redis Enterprise by https://redislabs.com Next, try Redis yourself!
  • 27. ‱ The Redis Manifesto https://github.com/antirez/redis/blob/unstable/MANIFESTO ‱ Salvatore's blog posts http://antirez.com/news/114 and http://antirez.com/news/116 ‱ Salvatore's Streams demo https://www.youtube.com/watch?v=ELDzy9lCFHQ ‱ RCP 11 - The stream data type https://github.com/redis/redis-rcp/blob/master/RCP11.md ‱ Reddit discussion https://www.reddit.com/r/redis/comments/4mmrgr/stream_data_structure_for_redis_lets _design_it/ ‱ Hacker News discussion https://news.ycombinator.com/item?id=15384396 ‱ Consumer groups specification https://gist.github.com/antirez/68e67f3251d10f026861be2d0fe0d2f4 ‱ Consumer groups API https://gist.github.com/antirez/4e7049ce4fce4aa61bf0cfbc3672e64d & https://gist.github.com/antirez/4e7049ce4fce4aa61bf0cfbc3672e64d ‱ Redis Streams and the Unified Log https://brandur.org/redis-streams ‱ Introduction to Redis Streams https://hackernoon.com/introduction-to-redis-streams-133f1c375cd3 References
  • 28. Join us next month at Redis Day Tel Aviv Thank you, Questions?