SlideShare a Scribd company logo
Redis

  REmote DIctionary Server


         Ezra Zygmuntowicz
#redis   twitter: @ezmobius
• Fast, in memory key/value store
• STRING, LIST, SET & ZSET data types
• Persistence via async snapshots or AOF
• Perfect Data Structure/State/Cache Server
Data Structure Server
Data Structure Server
   Key:String => Value:String
Data Structure Server
   Key:String => Value:String

   Key:String => Value:List
Data Structure Server
   Key:String => Value:String

   Key:String => Value:List

   Key:String => Value:Set
Data Structure Server
   Key:String => Value:String

   Key:String => Value:List

   Key:String => Value:Set

    Key:String => Value:Zset
Operations on any Type

• Exists, Del, Type
• Keys, Randomkey
• Rename, RenameNX
• Dbsize, Select, Move, Flushdb, Flushall
• TTL, Expire
Operations on
       STRING’s
• Get, Set, GetSet, SetNX
• Mget, Mset, MgetNX, MsetNX
• Incr, Incrby
• Decr, Decrby
Operations on LISTS’s
• Atomic Operations:
• Push/Pop
• Index (array indexing)
• Lrange, Ltrim, Llen
• Blpop, Brpop
• RpopLpush, BRpopLpush
Operations on SET’s

• Sadd, Srem, Spop, Smove
• Scard, Sismember, Smembers, Srandmember
• Sinter, Sinterstore, Sunion, Sunionstore
• Sdiff, Sdiffstore
Operations on ZSET’s

• Zadd, Zrem, Zincrby
• Zrange, Zrevrange
• Zrangebyscore, Zcard
• Zscore, Zremrangebyscore
Seems cool, but what
  are the use cases?
• Memcached on Steroids
• Tag Clouds, Leaderboards
• Stat collections, circular log buffers
• Share state between processes
• A/B testing
• REDIStribute your load
Example: Tagging
Example: Tagging

  SADD article:42 magick
 SADD article:42 unicorns
 SADD article:42 rainbows
Example: Tagging

  SADD article:42 magick
 SADD article:42 unicorns
 SADD article:42 rainbows
  SADD article:12 magick
   SADD article:12 bar
   SADD article:12 qux
   SADD article:12 foo
Example: Tagging
  SADD article:42 magick
 SADD article:42 unicorns
 SADD article:42 rainbows
  SADD article:12 magick
   SADD article:12 bar
   SADD article:12 qux
   SADD article:12 foo

 SINTER article:42 article:12
       #=> magick
Example: Fair Work
    Scheduler
Example: Fair Work
    Scheduler
Example: Fair Work
    Scheduler



 Each worker node periodically issues:
 ZADD worker:nodes 1.5 hostname
    1.5 is the load ave of the host
Example: Fair Work
    Scheduler



Each worker node listens for work with:
         BLPOP hostname 10
Example: Fair Work
      Scheduler



When a producer wants to issue a work request:
         ZRANGE worker:nodes 0 2
       returns top 3 least loaded nodes
Example: Fair Work
        Scheduler



Pick a random node out of the 3 least loaded nodes
  in order to add jitter so we don’t overload hosts
Example: Fair Work
    Scheduler



    Then issue the work request:
LPUSH hostname {“work”: {“foo”: “bar”}}
Example: Fair Work
         Scheduler



This setup uses ZSETS and the load average as a score
  in order to evenly distribute load across a farm of
    worker instances listening for jobs with BLPOP
Example: AMQP
message de-dupe
Example: AMQP
           message de-dupe
Route messages through 2 separate rabbitmq brokers for
                     redundancy

Use redis for message de-dupe by tagging messages with a
                          guid

               Use guid as key into redis

 Use SETNX when setting the guid key so first one wins
 and second messages gets discarded as already received
Other Ideas
• Distributed Lock Manager for process
  coordination
• Full Text Inverted Index Lookups
• Caching with extra smarts using lists, sets
  and atomic ops on said structures
• Share data structures between multiple
  processes like a blackboard/tuplespace
Speed
• 110k GETS/SETS/second on average linux box
• Mostly faster then memcached for same ops
• Event Driven, can handle thousands of clients with
  epoll/kqueue support
• Ops happen in memory, persistence is async so
  everything is very fast
Persistence

• Async Snapshots with configurable triggers
• Append Only File: AOF
• Redis 2.0 Virtual Memory
Replication


