SlideShare uma empresa Scribd logo
1 de 27
Baixar para ler offline
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

Mais conteúdo relacionado

Mais procurados

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
 

Mais procurados (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)
 

Semelhante 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
 

Semelhante 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

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
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
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.pdfsudhanshuwaghmare1
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
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
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
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
 

Último (20)

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
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
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
 

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