SlideShare une entreprise Scribd logo
1  sur  30
Télécharger pour lire hors ligne
+

Redis {beyond the basics}
Presented by
Steph ☺
+

Outline
■

Revisiting Redis

■

Keeping data safe
■
■

Replication

■

Replacing Failed Master

■

■

Persistence

Transaction

Reducing memory use
■
■

Intlist

■

■

Ziplist
Sharding

Scaling
+

Redis
■

In-memory remote database

■

Advanced key-value store

■

Data-structure server

■

Offers
■

High Performance

■

Replication

■

Unique data model
+

Snapshotting
{Persistence}
■

Data is taken as it exists and is written to the disk

■

Point-in-time copy of in-memory data

■

Backup & transfer to other server

■

Written to file in “dbfilename” stored in “dir”

■

Until next snapshot is taken, last snapshot can be lost if redis
crashes
+

Snapshotting
{Persistence}
Initiating Snapshots
■

bgsave

■

SAVE

■

Save lines save 60 10000

■

SHUTDOWN / TERM

■

SYNC
+

Snapshotting

■

How often to perform an automatic snapshot

■

Accept writes on failure

■

Snapshot compression

■

What to name the snapshot on the disk
+

Append Only File (AOF)
{Persistence}
■

Copies incoming write commands as it happens

■

Records data changes at the end of the backup file

■

Data set could be recovered with replaying AOF

■

“append only yes”

■

“appendfsyc always”

■

Limited by disk performance
+

Append Only File (AOF)

■

Option to use AOF

■

Occurrence of sync writes to disk

■

Option to sync during AOF compaction

■

Occurrence of AOF compaction
+

Replication
■

Method where other servers receive an updated copy of the
data as its being written

■

Replicas can service read queries

■

Single master database sends writes out to multiple slave
databases

■

Set operations can take seconds to finish
+

Replication
■

Configuring for replication
On master, ensure that the path and filename are writable
by redis process
■ Enable slaving : slaveof host port
■ In a running system, redis can be stopped slaving or
connect to a different master
■ New / Transfer connection: slaveof host port
■ Stop data update: SLAVEOF no one
■
+

Replication
{SLAVE to MASTER Connection}
+

Replication
{Redis Master-Slave Replica Tree}
+

Replacing Failed Master
{Scenario and Solution}
■

What will we do in case of system failure?

■

Scenario
■
■

Machine A loses network connectivity

■

■

Machine A – Redis Master, Machine B – Redis Slave
Machine C has Redis, but no copy of data

Solution A
■

Make a fresh snapshot using Machine B using SAVE

■

Copy snapshot to Machine C

■

Start Redis on Machine C

■

Tell Machine B to be a slave of Machine C
+

Replacing Failed Master
{Sequence of Commands}
+

Replacing Failed Master
{Scenario and Solution}
■

What will we do in case of system failure?

■

Solution B
■

Use Machine B (Slave) as Master

■

Create a new Slave (maybe Machine C)

■

Update client configuration to read/write to proper servers

■

(optional) update server configuration if restart is needed
+

Transactions
■

Begin transaction with MULTI

■

Execute commands with EXEC

■

Delayed execution with multi/exec can improve
performance
■

Holds off sending commands until all of them are known

■

When all of the commands are known, MULTI is sent by client
+

Transactions
■

Pipelining
■

Send multiple commands at once

■

Wait for all replies

■

Reduces number of network roundtrips that the client waits for
+

Reducing Memory Use
{Short Structures}
■

Method of reducing memory use

■

Ziplist – compact storage and unstructured representation of LISTs
HASHes and ZSETs

■

Intset – compact representation of SET

■

As structures grow beyond limits, they are converted back to their
original data structure type

■

Manipulating compact versions can become slow as they grow
+

Ziplist

■

Basic configuration for the 3 data types are similar

■

*-max-ziplist-value – max number of items to be encoded as ziplist

■

If limits are exceeded, redis will convert the list/hash/zset into non-ziplist
structure
+

ZIPLIST - LIST
+

Intset
+

Sharded Structures
■

Sharding – takes data, partitions it to smaller pieces and
sends data to different locations depending on which
partition the data is assigned to

■

Sharding LISTs – uses LUA scripting

■

Sharding ZSETs – zset operations on shards violate how
quickly zsets perform, sharding is not useful on zsets
+

Sharded Structures
■

Sharding HASHes
■

Method of partitioning data must be chosen