• Built in Master -> Slave Async replication
• Create replication chains as needed
Sharding

• Client side sharding (like memcached)
• Consistent ring hashing
• Special case keys “foo{tags}” for operations on
  keys that must live on the same server in ruby
  client
Redactor
• Simple Actor Library based around Redis
Questions?


  http://code.google.com/p/redis/
http://github.com/ezmobius/redis-rb

More Related Content

What's hot (20)

PPTX
Apache Bigtopによるオープンなビッグデータ処理基盤の構築(オープンデベロッパーズカンファレンス 2021 Online 発表資料)
NTT DATA Technology & Innovation
 
PDF
Airflow Best Practises & Roadmap to Airflow 2.0
Kaxil Naik
 
PDF
Building robust CDC pipeline with Apache Hudi and Debezium
Tathastu.ai
 
PDF
Monitoring Kubernetes with Prometheus
Grafana Labs
 
PPTX
Apache airflow
Pavel Alexeev
 
PDF
Apache Hadoop YARNとマルチテナントにおけるリソース管理
Cloudera Japan
 
PDF
Spark
Amir Payberah
 
PDF
İleri Seviye T-SQL Programlama - Chapter 16
Cihan Özhan
 
PPTX
YARN Ready: Integrating to YARN with Tez
Hortonworks
 
PPTX
MySQL Monitoring using Prometheus & Grafana
YoungHeon (Roy) Kim
 
PDF
Amazon S3 Best Practice and Tuning for Hadoop/Spark in the Cloud
Noritaka Sekiyama
 
PPTX
Hadoop -NameNode HAの仕組み-
Yuki Gonda
 
PDF
Data ingestion and distribution with apache NiFi
Lev Brailovskiy
 
PPTX
Oracle GoldenGate 21c New Features and Best Practices
Bobby Curtis
 
PPTX
Apache Tez: Accelerating Hadoop Query Processing
Hortonworks
 
ODP
Redis overview
Ahmad El-khuja
 
PDF
Terraform features(kr)
규석 이
 
PDF
State of the Trino Project
Martin Traverso
 
PDF
Apache Iceberg - A Table Format for Hige Analytic Datasets
Alluxio, Inc.
 
PPTX
Introduction to Elasticsearch
Ismaeel Enjreny
 
Apache Bigtopによるオープンなビッグデータ処理基盤の構築(オープンデベロッパーズカンファレンス 2021 Online 発表資料)
NTT DATA Technology & Innovation
 
Airflow Best Practises & Roadmap to Airflow 2.0
Kaxil Naik
 
Building robust CDC pipeline with Apache Hudi and Debezium
Tathastu.ai
 
Monitoring Kubernetes with Prometheus
Grafana Labs
 
Apache airflow
Pavel Alexeev
 
Apache Hadoop YARNとマルチテナントにおけるリソース管理
Cloudera Japan
 
İleri Seviye T-SQL Programlama - Chapter 16
Cihan Özhan
 
YARN Ready: Integrating to YARN with Tez
Hortonworks
 
MySQL Monitoring using Prometheus & Grafana
YoungHeon (Roy) Kim
 
Amazon S3 Best Practice and Tuning for Hadoop/Spark in the Cloud
Noritaka Sekiyama
 
Hadoop -NameNode HAの仕組み-
Yuki Gonda
 
Data ingestion and distribution with apache NiFi
Lev Brailovskiy
 
Oracle GoldenGate 21c New Features and Best Practices
Bobby Curtis
 
Apache Tez: Accelerating Hadoop Query Processing
Hortonworks
 
Redis overview
Ahmad El-khuja
 
Terraform features(kr)
규석 이
 
State of the Trino Project
Martin Traverso
 
Apache Iceberg - A Table Format for Hige Analytic Datasets
Alluxio, Inc.
 
Introduction to Elasticsearch
Ismaeel Enjreny
 

Viewers also liked (6)

PPS
Get Rid Of Stress 194
Neerja Chaudhary
 
PDF
Evan Ellis "Tumblr. Massively Sharded MySQL"
Alexey Mahotkin
 
PPTX
Redis勉強会資料(2015/06 update)
Yuji Otani
 
PPTX
High-Volume Data Collection and Real Time Analytics Using Redis
cacois
 
PPTX
Sharding Methods for MongoDB
MongoDB
 
PDF
大規模Redisサーバ縮小化の戦い
Yuto Komai
 
