SlideShare une entreprise Scribd logo
1  sur  12
Redis
Erwin van der Koogh - Erronis
Warning!
This is not about how blazingly fast Redisis

Or how many keys it can store

This is for a prototype. Our load is less than
a request/min and we have < 100.000 keys

This is to show how easy it is to use Redis in
development to knock something up.
What is Redis?
Simple In-memory key-value store

With a twist

Complex data structures

Strong persistence

Powerful control flows

Extremely fast
Problem
API for Electronic Programming Guide

Complete dump of upcoming 7 days every
hour

Build 10 days of history

Flexible query options begin= & end=

Hundreds of channels
First solution - Import
Read in dump, convert to JSON

Store channelId in Set channels

Make a SortedSet for channel

Store JSON with date/time as score
First solution - Query
Get all channelIds for Set channels

Get all items between begin and end from
SortedSet

return
Problem 2
That was fine for the first import, but the
import 1 hour later had to overwrite most of
the data
Second solution
Add new entries in a temp SortedSet

Take date/time from first entry in SortedSet

Copy current SortedSet to merge SortedSet

Remove items in merge Set newer than first
new entry

Merge merge and tmp SortedSet into new
SortedSet
Problem 3
We needed to update some of the data

Updating complex entries (JSON) in a
(Sorted)Set is error-prone
Third Solution - Import
 Instead of saving JSON in SortedSet save
 them in a hash

 Put only the key of the hash in the
 SortedSet
Third Solution - Query
 Get all channelIds from channel Set

 Get all Ids for entries between begin & end

 Get all information from hash for every id

 Start streaming every item in as they are
 coming in
Lessons Learned
In-memory makes a difference, lots of
queries are ok

Learn to love single-threaded

Use the complex data-structure for easy
querying (List, Set, SortedSet)

MONITOR is your friend

Contenu connexe

Plus de Erwin van der Koogh

MVP, You keep using that word. I don't think it means what you think it does
MVP, You keep using that word. I don't think it means what you think it doesMVP, You keep using that word. I don't think it means what you think it does
MVP, You keep using that word. I don't think it means what you think it doesErwin van der Koogh
 
7 Habits of Highly Effective Organisations (Agile)
7 Habits of Highly Effective Organisations (Agile)7 Habits of Highly Effective Organisations (Agile)
7 Habits of Highly Effective Organisations (Agile)Erwin van der Koogh
 
3 Mistakes Companies Make when Changing the Business Culture
3 Mistakes Companies Make when Changing the Business Culture3 Mistakes Companies Make when Changing the Business Culture
3 Mistakes Companies Make when Changing the Business CultureErwin van der Koogh
 
Manage Change, Lead the Status Quo
Manage Change, Lead the Status QuoManage Change, Lead the Status Quo
Manage Change, Lead the Status QuoErwin van der Koogh
 
Storylistening: Unleash the human
Storylistening: Unleash the humanStorylistening: Unleash the human
Storylistening: Unleash the humanErwin van der Koogh
 
From Explotation of Resources to Unfolding of Human Potential
From Explotation of Resources to Unfolding of Human PotentialFrom Explotation of Resources to Unfolding of Human Potential
From Explotation of Resources to Unfolding of Human PotentialErwin van der Koogh
 

Plus de Erwin van der Koogh (9)

MVP, You keep using that word. I don't think it means what you think it does
MVP, You keep using that word. I don't think it means what you think it doesMVP, You keep using that word. I don't think it means what you think it does
MVP, You keep using that word. I don't think it means what you think it does
 
7 Habits of Highly Effective Organisations (Agile)
7 Habits of Highly Effective Organisations (Agile)7 Habits of Highly Effective Organisations (Agile)
7 Habits of Highly Effective Organisations (Agile)
 
Agile HR
Agile HRAgile HR
Agile HR
 
3 Mistakes Companies Make when Changing the Business Culture
3 Mistakes Companies Make when Changing the Business Culture3 Mistakes Companies Make when Changing the Business Culture
3 Mistakes Companies Make when Changing the Business Culture
 
Manage Change, Lead the Status Quo
Manage Change, Lead the Status QuoManage Change, Lead the Status Quo
Manage Change, Lead the Status Quo
 
Storylistening: Unleash the human
Storylistening: Unleash the humanStorylistening: Unleash the human
Storylistening: Unleash the human
 
From Explotation of Resources to Unfolding of Human Potential
From Explotation of Resources to Unfolding of Human PotentialFrom Explotation of Resources to Unfolding of Human Potential
From Explotation of Resources to Unfolding of Human Potential
 
Deliberate discovery
Deliberate discoveryDeliberate discovery
Deliberate discovery
 
The Future of IT is here
The Future of IT is hereThe Future of IT is here
The Future of IT is here
 

Dernier

The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 

Dernier (20)

The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 

How I used Redis' SortedSets

  • 1. Redis Erwin van der Koogh - Erronis
  • 2. Warning! This is not about how blazingly fast Redisis Or how many keys it can store This is for a prototype. Our load is less than a request/min and we have < 100.000 keys This is to show how easy it is to use Redis in development to knock something up.
  • 3. What is Redis? Simple In-memory key-value store With a twist Complex data structures Strong persistence Powerful control flows Extremely fast
  • 4. Problem API for Electronic Programming Guide Complete dump of upcoming 7 days every hour Build 10 days of history Flexible query options begin= & end= Hundreds of channels
  • 5. First solution - Import Read in dump, convert to JSON Store channelId in Set channels Make a SortedSet for channel Store JSON with date/time as score
  • 6. First solution - Query Get all channelIds for Set channels Get all items between begin and end from SortedSet return
  • 7. Problem 2 That was fine for the first import, but the import 1 hour later had to overwrite most of the data
  • 8. Second solution Add new entries in a temp SortedSet Take date/time from first entry in SortedSet Copy current SortedSet to merge SortedSet Remove items in merge Set newer than first new entry Merge merge and tmp SortedSet into new SortedSet
  • 9. Problem 3 We needed to update some of the data Updating complex entries (JSON) in a (Sorted)Set is error-prone
  • 10. Third Solution - Import Instead of saving JSON in SortedSet save them in a hash Put only the key of the hash in the SortedSet
  • 11. Third Solution - Query Get all channelIds from channel Set Get all Ids for entries between begin & end Get all information from hash for every id Start streaming every item in as they are coming in
  • 12. Lessons Learned In-memory makes a difference, lots of queries are ok Learn to love single-threaded Use the complex data-structure for easy querying (List, Set, SortedSet) MONITOR is your friend

Notes de l'éditeur

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n