■

Hash’s keys can be used as source of info for sharding

■

To partition keys:
■

Calculate hash function on the key

■

Calculate number of shards needed depending on number of keys
we want to fit in one shard and the total number of keys

■

Resulting number of shards along with hash value will be used to
find out which shard we’ll use
+

Scaling
{read capacity}
■

In using small structures, make sure max ziplist is not too
large

■

Use structures that offer good performance for the types of
queries we want to perform

■

Compress large data sent to redis for caching to reduce
network reads and writes

■

Use pipelining and connection pooling
+

Scaling
{read capacity}
■

Increase total read throughput using read only slave servers
■
■

■

Always remember to WRITE TO THE MASTER
Writing on SLAVE will cause an error

Redis Sentinel
■

Mode where redis server binary doesn’t act like the typical one

■

Watches behavior and health of master(s) and slave(s)

■

Intended to offer automated failover
+

Scaling
{memory capacity}
■

Make sure to check all methods to reduce read data volume

■

Make sure larger pieces of unrelated functionality are moved to
different servers

■

Aggregate writes in local memory before writing to redis

■

Consider using locks or LUA when limitations such as
watch/multi/exec are encountered

■

When using AOF, keep in mind that the disk needs to keep up
with the volume we’re writing
+

Scaling
{write capability}
■

Presharding for growth
■

Run multiple redis servers on your machine (listen on diff. ports)

■

Use multiple redis database on your database server
+

Scaling
{complex queries}
■

Scenario : machines have enough memory to hold index, but we need to
execute more queries that server can handle

■

Use : SUNIONSTORE, SINTERSTORE, SDIFFSTORE, ZINTERSTORE,
and/or ZUNIONSTORE

■

Since we “read” from slave, set : slave-read-only no
+

Reference
■

Carlson, Josiah. (2013) Redis in Action. Shelter Island, NY: Manning
Publications
+

Thank You ☺

Contenu connexe

Tendances

Performance bottlenecks for metadata workload in Gluster with Poornima Gurusi...
Performance bottlenecks for metadata workload in Gluster with Poornima Gurusi...Performance bottlenecks for metadata workload in Gluster with Poornima Gurusi...
Performance bottlenecks for metadata workload in Gluster with Poornima Gurusi...
Gluster.org
 
BigTable PreReading
BigTable PreReadingBigTable PreReading
BigTable PreReading
everestsun
 

Tendances (19)

Seastore: Next Generation Backing Store for Ceph
Seastore: Next Generation Backing Store for CephSeastore: Next Generation Backing Store for Ceph
Seastore: Next Generation Backing Store for Ceph
 
Erasure codes and storage tiers on gluster
Erasure codes and storage tiers on glusterErasure codes and storage tiers on gluster
Erasure codes and storage tiers on gluster
 
DB Latency Using DRAM + PMem in App Direct & Memory Modes
DB Latency Using DRAM + PMem in App Direct & Memory ModesDB Latency Using DRAM + PMem in App Direct & Memory Modes
DB Latency Using DRAM + PMem in App Direct & Memory Modes
 
Avoiding Data Hotspots at Scale
Avoiding Data Hotspots at ScaleAvoiding Data Hotspots at Scale
Avoiding Data Hotspots at Scale
 
Challenges with Gluster and Persistent Memory with Dan Lambright
Challenges with Gluster and Persistent Memory with Dan LambrightChallenges with Gluster and Persistent Memory with Dan Lambright
Challenges with Gluster and Persistent Memory with Dan Lambright
 
IMC Summit 2016 Breakout - Andy Pavlo - What Non-Volatile Memory Means for th...
IMC Summit 2016 Breakout - Andy Pavlo - What Non-Volatile Memory Means for th...IMC Summit 2016 Breakout - Andy Pavlo - What Non-Volatile Memory Means for th...
IMC Summit 2016 Breakout - Andy Pavlo - What Non-Volatile Memory Means for th...
 
Vanquishing Latency Outliers in the Lightbits LightOS Software Defined Storag...
Vanquishing Latency Outliers in the Lightbits LightOS Software Defined Storag...Vanquishing Latency Outliers in the Lightbits LightOS Software Defined Storag...
Vanquishing Latency Outliers in the Lightbits LightOS Software Defined Storag...
 