Get Rid Of Stress 194
Neerja Chaudhary
 
Evan Ellis "Tumblr. Massively Sharded MySQL"
Alexey Mahotkin
 
Redis勉強会資料(2015/06 update)
Yuji Otani
 
High-Volume Data Collection and Real Time Analytics Using Redis
cacois
 
Sharding Methods for MongoDB
MongoDB
 
大規模Redisサーバ縮小化の戦い
Yuto Komai
 
Ad

Similar to Redis: REmote DIctionary Server (20)

PDF
Redis Everywhere - Sunshine PHP
Ricard Clau
 
PPT
Python redis talk
Josiah Carlson
 
PDF
Speed up your Symfony2 application and build awesome features with Redis
Ricard Clau
 
KEY
Building Scalable, Distributed Job Queues with Redis and Redis::Client
Mike Friedman
 
PDF
Redis — The AK-47 of Post-relational Databases
Karel Minarik
 
KEY
Redis, Resque & Friends
Christopher Spring
 
PDF
Introduction to redis - version 2
Dvir Volk
 
PDF
Introduction to Redis
Dvir Volk
 
PDF
An Introduction to Redis for Developers.pdf
Stephen Lorello
 
PDF
Building Distributed Systems
Pivorak MeetUp
 
PDF
A Brief Introduction to Redis
Charles Anderson
 
PPTX
NoSQL Introduction, Theory, Implementations
Firat Atagun
 
PDF
Seminar_Final
Cheng Zhang
 
PDF
Voldemort Nosql
elliando dias
 
PDF
Fun with Ruby and Redis
javier ramirez
 
PPTX
REDIS327
Rajan Bhatt
 
PDF
Paris Redis Meetup Introduction
Gregory Boissinot
 
PDF
mar07-redis.pdf
AnisSalhi3
 
KEY
Messaging, interoperability and log aggregation - a new framework
Tomas Doran
 
PDF
Redis
Socialmetrix
 
Redis Everywhere - Sunshine PHP
Ricard Clau
 
Python redis talk
Josiah Carlson
 
Speed up your Symfony2 application and build awesome features with Redis
Ricard Clau
 
Building Scalable, Distributed Job Queues with Redis and Redis::Client
Mike Friedman
 
Redis — The AK-47 of Post-relational Databases
Karel Minarik
 
Redis, Resque & Friends
Christopher Spring
 
Introduction to redis - version 2
Dvir Volk
 
Introduction to Redis
Dvir Volk
 
An Introduction to Redis for Developers.pdf
Stephen Lorello
 
Building Distributed Systems
Pivorak MeetUp
 
A Brief Introduction to Redis
Charles Anderson
 
NoSQL Introduction, Theory, Implementations
Firat Atagun
 
Seminar_Final
Cheng Zhang
 
Voldemort Nosql
elliando dias
 
Fun with Ruby and Redis
javier ramirez
 
REDIS327
Rajan Bhatt
 
Paris Redis Meetup Introduction
Gregory Boissinot
 
mar07-redis.pdf
AnisSalhi3
 
Messaging, interoperability and log aggregation - a new framework
Tomas Doran
 
Ad

More from Ezra Zygmuntowicz (9)

PDF
Where do I put this data? #lessql
Ezra Zygmuntowicz
 
PDF
Railsconf
Ezra Zygmuntowicz
 
PDF
Erlangfactory
Ezra Zygmuntowicz
 
PDF
Ruby Deployment
Ezra Zygmuntowicz
 
PDF
Merb + Nanite
Ezra Zygmuntowicz
 
PDF
Vertebra
Ezra Zygmuntowicz
 
PDF
Vertebra
Ezra Zygmuntowicz
 
PDF
Merb Core
Ezra Zygmuntowicz
 
PPT
Custom Mongrel Handlers: Learning how to walk the dog
Ezra Zygmuntowicz
 
Where do I put this data? #lessql
Ezra Zygmuntowicz
 
Erlangfactory
Ezra Zygmuntowicz
 
Ruby Deployment
Ezra Zygmuntowicz
 
Merb + Nanite
Ezra Zygmuntowicz
 
Custom Mongrel Handlers: Learning how to walk the dog
Ezra Zygmuntowicz
 

Recently uploaded (20)

PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
Digital Circuits, important subject in CS
contactparinay1
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 

