SlideShare una empresa de Scribd logo
1 de 49
Redis - Fast and Furious
N✮SQL Berlin




Mathias Meyer, 22.10.2009
Peritor GmbH
Self
I work at
   
   Peritor in Berlin
I tweet
 
   
   @roidrage
I code at
   
   http://github.com/mattmatt
I blog at
   
   http://paperplanes.de




                                              2
Peritor
              Working on




          http://scalarium.com


                                 3
Redis - Key-Value Store
Simple, yet awesome
Fast, yet nonvolatile




code.google.com/p/redis
                          4
Redis




REmote DIctionary Server




                           5
Redis




Went public in March 2009
Just reached 1.0




                            6
Redis




< 6000 lines of code




                       7
Redis




And the code is simple




                         8
Redis




No threading, just one process




                                 9
Redis




Like Memcached, only awesome




                               10
Redis




Simple and efficient text-based protocol
(just like grandma and Memcached used to make)




                                                 11
Redis Protocol




                 12
Redis Protocol




redis[“key”] = “value”




                         13
Redis Protocol




Duh!




                 14
Redis Protocol




Values can be strings, lists or sets




                                       15
Redis Protocol - Special Ops
Push and pop elements
(atomic)
Fetch arbitrary set and
array elements
Sorting




                               16
Redis Protocol

set foo 4
1000
+OK




                 17
Redis Protocol

set foo 4
                 Request
1000
+OK              Response




                            17
Redis Protocol

get foo
$4
1000


get bar
$-1




                 18
Redis Protocol

get foo          Request
$4
                 Response
1000


get bar          Reques
$-1              Respons



                            18
Redis Protocol

incr foo
:1001


type foo
+string




                 19
Redis Protocol - Lists

lpush pizza 4
fury
+OK


rpush pizza 8
ortolana
+OK


                         20
Redis Protocol - Lists

lrange pizza 0 1
*2
$4
fury
$8
ortolana




                         21
Redis Protocol - Lists

lrange pizza 0 1         Request
*2
$4
fury                     Response
$8
ortolana




                                    21
Redis Protocol - Sets

sadd mq 8
rabbitmq
:1


sadd mq 6
zeromq
:1


                        22
Redis Protocol - Sets

smembers mq
*2
$6
zeromq
$8
rabbitmq




                        23
Redis Protocol - Sets

sort mq alpha
*2
$8
rabbitmq
$6
zeromq




                        24
Redis Protocol - The Rest
Random list/set access
Intersections, Unions
Monitoring
Controlling the Server
Multi-Set Commands




                            25
Redis




Data is held in memory, but can be persisted




                                               26
Redis Key-Value Database

Persistent
Asynchronous
Just like Super Pursuit
Mode




                           27
Redis Database




Data is written to disk asynchronously




                                         28
Redis Database


                              Redis Server

                                Dump
                               Database

                     fork()
      Redis Server             rename()



                                 exit()




                                             29
Redis Database




save 900 1
save 300 10
save 60 100000



                 30
Replication

1 Master - N Slaves
Asynchronous on Master
Synchronous on Slave




                         31
Redis Replication
Like dumping the database, only to a different file descriptor.




                                                                 32
Redis Replication


                   Redis Master




           Redis Slave         Redis Slave




                     Redis Slave         Redis Slave




                                                       33
Redis - Scaling




Horizontal
 • Run multiple Redis processes
 • Use HashRing (e.g. in redis-rb)




                                     34
Redis - Scaling




Vertical
 • Master-Slave setup
 • Fetch data from any slave (e.g. random)




                                             35
To Redis, or not to Redis?




                             36
As always, it depends




                        37
To Redis




Caching
Statistical data
Recoverable state
Worker queue

                    38
Not to Redis




100% consistent dataset required
Data is larger than memory



                                   39
Redis Use Cases




Nanite - A self-assembling cluster of Ruby
daemons




                                             40
The most important




                     41
Is it faster than




                    42
No, but fast enough for you
(if you need the extra features)




                                   43
Redis
Simple, fast, awesome.




                         44
Questions




            45
Peritor GmbH
Blücherstr. 22, Hof III Aufgang 6
10961 Berlin
Tel.: +49 (0)30 69 20 09 84 0
Fax: +49 (0)30 69 20 09 84 9
Internet: www.peritor.com
E-Mail: info@peritor.com



© Peritor GmbH - Alle Rechte Vorbehalten

Más contenido relacionado

La actualidad más candente

المشروع الأول
المشروع الأولالمشروع الأول
المشروع الأول
Mai Saleh
 

La actualidad más candente (20)

PostgreSQL performance archaeology
PostgreSQL performance archaeologyPostgreSQL performance archaeology
PostgreSQL performance archaeology
 
Sp ch05
Sp ch05Sp ch05
Sp ch05
 
Gluster fs for_storage_admins_glusterfs_meetup_07_feb
Gluster fs for_storage_admins_glusterfs_meetup_07_febGluster fs for_storage_admins_glusterfs_meetup_07_feb
Gluster fs for_storage_admins_glusterfs_meetup_07_feb
 
