SlideShare una empresa de Scribd logo
1 de 27
Descargar para leer sin conexión
Introduction to


Rizky Abdilah, Mindtalk, @rizkyabdilah
Background
●   First release in March 2009
●   Created n maintained by Salvatore Sanfilippo
●   Mostly like Memcache, but with superset
    feature
●   In-memory database, key-value store
●   Open Source, BSD license
●   Sponsored by VMWare
What to Expect
●   Introduction to Redis:
    –   Data Structure Server, Key Feature
    –   Scale it up, Persistence, Who's using Redis
●   Redis and Memcache:
    –   Difference and Similarity
●   Tips with Redis
●   Redis on Mindtalk
Data Structure Server
●   String => “This   is String”
●   List => [“dog”,   “fox”, “dog”, “cat”]
●   Hash Table, Dictionary => {“name”: “Rizky”}
●   Set => set([“dog”,   “fox”, “cat”])
●   Sorted Set:
    –   set([(“dog”, 1), (“fox”, 4), (“cat”, 6)])
Key Features and Cool Stuff
●   All data is in memory (fast)
●   Support for persistence (rdb, aof)
●   Time To Live key (set expired)
●   Atomic Operation (INCR)
●   Lua Scripting (v2.6)
●   Pub/Sub
●   Awesome Community (Friendly)
Persistence
●   RDB, saved periodically or immediately,
    snashotting:
    –   save 900 1 - (15 min, 1 key changed)
    –   LZF compression
●   AOF (Append Only File, work like journal)
    –   appendonly yes
    –   Data safety, sacrificing speed
●   Background and Foreground save
Scale it Up
●   Master-slave, replication for HA
●   Single-threaded, multiple instance in one
    machine