Redis: REmote DIctionary Server

  • 1. Redis REmote DIctionary Server Ezra Zygmuntowicz #redis twitter: @ezmobius
  • 2. • Fast, in memory key/value store • STRING, LIST, SET & ZSET data types • Persistence via async snapshots or AOF • Perfect Data Structure/State/Cache Server
  • 4. Data Structure Server Key:String => Value:String
  • 5. Data Structure Server Key:String => Value:String Key:String => Value:List
  • 6. Data Structure Server Key:String => Value:String Key:String => Value:List Key:String => Value:Set
  • 7. Data Structure Server Key:String => Value:String Key:String => Value:List Key:String => Value:Set Key:String => Value:Zset
  • 8. Operations on any Type • Exists, Del, Type • Keys, Randomkey • Rename, RenameNX • Dbsize, Select, Move, Flushdb, Flushall • TTL, Expire
  • 9. Operations on STRING’s • Get, Set, GetSet, SetNX • Mget, Mset, MgetNX, MsetNX • Incr, Incrby • Decr, Decrby
  • 10. Operations on LISTS’s • Atomic Operations: • Push/Pop • Index (array indexing) • Lrange, Ltrim, Llen • Blpop, Brpop • RpopLpush, BRpopLpush
  • 11. Operations on SET’s • Sadd, Srem, Spop, Smove • Scard, Sismember, Smembers, Srandmember • Sinter, Sinterstore, Sunion, Sunionstore • Sdiff, Sdiffstore
  • 12. Operations on ZSET’s • Zadd, Zrem, Zincrby • Zrange, Zrevrange • Zrangebyscore, Zcard • Zscore, Zremrangebyscore
  • 13. Seems cool, but what are the use cases? • Memcached on Steroids • Tag Clouds, Leaderboards • Stat collections, circular log buffers • Share state between processes • A/B testing • REDIStribute your load
  • 15. Example: Tagging SADD article:42 magick SADD article:42 unicorns SADD article:42 rainbows
  • 16. Example: Tagging SADD article:42 magick SADD article:42 unicorns SADD article:42 rainbows SADD article:12 magick SADD article:12 bar SADD article:12 qux SADD article:12 foo
  • 17. Example: Tagging SADD article:42 magick SADD article:42 unicorns SADD article:42 rainbows SADD article:12 magick SADD article:12 bar SADD article:12 qux SADD article:12 foo SINTER article:42 article:12 #=> magick
  • 18. Example: Fair Work Scheduler
  • 19. Example: Fair Work Scheduler
  • 20. Example: Fair Work Scheduler Each worker node periodically issues: ZADD worker:nodes 1.5 hostname 1.5 is the load ave of the host
  • 21. Example: Fair Work Scheduler Each worker node listens for work with: BLPOP hostname 10
  • 22. Example: Fair Work Scheduler When a producer wants to issue a work request: ZRANGE worker:nodes 0 2 returns top 3 least loaded nodes
  • 23. Example: Fair Work Scheduler Pick a random node out of the 3 least loaded nodes in order to add jitter so we don’t overload hosts
  • 24. Example: Fair Work Scheduler Then issue the work request: LPUSH hostname {“work”: {“foo”: “bar”}}
  • 25. Example: Fair Work Scheduler This setup uses ZSETS and the load average as a score in order to evenly distribute load across a farm of worker instances listening for jobs with BLPOP
  • 27. Example: AMQP message de-dupe Route messages through 2 separate rabbitmq brokers for redundancy Use redis for message de-dupe by tagging messages with a guid Use guid as key into redis Use SETNX when setting the guid key so first one wins and second messages gets discarded as already received
  • 28. Other Ideas • Distributed Lock Manager for process coordination • Full Text Inverted Index Lookups • Caching with extra smarts using lists, sets and atomic ops on said structures • Share data structures between multiple processes like a blackboard/tuplespace
  • 29. Speed • 110k GETS/SETS/second on average linux box • Mostly faster then memcached for same ops • Event Driven, can handle thousands of clients with epoll/kqueue support • Ops happen in memory, persistence is async so everything is very fast
  • 30. Persistence • Async Snapshots with configurable triggers • Append Only File: AOF • Redis 2.0 Virtual Memory
  • 31. Replication • Built in Master -> Slave Async replication • Create replication chains as needed
  • 32. Sharding • Client side sharding (like memcached) • Consistent ring hashing • Special case keys “foo{tags}” for operations on keys that must live on the same server in ruby client
  • 33. Redactor • Simple Actor Library based around Redis