PostgreSQL na EXT4, XFS, BTRFS a ZFS / FOSDEM PgDay 2016
PostgreSQL na EXT4, XFS, BTRFS a ZFS / FOSDEM PgDay 2016PostgreSQL na EXT4, XFS, BTRFS a ZFS / FOSDEM PgDay 2016
PostgreSQL na EXT4, XFS, BTRFS a ZFS / FOSDEM PgDay 2016
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
OS入門 Fukuoka.php vol.18 LT資料
OS入門 Fukuoka.php vol.18 LT資料OS入門 Fukuoka.php vol.18 LT資料
OS入門 Fukuoka.php vol.18 LT資料
 
Database Architectures and Hypertable
Database Architectures and HypertableDatabase Architectures and Hypertable
Database Architectures and Hypertable
 
Hypertable - massively scalable nosql database
Hypertable - massively scalable nosql databaseHypertable - massively scalable nosql database
Hypertable - massively scalable nosql database
 
المشروع الأول
المشروع الأولالمشروع الأول
المشروع الأول
 
tokyotalk
tokyotalktokyotalk
tokyotalk
 
[Pgday.Seoul 2017] 3. PostgreSQL WAL Buffers, Clog Buffers Deep Dive - 이근오
[Pgday.Seoul 2017] 3. PostgreSQL WAL Buffers, Clog Buffers Deep Dive - 이근오[Pgday.Seoul 2017] 3. PostgreSQL WAL Buffers, Clog Buffers Deep Dive - 이근오
[Pgday.Seoul 2017] 3. PostgreSQL WAL Buffers, Clog Buffers Deep Dive - 이근오
 
บทท 7
บทท   7บทท   7
บทท 7
 
ulimit
ulimit ulimit
ulimit
 
Bsdtw17: mariusz zaborski: case studies of sandboxing base system with capsicum
Bsdtw17: mariusz zaborski: case studies of sandboxing base system with capsicumBsdtw17: mariusz zaborski: case studies of sandboxing base system with capsicum
Bsdtw17: mariusz zaborski: case studies of sandboxing base system with capsicum
 
Linux Tor Browser kurulum
Linux Tor Browser kurulumLinux Tor Browser kurulum
Linux Tor Browser kurulum
 
EncExec: Secure In-Cache Execution
EncExec: Secure In-Cache ExecutionEncExec: Secure In-Cache Execution
EncExec: Secure In-Cache Execution
 
C++ CoreHard Autumn 2018. Знай свое "железо": иерархия памяти - Александр Титов
C++ CoreHard Autumn 2018. Знай свое "железо": иерархия памяти - Александр ТитовC++ CoreHard Autumn 2018. Знай свое "железо": иерархия памяти - Александр Титов
C++ CoreHard Autumn 2018. Знай свое "железо": иерархия памяти - Александр Титов
 
OpenZFS send and receive
OpenZFS send and receiveOpenZFS send and receive
OpenZFS send and receive
 
Linux Kernel 개발참여방법과 문화 (Contribution)
Linux Kernel 개발참여방법과 문화 (Contribution)Linux Kernel 개발참여방법과 문화 (Contribution)
Linux Kernel 개발참여방법과 문화 (Contribution)
 
[Paper Reading] Efficient Query Processing with Optimistically Compressed Has...
[Paper Reading] Efficient Query Processing with Optimistically Compressed Has...[Paper Reading] Efficient Query Processing with Optimistically Compressed Has...
[Paper Reading] Efficient Query Processing with Optimistically Compressed Has...
 

Similar a Redis - N✮SQL Berlin

Cluster Computing with Dryad
Cluster Computing with DryadCluster Computing with Dryad
Cluster Computing with Dryad
butest
 