Performance bottlenecks for metadata workload in Gluster with Poornima Gurusi...
Performance bottlenecks for metadata workload in Gluster with Poornima Gurusi...Performance bottlenecks for metadata workload in Gluster with Poornima Gurusi...
Performance bottlenecks for metadata workload in Gluster with Poornima Gurusi...
 
HBase at Flurry
HBase at FlurryHBase at Flurry
HBase at Flurry
 
Backup, Restore, and Disaster Recovery
Backup, Restore, and Disaster RecoveryBackup, Restore, and Disaster Recovery
Backup, Restore, and Disaster Recovery
 
Sharding: Past, Present and Future with Krutika Dhananjay
Sharding: Past, Present and Future with Krutika DhananjaySharding: Past, Present and Future with Krutika Dhananjay
Sharding: Past, Present and Future with Krutika Dhananjay
 
Realtime Indexing for Fast Queries on Massive Semi-Structured Data
Realtime Indexing for Fast Queries on Massive Semi-Structured DataRealtime Indexing for Fast Queries on Massive Semi-Structured Data
Realtime Indexing for Fast Queries on Massive Semi-Structured Data
 
MongoDB 101 & Beyond: Get Started in MongoDB 3.0, Preview 3.2 & Demo of Ops M...
MongoDB 101 & Beyond: Get Started in MongoDB 3.0, Preview 3.2 & Demo of Ops M...MongoDB 101 & Beyond: Get Started in MongoDB 3.0, Preview 3.2 & Demo of Ops M...
MongoDB 101 & Beyond: Get Started in MongoDB 3.0, Preview 3.2 & Demo of Ops M...
 
InfluxDB Internals
InfluxDB InternalsInfluxDB Internals
InfluxDB Internals
 
BigTable PreReading
BigTable PreReadingBigTable PreReading
BigTable PreReading
 
Life as a GlusterFS Consultant with Ivan Rossi
Life as a GlusterFS Consultant with Ivan RossiLife as a GlusterFS Consultant with Ivan Rossi
Life as a GlusterFS Consultant with Ivan Rossi
 
Performance Analysis and Troubleshooting Methodologies for Databases
Performance Analysis and Troubleshooting Methodologies for DatabasesPerformance Analysis and Troubleshooting Methodologies for Databases
Performance Analysis and Troubleshooting Methodologies for Databases
 
Building an Efficient AI Training Platform at bilibili with Alluxio
Building an Efficient AI Training Platform at bilibili with AlluxioBuilding an Efficient AI Training Platform at bilibili with Alluxio
Building an Efficient AI Training Platform at bilibili with Alluxio
 
Speed Up Uber's Presto with Alluxio
Speed Up Uber's Presto with AlluxioSpeed Up Uber's Presto with Alluxio
Speed Up Uber's Presto with Alluxio
 

En vedette (8)

大型网站架构的发展
大型网站架构的发展大型网站架构的发展
大型网站架构的发展
 
GIMP 2.8 - Efeito foto rasgada
GIMP 2.8 - Efeito foto rasgadaGIMP 2.8 - Efeito foto rasgada
GIMP 2.8 - Efeito foto rasgada
 
The simplethebeautiful
The simplethebeautifulThe simplethebeautiful
The simplethebeautiful
 
Peirce tp
Peirce tpPeirce tp
Peirce tp
 
Oracle数据库分析函数详解
Oracle数据库分析函数详解Oracle数据库分析函数详解
Oracle数据库分析函数详解
 
제7장223p 정의적특성평가의이해 4김정관
제7장223p 정의적특성평가의이해 4김정관 제7장223p 정의적특성평가의이해 4김정관
제7장223p 정의적특성평가의이해 4김정관
 
Redis运维之道
Redis运维之道Redis运维之道
Redis运维之道
 
深入了解Redis
深入了解Redis深入了解Redis
深入了解Redis
 

Similaire à Redis Beyond

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
Andrew Dunstan
 

Similaire à Redis Beyond (20)

MariaDB Paris Workshop 2023 - Performance Optimization
MariaDB Paris Workshop 2023 - Performance OptimizationMariaDB Paris Workshop 2023 - Performance Optimization
MariaDB Paris Workshop 2023 - Performance Optimization
 
Aerospike Hybrid Memory Architecture
Aerospike Hybrid Memory ArchitectureAerospike Hybrid Memory Architecture
Aerospike Hybrid Memory Architecture
 
Aerospike Architecture
Aerospike ArchitectureAerospike Architecture
Aerospike Architecture
 
