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

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
Erwin 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 Quo
Erwin van der Koogh
 
Storylistening: Unleash the human
Storylistening: Unleash the humanStorylistening: Unleash the human
Storylistening: Unleash the human
Erwin 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

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
 

Dernier (20)

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...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
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
 
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
 
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
 
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
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

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