RedisConf18 - Active-Active Geo-Distributed Apps with Redis CRDTs (conflict f...
RedisConf18 - Active-Active Geo-Distributed Apps with Redis CRDTs (conflict f...RedisConf18 - Active-Active Geo-Distributed Apps with Redis CRDTs (conflict f...
RedisConf18 - Active-Active Geo-Distributed Apps with Redis CRDTs (conflict f...
Redis Labs
 
What CloudStackers Need To Know About LINSTOR/DRBD
What CloudStackers Need To Know About LINSTOR/DRBDWhat CloudStackers Need To Know About LINSTOR/DRBD
What CloudStackers Need To Know About LINSTOR/DRBD
ShapeBlue
 

Similar a Redis - N✮SQL Berlin (20)

Redis memcached pdf
Redis memcached pdfRedis memcached pdf
Redis memcached pdf
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
NoSQL - Motivation and Overview
NoSQL - Motivation and OverviewNoSQL - Motivation and Overview
NoSQL - Motivation and Overview
 
Developing a Redis Module - Hackathon Kickoff
 Developing a Redis Module - Hackathon Kickoff Developing a Redis Module - Hackathon Kickoff
Developing a Redis Module - Hackathon Kickoff
 
What's new with enterprise Redis - Leena Joshi, Redis Labs
What's new with enterprise Redis - Leena Joshi, Redis LabsWhat's new with enterprise Redis - Leena Joshi, Redis Labs
What's new with enterprise Redis - Leena Joshi, Redis Labs
 
Boosting Machine Learning with Redis Modules and Spark
Boosting Machine Learning with Redis Modules and SparkBoosting Machine Learning with Redis Modules and Spark
Boosting Machine Learning with Redis Modules and Spark
 
Redis by-hari
Redis by-hariRedis by-hari
Redis by-hari
 
10 Ways to Scale with Redis - LA Redis Meetup 2019
10 Ways to Scale with Redis - LA Redis Meetup 201910 Ways to Scale with Redis - LA Redis Meetup 2019
10 Ways to Scale with Redis - LA Redis Meetup 2019
 
Building Scalable, Distributed Job Queues with Redis and Redis::Client
Building Scalable, Distributed Job Queues with Redis and Redis::ClientBuilding Scalable, Distributed Job Queues with Redis and Redis::Client
Building Scalable, Distributed Job Queues with Redis and Redis::Client
 
Redis Modules - Redis India Tour - 2017
Redis Modules - Redis India Tour - 2017Redis Modules - Redis India Tour - 2017
Redis Modules - Redis India Tour - 2017
 
Orchestrating Redis & K8s Operators
Orchestrating Redis & K8s OperatorsOrchestrating Redis & K8s Operators
Orchestrating Redis & K8s Operators
 
Cluster Computing with Dryad
Cluster Computing with DryadCluster Computing with Dryad
Cluster Computing with Dryad
 
10 Ways to Scale Your Website Silicon Valley Code Camp 2019
10 Ways to Scale Your Website Silicon Valley Code Camp 201910 Ways to Scale Your Website Silicon Valley Code Camp 2019
10 Ways to Scale Your Website Silicon Valley Code Camp 2019
 
RedisConf18 - Active-Active Geo-Distributed Apps with Redis CRDTs (conflict f...
RedisConf18 - Active-Active Geo-Distributed Apps with Redis CRDTs (conflict f...RedisConf18 - Active-Active Geo-Distributed Apps with Redis CRDTs (conflict f...
RedisConf18 - Active-Active Geo-Distributed Apps with Redis CRDTs (conflict f...
 
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
 
Redis 101
Redis 101Redis 101
Redis 101
 
Extend Redis with Modules
Extend Redis with ModulesExtend Redis with Modules
Extend Redis with Modules
 
RedisConf 2016 - Redis usage and ecosystem
RedisConf 2016 - Redis usage and ecosystemRedisConf 2016 - Redis usage and ecosystem
RedisConf 2016 - Redis usage and ecosystem
 
What CloudStackers Need To Know About LINSTOR/DRBD
What CloudStackers Need To Know About LINSTOR/DRBDWhat CloudStackers Need To Know About LINSTOR/DRBD
What CloudStackers Need To Know About LINSTOR/DRBD
 
Fun with Ruby and Redis
Fun with Ruby and RedisFun with Ruby and Redis
Fun with Ruby and Redis
 

Más de mattmatt (6)

Cloud Conf - Datenbanken in der Cloud
Cloud Conf - Datenbanken in der CloudCloud Conf - Datenbanken in der Cloud
Cloud Conf - Datenbanken in der Cloud
 
Mein Freund Der Legacy Code
Mein Freund Der Legacy CodeMein Freund Der Legacy Code
Mein Freund Der Legacy Code
 
RabbitMQ And Nanite
RabbitMQ And NaniteRabbitMQ And Nanite
RabbitMQ And Nanite
 
The Current State of Asynchronous Processing With Ruby
The Current State of Asynchronous Processing With RubyThe Current State of Asynchronous Processing With Ruby
The Current State of Asynchronous Processing With Ruby
 
Upstream Goes To Maine
Upstream Goes To MaineUpstream Goes To Maine
Upstream Goes To Maine
 
Smalltalk on Git
Smalltalk on GitSmalltalk on Git
Smalltalk on Git
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Último (20)

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
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
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
 
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
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
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
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 

Redis - N✮SQL Berlin

Notas del editor

  1. (that&amp;#x2019;s not a lot, even for C code)
  2. (even for C code)
  3. (old school)
  4. Strings can&amp;#x2019;t be longer than 1GB Lists are implemented as doubly linked lists Sets are stored as hashesh
  5. Different datatypes require using different command sets. Not doing so will raise errors.
  6. Get is wicked fast.
  7. incr requires parsing of the value
  8. lset is destructive, replaces the existing element
  9. List access only through ranges, getting a whole list requires you to fetch the length first.
  10. Data in Redis isn&amp;#x2019;t volatile, at least most of the time
  11. ..and only if necessary. Data is put into a single dump file.
  12. Database is dumped into a tempfile, then renamed. It&amp;#x2019;s possible to loose data in the dumping period.
  13. Writes out data after x seconds if at least y number of keys have changed. On startup the dump is reread into memory.
  14. Fast, more complex, datatypes
  15. Redis stores the daemon state and is used for service lookup.