Memcache d
Memcache dMemcache d
Memcache d
 
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
 
C# as a System Language
C# as a System LanguageC# as a System Language
C# as a System Language
 
MariaDB Server Performance Tuning & Optimization
MariaDB Server Performance Tuning & OptimizationMariaDB Server Performance Tuning & Optimization
MariaDB Server Performance Tuning & Optimization
 
Red Hat Gluster Storage Performance
Red Hat Gluster Storage PerformanceRed Hat Gluster Storage Performance
Red Hat Gluster Storage Performance
 
Maximizing performance via tuning and optimization
Maximizing performance via tuning and optimizationMaximizing performance via tuning and optimization
Maximizing performance via tuning and optimization
 
Maximizing performance via tuning and optimization
Maximizing performance via tuning and optimizationMaximizing performance via tuning and optimization
Maximizing performance via tuning and optimization
 
Serverless Apps on Google Cloud: more dev, less ops
Serverless Apps on Google Cloud:  more dev, less opsServerless Apps on Google Cloud:  more dev, less ops
Serverless Apps on Google Cloud: more dev, less ops
 
Serverless Apps on Google Cloud: more dev, less ops
Serverless Apps on Google Cloud: more dev, less opsServerless Apps on Google Cloud: more dev, less ops
Serverless Apps on Google Cloud: more dev, less ops
 
Automation of Hadoop cluster operations in Arm Treasure Data
Automation of Hadoop cluster operations in Arm Treasure DataAutomation of Hadoop cluster operations in Arm Treasure Data
Automation of Hadoop cluster operations in Arm Treasure Data
 
AWSome day 2018 - database in cloud
AWSome day 2018 -  database in cloudAWSome day 2018 -  database in cloud
AWSome day 2018 - database in cloud
 
EVCache: Lowering Costs for a Low Latency Cache with RocksDB
EVCache: Lowering Costs for a Low Latency Cache with RocksDBEVCache: Lowering Costs for a Low Latency Cache with RocksDB
EVCache: Lowering Costs for a Low Latency Cache with RocksDB
 
Capacity Planning
Capacity PlanningCapacity Planning
Capacity Planning
 
Building Efficient Multi-Threaded Filters for Faster SQL Queries
Building Efficient Multi-Threaded Filters for Faster SQL QueriesBuilding Efficient Multi-Threaded Filters for Faster SQL Queries
Building Efficient Multi-Threaded Filters for Faster SQL Queries
 
Big data should be simple
Big data should be simpleBig data should be simple
Big data should be simple
 
MariaDB Performance Tuning and Optimization
MariaDB Performance Tuning and OptimizationMariaDB Performance Tuning and Optimization
MariaDB Performance Tuning and Optimization
 
Sql server performance tuning
Sql server performance tuningSql server performance tuning
Sql server performance tuning
 

