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
■  What

compression

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
■  Option

of sync writes to disk

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
■  On

for replication

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 – Redis Master, Machine B – Redis Slave
Machine A loses network connectivity
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 nonziplist 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
■  Sharding

LISTs – uses LUA scripting

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

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 glusterRed_Hat_Storage
 
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 LambrightGluster.org
 
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
 
HBase at Flurry
HBase at FlurryHBase at Flurry
HBase at Flurryddlatham
 
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 DataScyllaDB
 
Backup, Restore, and Disaster Recovery
Backup, Restore, and Disaster RecoveryBackup, Restore, and Disaster Recovery
Backup, Restore, and Disaster RecoveryMongoDB
 
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...MongoDB
 
Let the Tiger Roar!
Let the Tiger Roar!Let the Tiger Roar!
Let the Tiger Roar!MongoDB
 
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 DhananjayGluster.org
 
Life And Times Of An Address Space
Life And Times Of An Address SpaceLife And Times Of An Address Space
Life And Times Of An Address SpaceMartin Packer
 
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 AlluxioAlluxio, Inc.
 
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 AlluxioAlluxio, Inc.
 
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 DatabasesScyllaDB
 
BigTable PreReading
BigTable PreReadingBigTable PreReading
BigTable PreReadingeverestsun
 
InfluxDB Internals
InfluxDB InternalsInfluxDB Internals
InfluxDB InternalsInfluxData
 
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 RossiGluster.org
 
Introducing MongoDB in a multi-site HA environment
Introducing MongoDB in a multi-site HA environmentIntroducing MongoDB in a multi-site HA environment
Introducing MongoDB in a multi-site HA environmentSebastian Geib
 
MongoDB on EC2 and EBS
MongoDB on EC2 and EBSMongoDB on EC2 and EBS
MongoDB on EC2 and EBSJared Rosoff
 

Tendances (20)

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
 
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
 
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
 
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
 
Backup, Restore, and Disaster Recovery
Backup, Restore, and Disaster RecoveryBackup, Restore, and Disaster Recovery
Backup, Restore, and Disaster Recovery
 
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...
 
Let the Tiger Roar!
Let the Tiger Roar!Let the Tiger Roar!
Let the Tiger Roar!
 
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
 
Life And Times Of An Address Space
Life And Times Of An Address SpaceLife And Times Of An Address Space
Life And Times Of An Address Space
 
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
 
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
 
BigTable PreReading
BigTable PreReadingBigTable PreReading
BigTable PreReading
 
No sql
No sqlNo sql
No sql
 
InfluxDB Internals
InfluxDB InternalsInfluxDB Internals
InfluxDB Internals
 
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
 
Introducing MongoDB in a multi-site HA environment
Introducing MongoDB in a multi-site HA environmentIntroducing MongoDB in a multi-site HA environment
Introducing MongoDB in a multi-site HA environment
 
Accordion HBaseCon 2017
Accordion HBaseCon 2017Accordion HBaseCon 2017
Accordion HBaseCon 2017
 
MongoDB on EC2 and EBS
MongoDB on EC2 and EBSMongoDB on EC2 and EBS
MongoDB on EC2 and EBS
 

Similaire à Redis Beyond

MariaDB Paris Workshop 2023 - Performance Optimization
MariaDB Paris Workshop 2023 - Performance OptimizationMariaDB Paris Workshop 2023 - Performance Optimization
MariaDB Paris Workshop 2023 - Performance OptimizationMariaDB plc
 
Aerospike Hybrid Memory Architecture
Aerospike Hybrid Memory ArchitectureAerospike Hybrid Memory Architecture
Aerospike Hybrid Memory ArchitectureAerospike, Inc.
 
Aerospike Architecture
Aerospike ArchitectureAerospike Architecture
Aerospike ArchitecturePeter Milne
 
C# as a System Language
C# as a System LanguageC# as a System Language
C# as a System LanguageScyllaDB
 
MariaDB Server Performance Tuning & Optimization
MariaDB Server Performance Tuning & OptimizationMariaDB Server Performance Tuning & Optimization
MariaDB Server Performance Tuning & OptimizationMariaDB plc
 
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
 
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 opsJoseph Lust
 
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 opsmabl
 
Maximizing performance via tuning and optimization
Maximizing performance via tuning and optimizationMaximizing performance via tuning and optimization
Maximizing performance via tuning and optimizationMariaDB plc
 