●   Cluster? (to be released)
Who's Using Redis
●   Mindtalk
●   Twitter
●   Instagram
●   Github (Resque)
●   YouPorn
●   Etc (http://redis.io/topics/whos-using-redis)
BO (Basic Operation): “String”
●   SET => SET foo “bar”
●   GET => GET foo
●   INCR => INCR user_id
    –   Increment integer value by 1
●   INCRBY => INCRBY user_id 2
    –   Increment integer value by given amount
●   SETEX => SETEX foo 5 “bar”
    –   Set the value and the expired time
BO List: [“list”]
●   [L|R]PUSH => LPUSH jobs:android “bla”
    –   Prepend or append element in a list
●   [L|R]POP => LPOP jobs:android
    –   Remove and get first element in a list
●   LLEN => LLEN jobs:android
    –   Return length of a list
●   LRANGE => LRANGE jobs:android 0 -1
    –   Return all elements in a list
●   LINDEX => LINDEX jobs:android 0
    –   Get element in a list by its index
BO Hash Table: {“key”: “val”}
●   HSET => HSET user:$id name “Rizky”
    –   Set value in hash table
●   HGET => HGET user:$id name
    –   Return value inside hash table
●   HGETALL => HGETALL user:$id
    –   Return all data in hash table
BO Set: set([“1”])
●   SADD => SADD uniq_ip_visitor “192.168.1.1”
    –   Add element in Set
●   SREM => SREM uniq_ip_visitor “192.168.1.1”
    –   Remove element in Set
●   SMEMBERS => SMEMBERS uniq_ip_visitor
    –   Return all elements in Set
BO Sorted Set: set([(“cat”, 56)])
●   ZADD => ZADD post_view 1 $post_id
    –   Add element in sorted set
●   ZINCRBY => ZINCRBY post_view 1 $post_id
    –   increment
●   ZRANGE => ZRANGE post_view 0 -1
    –   Return all data with ascending sort
●   ZREVRANGE => ZREVRANGE post_view 0 -1
    –   Return all data with descending sort
Advanced Operation
●   Intersect, Diff, Union Set (join?)
●   Intersect, Diff, Union Sorted Set
Advanced Operation [2]
●   Blocking List: B[L|R]POP
●   Multi SET/GET
●   Bit Operation: SETBIT
●   Bitwise Operation: BITOP
●   Append String: APPEND
●   Scription: EVAL
●   Etc (http://redis.io/commands)
Redis and Memcache: Similarity
●   RAM only
●   TTL Support
●   Communicate via TCP
Redis and Memcache: “Difference”
●   Single vs Multithreaded
●   Redis Persistence concern
●   Redis native support for list, hash, set, etc
●   Redis native support for Pub/Sub
●   Memcache support for UDP while Redis
    concern with durability and data safety
    (TCP only)
Tips with Redis
●   Use hash table (HSET) to compress memory
    usage, instead of using plain String (SET) -
    http://mndt.lk/Vr7L - 70MB (SET) vs 16MB
    (HSET)
●   Hash and list ziplist max-size, around 1024
    –   Redis will encode the value inside hash table if the
        biggest entry didn't exceed the threshold (config)
    –   hash-max-ziplist-entries and list-max-
        ziplist-entries
Redis Way
●   “But the Redis Way is that the user must
    understand how things work so that he is able
    to pick the best compromise, and to
    understand how the system will behave
    exactly.” - Salvatore Sanfilippo
●   So, Redis or Memcache?
Redis on Mindtalk
●   Cache
●   REST API Rate Limiting
●   Message Queue (digaku.rpush)
●   Most Viewed Article (last 2 hour)
REST API Rate Limiting
●   Goal: To limit API Call from Client
Message Queue
●   Implemented using BLPOP and RPUSH
    command
Most Viewed Article (last 2 Hour)
Most Viewed Article (last 2 Hour)
●   Batch processing log-file, result saved in
    Redis using Sorted Set
●   ZADD article_view:$hour $count $post_id
●   ZREVRANGE article_view:$hour 0 9
Pub/Sub: digaku.notifier
Pub/Sub: digaku.notifier
●   Long-pooling in client and server
●   Implemented using Redis PUBLISH and
    SUBSCRIBE command
Introduction to Redis

Más contenido relacionado

La actualidad más candente

Linux administration training
Linux administration trainingLinux administration training
Linux administration trainingiman darabi
 
Kicking ass with redis
Kicking ass with redisKicking ass with redis
Kicking ass with redisDvir Volk
 
Extend Redis with Modules
Extend Redis with ModulesExtend Redis with Modules
Extend Redis with ModulesItamar Haber
 
Centralized + Unified Logging
Centralized + Unified LoggingCentralized + Unified Logging
Centralized + Unified LoggingGabor Kozma
 
Hvordan sette opp en OAI-PMH metadata-innhøster
Hvordan sette opp en OAI-PMH metadata-innhøsterHvordan sette opp en OAI-PMH metadata-innhøster
Hvordan sette opp en OAI-PMH metadata-innhøsterLibriotech
 
Redis SoCraTes 2014
Redis SoCraTes 2014Redis SoCraTes 2014
Redis SoCraTes 2014steffenbauer
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to RedisDvir Volk
 
JDD 2017: Nginx + Lua = OpenResty (Marcin Stożek)
JDD 2017: Nginx + Lua = OpenResty (Marcin Stożek)JDD 2017: Nginx + Lua = OpenResty (Marcin Stożek)
JDD 2017: Nginx + Lua = OpenResty (Marcin Stożek)PROIDEA
 
Everything you always wanted to know about Redis but were afraid to ask
Everything you always wanted to know about Redis but were afraid to askEverything you always wanted to know about Redis but were afraid to ask
Everything you always wanted to know about Redis but were afraid to askCarlos Abalde
 
Fluentd unified logging layer
Fluentd   unified logging layerFluentd   unified logging layer
Fluentd unified logging layerKiyoto Tamura
 
Object Storage with Gluster
Object Storage with GlusterObject Storage with Gluster
Object Storage with GlusterGluster.org
 
Building Awesome CLI apps in Go
Building Awesome CLI apps in GoBuilding Awesome CLI apps in Go
Building Awesome CLI apps in GoSteven Francia
 
Redis And python at pycon_2011
Redis And python at pycon_2011Redis And python at pycon_2011
Redis And python at pycon_2011sunilar0ra
 
Redis - Usability and Use Cases
Redis - Usability and Use CasesRedis - Usability and Use Cases
Redis - Usability and Use CasesFabrizio Farinacci
 
SaltStack – (Not) just another Automation & Remote Execution Tool
SaltStack – (Not) just another Automation & Remote Execution ToolSaltStack – (Not) just another Automation & Remote Execution Tool
SaltStack – (Not) just another Automation & Remote Execution Toolinovex GmbH
 
(Practical) linux 101
(Practical) linux 101(Practical) linux 101
(Practical) linux 101Arie Bregman
 
Don’t turn your logs into cuneiform
Don’t turn your logs into cuneiformDon’t turn your logs into cuneiform
Don’t turn your logs into cuneiformAndrey Rebrov
 

La actualidad más candente (20)

Linux administration training
Linux administration trainingLinux administration training
Linux administration training
 
Kicking ass with redis
Kicking ass with redisKicking ass with redis
Kicking ass with redis
 
Extend Redis with Modules
Extend Redis with ModulesExtend Redis with Modules
Extend Redis with Modules
 
Centralized + Unified Logging
Centralized + Unified LoggingCentralized + Unified Logging
Centralized + Unified Logging
 
Hvordan sette opp en OAI-PMH metadata-innhøster
Hvordan sette opp en OAI-PMH metadata-innhøsterHvordan sette opp en OAI-PMH metadata-innhøster
Hvordan sette opp en OAI-PMH metadata-innhøster
 
Redis SoCraTes 2014
Redis SoCraTes 2014Redis SoCraTes 2014
Redis SoCraTes 2014
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
JDD 2017: Nginx + Lua = OpenResty (Marcin Stożek)
JDD 2017: Nginx + Lua = OpenResty (Marcin Stożek)JDD 2017: Nginx + Lua = OpenResty (Marcin Stożek)
JDD 2017: Nginx + Lua = OpenResty (Marcin Stożek)
 
Everything you always wanted to know about Redis but were afraid to ask
Everything you always wanted to know about Redis but were afraid to askEverything you always wanted to know about Redis but were afraid to ask
Everything you always wanted to know about Redis but were afraid to ask
 
Fluentd unified logging layer
Fluentd   unified logging layerFluentd   unified logging layer
Fluentd unified logging layer
 
Object Storage with Gluster
Object Storage with GlusterObject Storage with Gluster
Object Storage with Gluster
 
Building Awesome CLI apps in Go
Building Awesome CLI apps in GoBuilding Awesome CLI apps in Go
Building Awesome CLI apps in Go
 
MongoDB & PHP
MongoDB & PHPMongoDB & PHP
MongoDB & PHP
 
Redis And python at pycon_2011
Redis And python at pycon_2011Redis And python at pycon_2011
Redis And python at pycon_2011
 
Redis - Usability and Use Cases
Redis - Usability and Use CasesRedis - Usability and Use Cases
Redis - Usability and Use Cases
 
Node.js in production
Node.js in productionNode.js in production
Node.js in production
 
SaltStack – (Not) just another Automation & Remote Execution Tool
SaltStack – (Not) just another Automation & Remote Execution ToolSaltStack – (Not) just another Automation & Remote Execution Tool
SaltStack – (Not) just another Automation & Remote Execution Tool
 
(Practical) linux 101
(Practical) linux 101(Practical) linux 101
(Practical) linux 101
 
Don’t turn your logs into cuneiform
Don’t turn your logs into cuneiformDon’t turn your logs into cuneiform
Don’t turn your logs into cuneiform
 
Nodejs - A quick tour (v5)
Nodejs - A quick tour (v5)Nodejs - A quick tour (v5)
Nodejs - A quick tour (v5)
 

Similar a Introduction to Redis

Postgres & Redis Sitting in a Tree- Rimas Silkaitis, Heroku
Postgres & Redis Sitting in a Tree- Rimas Silkaitis, HerokuPostgres & Redis Sitting in a Tree- Rimas Silkaitis, Heroku
Postgres & Redis Sitting in a Tree- Rimas Silkaitis, HerokuRedis Labs
 
Redis Modules - Redis India Tour - 2017
Redis Modules - Redis India Tour - 2017Redis Modules - Redis India Tour - 2017
Redis Modules - Redis India Tour - 2017HashedIn Technologies
 
PostgreSQL and Redis - talk at pgcon 2013
PostgreSQL and Redis - talk at pgcon 2013PostgreSQL and Redis - talk at pgcon 2013
PostgreSQL and Redis - talk at pgcon 2013Andrew Dunstan
 
An Introduction to Redis for .NET Developers.pdf
An Introduction to Redis for .NET Developers.pdfAn Introduction to Redis for .NET Developers.pdf
An Introduction to Redis for .NET Developers.pdfStephen Lorello
 
Introduction to redis
Introduction to redisIntroduction to redis
Introduction to redisTanu Siwag
 
Apache pig presentation_siddharth_mathur
Apache pig presentation_siddharth_mathurApache pig presentation_siddharth_mathur
Apache pig presentation_siddharth_mathurSiddharth Mathur
 
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 RedisRicard Clau
 
Apache pig presentation_siddharth_mathur
Apache pig presentation_siddharth_mathurApache pig presentation_siddharth_mathur
Apache pig presentation_siddharth_mathurSiddharth Mathur
 
power point presentation on pig -hadoop framework
power point presentation on pig -hadoop frameworkpower point presentation on pig -hadoop framework
power point presentation on pig -hadoop frameworkbhargavi804095
 
What’s new in 9.6, by PostgreSQL contributor
What’s new in 9.6, by PostgreSQL contributorWhat’s new in 9.6, by PostgreSQL contributor
What’s new in 9.6, by PostgreSQL contributorMasahiko Sawada
 
Redis everywhere - PHP London
Redis everywhere - PHP LondonRedis everywhere - PHP London
Redis everywhere - PHP LondonRicard Clau
 
Creating Secure VM (Comarison between Intel and AMD, and one more thing...) -...
Creating Secure VM (Comarison between Intel and AMD, and one more thing...) -...Creating Secure VM (Comarison between Intel and AMD, and one more thing...) -...
Creating Secure VM (Comarison between Intel and AMD, and one more thing...) -...Tsukasa Oi
 
HadoopThe Hadoop Java Software Framework
HadoopThe Hadoop Java Software FrameworkHadoopThe Hadoop Java Software Framework
HadoopThe Hadoop Java Software FrameworkThoughtWorks
 

Similar a Introduction to Redis (20)

Postgres & Redis Sitting in a Tree- Rimas Silkaitis, Heroku
Postgres & Redis Sitting in a Tree- Rimas Silkaitis, HerokuPostgres & Redis Sitting in a Tree- Rimas Silkaitis, Heroku
Postgres & Redis Sitting in a Tree- Rimas Silkaitis, Heroku
 
Python redis talk
Python redis talkPython redis talk
Python redis talk
 
L3.fa14.ppt
L3.fa14.pptL3.fa14.ppt
L3.fa14.ppt
 
R - the language
R - the languageR - the language
R - the language
 
Redis Modules - Redis India Tour - 2017
Redis Modules - Redis India Tour - 2017Redis Modules - Redis India Tour - 2017
Redis Modules - Redis India Tour - 2017
 
PostgreSQL and Redis - talk at pgcon 2013
PostgreSQL and Redis - talk at pgcon 2013PostgreSQL and Redis - talk at pgcon 2013
PostgreSQL and Redis - talk at pgcon 2013
 
An Introduction to Redis for .NET Developers.pdf
An Introduction to Redis for .NET Developers.pdfAn Introduction to Redis for .NET Developers.pdf
An Introduction to Redis for .NET Developers.pdf
 
Introduction to redis
Introduction to redisIntroduction to redis
Introduction to redis
 
Apache pig presentation_siddharth_mathur
Apache pig presentation_siddharth_mathurApache pig presentation_siddharth_mathur
Apache pig presentation_siddharth_mathur
 
Redis
RedisRedis
Redis
 
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
 
Apache pig presentation_siddharth_mathur
Apache pig presentation_siddharth_mathurApache pig presentation_siddharth_mathur
Apache pig presentation_siddharth_mathur
 
Training
TrainingTraining
Training
 
power point presentation on pig -hadoop framework
power point presentation on pig -hadoop frameworkpower point presentation on pig -hadoop framework
power point presentation on pig -hadoop framework
 
What’s new in 9.6, by PostgreSQL contributor
What’s new in 9.6, by PostgreSQL contributorWhat’s new in 9.6, by PostgreSQL contributor
What’s new in 9.6, by PostgreSQL contributor
 
Redis everywhere - PHP London
Redis everywhere - PHP LondonRedis everywhere - PHP London
Redis everywhere - PHP London
 
mapreduce ppt.ppt
mapreduce ppt.pptmapreduce ppt.ppt
mapreduce ppt.ppt
 
Creating Secure VM (Comarison between Intel and AMD, and one more thing...) -...
Creating Secure VM (Comarison between Intel and AMD, and one more thing...) -...Creating Secure VM (Comarison between Intel and AMD, and one more thing...) -...
Creating Secure VM (Comarison between Intel and AMD, and one more thing...) -...
 
HadoopThe Hadoop Java Software Framework
HadoopThe Hadoop Java Software FrameworkHadoopThe Hadoop Java Software Framework
HadoopThe Hadoop Java Software Framework
 
Apache Cassandra at Macys
Apache Cassandra at MacysApache Cassandra at Macys
Apache Cassandra at Macys
 

Último

Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
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 SolutionsEnterprise Knowledge
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
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 interpreternaman860154
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
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 MenDelhi Call girls
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
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 textsMaria Levchenko
 
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 WorkerThousandEyes
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
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 RobisonAnna Loughnan Colquhoun
 

Último (20)

Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
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
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
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
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
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
 
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
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 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
 

Introduction to Redis

  • 1. Introduction to Rizky Abdilah, Mindtalk, @rizkyabdilah
  • 2. Background ● First release in March 2009 ● Created n maintained by Salvatore Sanfilippo ● Mostly like Memcache, but with superset feature ● In-memory database, key-value store ● Open Source, BSD license ● Sponsored by VMWare
  • 3. What to Expect ● Introduction to Redis: – Data Structure Server, Key Feature – Scale it up, Persistence, Who's using Redis ● Redis and Memcache: – Difference and Similarity ● Tips with Redis ● Redis on Mindtalk
  • 4. Data Structure Server ● String => “This is String” ● List => [“dog”, “fox”, “dog”, “cat”] ● Hash Table, Dictionary => {“name”: “Rizky”} ● Set => set([“dog”, “fox”, “cat”]) ● Sorted Set: – set([(“dog”, 1), (“fox”, 4), (“cat”, 6)])
  • 5. Key Features and Cool Stuff ● All data is in memory (fast) ● Support for persistence (rdb, aof) ● Time To Live key (set expired) ● Atomic Operation (INCR) ● Lua Scripting (v2.6) ● Pub/Sub ● Awesome Community (Friendly)
  • 6. Persistence ● RDB, saved periodically or immediately, snashotting: – save 900 1 - (15 min, 1 key changed) – LZF compression ● AOF (Append Only File, work like journal) – appendonly yes – Data safety, sacrificing speed ● Background and Foreground save
  • 7. Scale it Up ● Master-slave, replication for HA ● Single-threaded, multiple instance in one machine ● Cluster? (to be released)
  • 8. Who's Using Redis ● Mindtalk ● Twitter ● Instagram ● Github (Resque) ● YouPorn ● Etc (http://redis.io/topics/whos-using-redis)
  • 9. BO (Basic Operation): “String” ● SET => SET foo “bar” ● GET => GET foo ● INCR => INCR user_id – Increment integer value by 1 ● INCRBY => INCRBY user_id 2 – Increment integer value by given amount ● SETEX => SETEX foo 5 “bar” – Set the value and the expired time
  • 10. BO List: [“list”] ● [L|R]PUSH => LPUSH jobs:android “bla” – Prepend or append element in a list ● [L|R]POP => LPOP jobs:android – Remove and get first element in a list ● LLEN => LLEN jobs:android – Return length of a list ● LRANGE => LRANGE jobs:android 0 -1 – Return all elements in a list ● LINDEX => LINDEX jobs:android 0 – Get element in a list by its index
  • 11. BO Hash Table: {“key”: “val”} ● HSET => HSET user:$id name “Rizky” – Set value in hash table ● HGET => HGET user:$id name – Return value inside hash table ● HGETALL => HGETALL user:$id – Return all data in hash table
  • 12. BO Set: set([“1”]) ● SADD => SADD uniq_ip_visitor “192.168.1.1” – Add element in Set ● SREM => SREM uniq_ip_visitor “192.168.1.1” – Remove element in Set ● SMEMBERS => SMEMBERS uniq_ip_visitor – Return all elements in Set
  • 13. BO Sorted Set: set([(“cat”, 56)]) ● ZADD => ZADD post_view 1 $post_id – Add element in sorted set ● ZINCRBY => ZINCRBY post_view 1 $post_id – increment ● ZRANGE => ZRANGE post_view 0 -1 – Return all data with ascending sort ● ZREVRANGE => ZREVRANGE post_view 0 -1 – Return all data with descending sort
  • 14. Advanced Operation ● Intersect, Diff, Union Set (join?) ● Intersect, Diff, Union Sorted Set
  • 15. Advanced Operation [2] ● Blocking List: B[L|R]POP ● Multi SET/GET ● Bit Operation: SETBIT ● Bitwise Operation: BITOP ● Append String: APPEND ● Scription: EVAL ● Etc (http://redis.io/commands)
  • 16. Redis and Memcache: Similarity ● RAM only ● TTL Support ● Communicate via TCP
  • 17. Redis and Memcache: “Difference” ● Single vs Multithreaded ● Redis Persistence concern ● Redis native support for list, hash, set, etc ● Redis native support for Pub/Sub ● Memcache support for UDP while Redis concern with durability and data safety (TCP only)
  • 18. Tips with Redis ● Use hash table (HSET) to compress memory usage, instead of using plain String (SET) - http://mndt.lk/Vr7L - 70MB (SET) vs 16MB (HSET) ● Hash and list ziplist max-size, around 1024 – Redis will encode the value inside hash table if the biggest entry didn't exceed the threshold (config) – hash-max-ziplist-entries and list-max- ziplist-entries
  • 19. Redis Way ● “But the Redis Way is that the user must understand how things work so that he is able to pick the best compromise, and to understand how the system will behave exactly.” - Salvatore Sanfilippo ● So, Redis or Memcache?
  • 20. Redis on Mindtalk ● Cache ● REST API Rate Limiting ● Message Queue (digaku.rpush) ● Most Viewed Article (last 2 hour)
  • 21. REST API Rate Limiting ● Goal: To limit API Call from Client
  • 22. Message Queue ● Implemented using BLPOP and RPUSH command
  • 23. Most Viewed Article (last 2 Hour)
  • 24. Most Viewed Article (last 2 Hour) ● Batch processing log-file, result saved in Redis using Sorted Set ● ZADD article_view:$hour $count $post_id ● ZREVRANGE article_view:$hour 0 9
  • 26. Pub/Sub: digaku.notifier ● Long-pooling in client and server ● Implemented using Redis PUBLISH and SUBSCRIBE command