Dernier

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Dernier (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
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
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
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...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
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
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
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
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 

Redis Beyond

  • 1. + Redis {beyond the basics} Presented by Steph ☺
  • 2. + Outline ■ Revisiting Redis ■ Keeping data safe ■ ■ Replication ■ Replacing Failed Master ■ ■ Persistence Transaction Reducing memory use ■ ■ Intlist ■ ■ Ziplist Sharding Scaling
  • 3. + Redis ■ In-memory remote database ■ Advanced key-value store ■ Data-structure server ■ Offers ■ High Performance ■ Replication ■ Unique data model
  • 4. + Snapshotting {Persistence} ■ Data is taken as it exists and is written to the disk ■ Point-in-time copy of in-memory data ■ Backup & transfer to other server ■ Written to file in “dbfilename” stored in “dir” ■ Until next snapshot is taken, last snapshot can be lost if redis crashes
  • 6. + Snapshotting ■ How often to perform an automatic snapshot ■ Accept writes on failure ■ Snapshot compression ■ What to name the snapshot on the disk
  • 7. + Append Only File (AOF) {Persistence} ■ Copies incoming write commands as it happens ■ Records data changes at the end of the backup file ■ Data set could be recovered with replaying AOF ■ “append only yes” ■ “appendfsyc always” ■ Limited by disk performance
  • 8. + Append Only File (AOF) ■ Option to use AOF ■ Occurrence of sync writes to disk ■ Option to sync during AOF compaction ■ Occurrence of AOF compaction
  • 9. + Replication ■ Method where other servers receive an updated copy of the data as its being written ■ Replicas can service read queries ■ Single master database sends writes out to multiple slave databases ■ Set operations can take seconds to finish
  • 10. + Replication ■ Configuring for replication On master, ensure that the path and filename are writable by redis process ■ Enable slaving : slaveof host port ■ In a running system, redis can be stopped slaving or connect to a different master ■ New / Transfer connection: slaveof host port ■ Stop data update: SLAVEOF no one ■
  • 13. + Replacing Failed Master {Scenario and Solution} ■ What will we do in case of system failure? ■ Scenario ■ ■ Machine A loses network connectivity ■ ■ Machine A – Redis Master, Machine B – Redis Slave Machine C has Redis, but no copy of data Solution A ■ Make a fresh snapshot using Machine B using SAVE ■ Copy snapshot to Machine C ■ Start Redis on Machine C ■ Tell Machine B to be a slave of Machine C
  • 15. + Replacing Failed Master {Scenario and Solution} ■ What will we do in case of system failure? ■ Solution B ■ Use Machine B (Slave) as Master ■ Create a new Slave (maybe Machine C) ■ Update client configuration to read/write to proper servers ■ (optional) update server configuration if restart is needed
  • 16. + Transactions ■ Begin transaction with MULTI ■ Execute commands with EXEC ■ Delayed execution with multi/exec can improve performance ■ Holds off sending commands until all of them are known ■ When all of the commands are known, MULTI is sent by client
  • 17. + Transactions ■ Pipelining ■ Send multiple commands at once ■ Wait for all replies ■ Reduces number of network roundtrips that the client waits for
  • 18. + Reducing Memory Use {Short Structures} ■ Method of reducing memory use ■ Ziplist – compact storage and unstructured representation of LISTs HASHes and ZSETs ■ Intset – compact representation of SET ■ As structures grow beyond limits, they are converted back to their original data structure type ■ Manipulating compact versions can become slow as they grow
  • 19. + Ziplist ■ Basic configuration for the 3 data types are similar ■ *-max-ziplist-value – max number of items to be encoded as ziplist ■ If limits are exceeded, redis will convert the list/hash/zset into non-ziplist structure
  • 22. + Sharded Structures ■ Sharding – takes data, partitions it to smaller pieces and sends data to different locations depending on which partition the data is assigned to ■ Sharding LISTs – uses LUA scripting ■ Sharding ZSETs – zset operations on shards violate how quickly zsets perform, sharding is not useful on zsets
  • 23. + Sharded Structures ■ Sharding HASHes ■ Method of partitioning data must be chosen ■ Hash’s keys can be used as source of info for sharding ■ To partition keys: ■ Calculate hash function on the key ■ Calculate number of shards needed depending on number of keys we want to fit in one shard and the total number of keys ■ Resulting number of shards along with hash value will be used to find out which shard we’ll use
  • 24. + Scaling {read capacity} ■ In using small structures, make sure max ziplist is not too large ■ Use structures that offer good performance for the types of queries we want to perform ■ Compress large data sent to redis for caching to reduce network reads and writes ■ Use pipelining and connection pooling
  • 25. + Scaling {read capacity} ■ Increase total read throughput using read only slave servers ■ ■ ■ Always remember to WRITE TO THE MASTER Writing on SLAVE will cause an error Redis Sentinel ■ Mode where redis server binary doesn’t act like the typical one ■ Watches behavior and health of master(s) and slave(s) ■ Intended to offer automated failover
  • 26. + Scaling {memory capacity} ■ Make sure to check all methods to reduce read data volume ■ Make sure larger pieces of unrelated functionality are moved to different servers ■ Aggregate writes in local memory before writing to redis ■ Consider using locks or LUA when limitations such as watch/multi/exec are encountered ■ When using AOF, keep in mind that the disk needs to keep up with the volume we’re writing
  • 27. + Scaling {write capability} ■ Presharding for growth ■ Run multiple redis servers on your machine (listen on diff. ports) ■ Use multiple redis database on your database server
  • 28. + Scaling {complex queries} ■ Scenario : machines have enough memory to hold index, but we need to execute more queries that server can handle ■ Use : SUNIONSTORE, SINTERSTORE, SDIFFSTORE, ZINTERSTORE, and/or ZUNIONSTORE ■ Since we “read” from slave, set : slave-read-only no
  • 29. + Reference ■ Carlson, Josiah. (2013) Redis in Action. Shelter Island, NY: Manning Publications