Maximizing performance via tuning and optimization
Maximizing performance via tuning and optimizationMaximizing performance via tuning and optimization
Maximizing performance via tuning and optimizationMariaDB plc
 
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 QueriesScyllaDB
 
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 RocksDBScott Mansfield
 
Red Hat Gluster Storage Performance
Red Hat Gluster Storage PerformanceRed Hat Gluster Storage Performance
Red Hat Gluster Storage PerformanceRed_Hat_Storage
 
Big data should be simple
Big data should be simpleBig data should be simple
Big data should be simpleDori Waldman
 
AWSome day 2018 - database in cloud
AWSome day 2018 -  database in cloudAWSome day 2018 -  database in cloud
AWSome day 2018 - database in cloudCorley S.r.l.
 
Capacity Planning
Capacity PlanningCapacity Planning
Capacity PlanningMongoDB
 
Sql server performance tuning
Sql server performance tuningSql server performance tuning
Sql server performance tuningngupt28
 
MariaDB Performance Tuning and Optimization
MariaDB Performance Tuning and OptimizationMariaDB Performance Tuning and Optimization
MariaDB Performance Tuning and OptimizationMariaDB plc
 
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 DataYan Wang
 

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
 
C# as a System Language
C# as a System LanguageC# as a System Language
C# as a System Language
 
Memcache d
Memcache dMemcache d
Memcache d
 
MariaDB Server Performance Tuning & Optimization
MariaDB Server Performance Tuning & OptimizationMariaDB Server Performance Tuning & Optimization
MariaDB Server Performance Tuning & Optimization
 
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
 
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
 
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
 
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
 
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
 
Red Hat Gluster Storage Performance
Red Hat Gluster Storage PerformanceRed Hat Gluster Storage Performance
Red Hat Gluster Storage Performance
 
Big data should be simple
Big data should be simpleBig data should be simple
Big data should be simple
 
AWSome day 2018 - database in cloud
AWSome day 2018 -  database in cloudAWSome day 2018 -  database in cloud
AWSome day 2018 - database in cloud
 
Capacity Planning
Capacity PlanningCapacity Planning
Capacity Planning
 
Sql server performance tuning
Sql server performance tuningSql server performance tuning
Sql server performance tuning
 
MariaDB Performance Tuning and Optimization
MariaDB Performance Tuning and OptimizationMariaDB Performance Tuning and Optimization
MariaDB Performance Tuning and Optimization
 
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
 

Plus de KLabCyscorpions-TechBlog (13)

Object Calisthenics in Objective-C
Object Calisthenics in Objective-CObject Calisthenics in Objective-C
Object Calisthenics in Objective-C
 
Auto Layout on Xcode 5
Auto Layout on Xcode 5Auto Layout on Xcode 5
Auto Layout on Xcode 5
 
Code Review for iOS
Code Review for iOSCode Review for iOS
Code Review for iOS
 
Object Calisthenics
Object CalisthenicsObject Calisthenics
Object Calisthenics
 
Why You're A Bad PHP Programmer
Why You're A Bad PHP ProgrammerWhy You're A Bad PHP Programmer
Why You're A Bad PHP Programmer
 
Redis Set Go
Redis Set GoRedis Set Go
Redis Set Go
 
X-Debug in Php Storm
X-Debug in Php StormX-Debug in Php Storm
X-Debug in Php Storm
 
Software Testing
Software TestingSoftware Testing
Software Testing
 
Php + MySql Optimization
Php + MySql OptimizationPhp + MySql Optimization
Php + MySql Optimization
 
Mysql Optimization
Mysql OptimizationMysql Optimization
Mysql Optimization
 
MVC Web Application
MVC Web ApplicationMVC Web Application
MVC Web Application
 
AfNetworking vs. Native + Caching
AfNetworking vs. Native + CachingAfNetworking vs. Native + Caching
AfNetworking vs. Native + Caching
 
Bash
BashBash
Bash
 

Dernier

ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptshraddhaparab530
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...JojoEDelaCruz
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Food processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsFood processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsManeerUddin
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 

Dernier (20)

ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.ppt
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Food processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsFood processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture hons
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 

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 ■  What compression 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 ■  Option of sync writes to disk 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 ■  On for replication 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 – Redis Master, Machine B – Redis Slave Machine A loses network connectivity 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 nonziplist 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 ■  Sharding LISTs – uses LUA scripting 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