SlideShare une entreprise Scribd logo
1  sur  27
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

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
 

Tendances (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)
 

Similaire à 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
 

Similaire à 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
 

Dernier

Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URLRuncy Oommen
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UbiTrack UK
 
UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPathCommunity
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfJamie (Taka) Wang
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioChristian Posta
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDELiveplex
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Commit University
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...DianaGray10
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Adtran
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxGDSC PJATK
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureEric D. Schabell
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostMatt Ray
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024SkyPlanner
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesDavid Newbury
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAshyamraj55
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfDaniel Santiago Silva Capera
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1DianaGray10
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IES VE
 
Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1DianaGray10
 
AI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarAI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarPrecisely
 

Dernier (20)

Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URL
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
 
UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation Developers
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and Istio
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptx
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability Adventure
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond Ontologies
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
 
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1UiPath Platform: The Backend Engine Powering Your Automation - Session 1
UiPath Platform: The Backend Engine Powering Your Automation - Session 1
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
 
Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1
 
AI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarAI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity Webinar
 

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