SlideShare una empresa de Scribd logo
1 de 19
redis 深入浅出
Agenda

    Feature&Architecture

    Admin&capcity forecast

    Replication

    Presistence

    Table design
Feature


                 redis                       memcached
data structure   string|list|hash|set|zset   string
thread model     third(main thread, two      many
                 auxiliary thread)
demultiplexer    ae.c                        libevent(3rd library)
persistence      yes                         no
replication      yes                         no
design           weak                        no
String

    Set hello world





    Set hello 1234567

    Set hello 1234
List

    Lpush list aaaa bbb ccc





    Double link list, so can lpush,rpush,lpop,rpop
Zipmap
Hset test hello world
Hset test aliyun dba




Zipmap defect:Zmlen one bytes, only 253 subkey
Architecture
Rehash
Cache forecast
string 类型的内存大小 = 键值个数 * (dictEntry 大
  小 + redisObject 大小 + 包含 key 的 sds 大小 +
  包含 value 的 sds 大小 ) + bucket 个数 * 4


zipmap 类型的内存大小 = hashkey 个数 *
  (dictEntry 大小 + redisObject 大小 + 包含 key
  的 sds 大小 + subkey 的总大小 ) + bucket 个数 *
  4


Jemalloc size class
Admin

    Redis.conf(static), config set(dynamic)
    –   maxmemory <bytes>
    –   Appendfsync everysec(fsync pagecache to disk)
    –   hash-max-zipmap-entries 512
    –   hash-max-zipmap-value 64
Replication

    procedure
     
         map
     
         Master slave – slave – slave - slave

    defects
     
         Without resume broken transfer
     
         Without lag(slave position)
replication
Persistence

    Snapshot
     
          Fork process, loop hash table, save file dump.rdb
     
          Yes!!! sequential write
     
          Write dump.rdb need O_DIRECT

    Aof
     
          Like binlog, for recover after crash
     
          Auto bgrewrteaof
     
          Auxiliary threads
     
          Postpone fsync
Auxiliary thread
Table desgin login user

    Design a login user system
     
         Heap table
            
                userid login_times   last_login_time
            
                1        5            2011-1-1
            
                2        1            2011-1-2
            
                3        2            2011-1-3
     
         Last login man? Create index on last_login_time
     
         Max login man? Create index on login_times
     
         Index, explan plan, compute statistics is suck!!!
Login user

    data
       
             Set userid:1:login_times 5
       
             Set userid:2:login_times 1
       
             Set userid:3:login_times 2


       
             Set userid:1:last_login 2011-1-1
       
             Set userid:2:last_login 2011-1-2
       
             Set userid:3:last_login 2011-1-3

    Last login
       
             lpush user_last_login 1
       
             lpush user_last_login 2
       
             lpush user_last_login 3
       
             ltrim user_last_login 0 1
Login user

    Max login man
     
         zadd user:login_times 5 1
     
         zadd user:login_times 1 2
     
         zadd user:login_times 2 3
     
         zcard user:login_times
     
         zrangebyscore user:login_times 3 +inf withscores

    Column store data?
Suitable Scene

    轻量级的高性能消息队列服务 , 生产者消费者

    跨机器的共享内存

    Redis 的主要缺点是数据库容量受到物理内存
    的限制,不能用作海量数据的高性能读写,并
    且它没有原生的可扩展机制,不具有
    scale (可扩展)能力,要依赖客户端来实现
    分布式读写,因此 Redis 适合的场景主要局限
    在较小数据量的高性能操作和运算上。
QA
  @hoterran
www.hoterran.info

Más contenido relacionado

La actualidad más candente

IBM DB2 LUW UDB DBA Training by www.etraining.guru
IBM DB2 LUW UDB DBA Training by www.etraining.guruIBM DB2 LUW UDB DBA Training by www.etraining.guru
IBM DB2 LUW UDB DBA Training by www.etraining.guruRavikumar Nandigam
 
Linux Shell Scripting Presantion
Linux Shell Scripting PresantionLinux Shell Scripting Presantion
Linux Shell Scripting PresantionSameerNimkar
 
Hive data migration (export/import)
Hive data migration (export/import)Hive data migration (export/import)
Hive data migration (export/import)Bopyo Hong
 
Hypertable
HypertableHypertable
Hypertablebetaisao
 
Hypertable - massively scalable nosql database
Hypertable - massively scalable nosql databaseHypertable - massively scalable nosql database
Hypertable - massively scalable nosql databasebigdatagurus_meetup
 
Basic linux commands for bioinformatics
Basic linux commands for bioinformaticsBasic linux commands for bioinformatics
Basic linux commands for bioinformaticsBonnie Ng
 
Unix commands in etl testing
Unix commands in etl testingUnix commands in etl testing
Unix commands in etl testingGaruda Trainings
 
Hadoop 20111117
Hadoop 20111117Hadoop 20111117
Hadoop 20111117exsuns
 
REDIS intro and how to use redis
REDIS intro and how to use redisREDIS intro and how to use redis
REDIS intro and how to use redisKris Jeong
 
Database Architectures and Hypertable
Database Architectures and HypertableDatabase Architectures and Hypertable
Database Architectures and Hypertablehypertable
 
HDFS introduction
HDFS introductionHDFS introduction
HDFS introductioninjae yeo
 
Basic command ppt
Basic command pptBasic command ppt
Basic command pptRohit Kumar
 
Basic linux commands
Basic linux commands Basic linux commands
Basic linux commands Raghav Arora
 
Kicking ass with redis
Kicking ass with redisKicking ass with redis
Kicking ass with redisDvir Volk
 

La actualidad más candente (20)

IBM DB2 LUW UDB DBA Training by www.etraining.guru
IBM DB2 LUW UDB DBA Training by www.etraining.guruIBM DB2 LUW UDB DBA Training by www.etraining.guru
IBM DB2 LUW UDB DBA Training by www.etraining.guru
 
PgconfSV compression
PgconfSV compressionPgconfSV compression
PgconfSV compression
 
2 db2 instance creation
2 db2 instance creation2 db2 instance creation
2 db2 instance creation
 
Linux Shell Scripting Presantion
Linux Shell Scripting PresantionLinux Shell Scripting Presantion
Linux Shell Scripting Presantion
 
Hive data migration (export/import)
Hive data migration (export/import)Hive data migration (export/import)
Hive data migration (export/import)
 
Redis acc
Redis accRedis acc
Redis acc
 
Basic Linux commands
Basic Linux commandsBasic Linux commands
Basic Linux commands
 
Hypertable
HypertableHypertable
Hypertable
 
Linux file commands
Linux file commandsLinux file commands
Linux file commands
 
Hypertable - massively scalable nosql database
Hypertable - massively scalable nosql databaseHypertable - massively scalable nosql database
Hypertable - massively scalable nosql database
 
Introduction to HDFS
Introduction to HDFSIntroduction to HDFS
Introduction to HDFS
 
Basic linux commands for bioinformatics
Basic linux commands for bioinformaticsBasic linux commands for bioinformatics
Basic linux commands for bioinformatics
 
Unix commands in etl testing
Unix commands in etl testingUnix commands in etl testing
Unix commands in etl testing
 
Hadoop 20111117
Hadoop 20111117Hadoop 20111117
Hadoop 20111117
 
REDIS intro and how to use redis
REDIS intro and how to use redisREDIS intro and how to use redis
REDIS intro and how to use redis
 
Database Architectures and Hypertable
Database Architectures and HypertableDatabase Architectures and Hypertable
Database Architectures and Hypertable
 
HDFS introduction
HDFS introductionHDFS introduction
HDFS introduction
 
Basic command ppt
Basic command pptBasic command ppt
Basic command ppt
 
Basic linux commands
Basic linux commands Basic linux commands
Basic linux commands
 
Kicking ass with redis
Kicking ass with redisKicking ass with redis
Kicking ass with redis
 

Destacado

Redis内存存储结构分析
Redis内存存储结构分析Redis内存存储结构分析
Redis内存存储结构分析锐 张
 
05 杨志丰
05 杨志丰05 杨志丰
05 杨志丰锐 张
 
长尾理论(The longtail)版
长尾理论(The longtail)版长尾理论(The longtail)版
长尾理论(The longtail)版锐 张
 
数据成就互联网的可能 用技术撬动Roi-好耶
数据成就互联网的可能 用技术撬动Roi-好耶数据成就互联网的可能 用技术撬动Roi-好耶
数据成就互联网的可能 用技术撬动Roi-好耶锐 张
 
Lamp高性能设计
Lamp高性能设计Lamp高性能设计
Lamp高性能设计锐 张
 

Destacado (8)

Redis内存存储结构分析
Redis内存存储结构分析Redis内存存储结构分析
Redis内存存储结构分析
 
05 杨志丰
05 杨志丰05 杨志丰
05 杨志丰
 
长尾理论(The longtail)版
长尾理论(The longtail)版长尾理论(The longtail)版
长尾理论(The longtail)版
 
Hridoyer katha
Hridoyer kathaHridoyer katha
Hridoyer katha
 
数据成就互联网的可能 用技术撬动Roi-好耶
数据成就互联网的可能 用技术撬动Roi-好耶数据成就互联网的可能 用技术撬动Roi-好耶
数据成就互联网的可能 用技术撬动Roi-好耶
 
Lamp高性能设计
Lamp高性能设计Lamp高性能设计
Lamp高性能设计
 
Makalahe toga
Makalahe togaMakalahe toga
Makalahe toga
 
Our heroes
Our heroesOur heroes
Our heroes
 

Similar a Redis深入浅出-内存数据库Redis的特性、数据结构、持久化、复制等原理

Redis深入浅出
Redis深入浅出Redis深入浅出
Redis深入浅出iammutex
 
Redis深入浅出
Redis深入浅出Redis深入浅出
Redis深入浅出ruoyi ruan
 
Swift Install Workshop - OpenStack Conference Spring 2012
Swift Install Workshop - OpenStack Conference Spring 2012Swift Install Workshop - OpenStack Conference Spring 2012
Swift Install Workshop - OpenStack Conference Spring 2012Joe Arnold
 
Puppet Camp Dallas 2014: Replacing Simple Puppet Modules with Providers
Puppet Camp Dallas 2014: Replacing Simple Puppet Modules with Providers Puppet Camp Dallas 2014: Replacing Simple Puppet Modules with Providers
Puppet Camp Dallas 2014: Replacing Simple Puppet Modules with Providers Puppet
 
Driver Debugging Basics
Driver Debugging BasicsDriver Debugging Basics
Driver Debugging BasicsBala Subra
 
ContainerDays Boston 2015: "CoreOS: Building the Layers of the Scalable Clust...
ContainerDays Boston 2015: "CoreOS: Building the Layers of the Scalable Clust...ContainerDays Boston 2015: "CoreOS: Building the Layers of the Scalable Clust...
ContainerDays Boston 2015: "CoreOS: Building the Layers of the Scalable Clust...DynamicInfraDays
 
Replacing Simple Puppet Modules with Providers
Replacing Simple Puppet Modules with ProvidersReplacing Simple Puppet Modules with Providers
Replacing Simple Puppet Modules with ProvidersPuppet
 
Inside CynosDB: MariaDB optimized for the cloud at Tencent
Inside CynosDB: MariaDB optimized for the cloud at TencentInside CynosDB: MariaDB optimized for the cloud at Tencent
Inside CynosDB: MariaDB optimized for the cloud at TencentMariaDB plc
 
OSDC 2012 | Scaling with MongoDB by Ross Lawley
OSDC 2012 | Scaling with MongoDB by Ross LawleyOSDC 2012 | Scaling with MongoDB by Ross Lawley
OSDC 2012 | Scaling with MongoDB by Ross LawleyNETWAYS
 
Postgres Vienna DB Meetup 2014
Postgres Vienna DB Meetup 2014Postgres Vienna DB Meetup 2014
Postgres Vienna DB Meetup 2014Michael Renner
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalabilityWim Godden
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalabilityWim Godden
 
Logging for Production Systems in The Container Era
Logging for Production Systems in The Container EraLogging for Production Systems in The Container Era
Logging for Production Systems in The Container EraSadayuki Furuhashi
 
Amir Salihefendic: Redis - the hacker's database
Amir Salihefendic: Redis - the hacker's databaseAmir Salihefendic: Redis - the hacker's database
Amir Salihefendic: Redis - the hacker's databaseit-people
 
DjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling DisqusDjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling Disquszeeg
 
Scaling with Python: SF Python Meetup, September 2017
Scaling with Python: SF Python Meetup, September 2017Scaling with Python: SF Python Meetup, September 2017
Scaling with Python: SF Python Meetup, September 2017Varun Varma
 
深入了解Redis
深入了解Redis深入了解Redis
深入了解Redisiammutex
 
SD, a P2P bug tracking system
SD, a P2P bug tracking systemSD, a P2P bug tracking system
SD, a P2P bug tracking systemJesse Vincent
 

Similar a Redis深入浅出-内存数据库Redis的特性、数据结构、持久化、复制等原理 (20)

Redis深入浅出
Redis深入浅出Redis深入浅出
Redis深入浅出
 
Redis深入浅出
Redis深入浅出Redis深入浅出
Redis深入浅出
 
Swift Install Workshop - OpenStack Conference Spring 2012
Swift Install Workshop - OpenStack Conference Spring 2012Swift Install Workshop - OpenStack Conference Spring 2012
Swift Install Workshop - OpenStack Conference Spring 2012
 
Puppet Camp Dallas 2014: Replacing Simple Puppet Modules with Providers
Puppet Camp Dallas 2014: Replacing Simple Puppet Modules with Providers Puppet Camp Dallas 2014: Replacing Simple Puppet Modules with Providers
Puppet Camp Dallas 2014: Replacing Simple Puppet Modules with Providers
 
Driver Debugging Basics
Driver Debugging BasicsDriver Debugging Basics
Driver Debugging Basics
 
ContainerDays Boston 2015: "CoreOS: Building the Layers of the Scalable Clust...
ContainerDays Boston 2015: "CoreOS: Building the Layers of the Scalable Clust...ContainerDays Boston 2015: "CoreOS: Building the Layers of the Scalable Clust...
ContainerDays Boston 2015: "CoreOS: Building the Layers of the Scalable Clust...
 
Replacing Simple Puppet Modules with Providers
Replacing Simple Puppet Modules with ProvidersReplacing Simple Puppet Modules with Providers
Replacing Simple Puppet Modules with Providers
 
Inside CynosDB: MariaDB optimized for the cloud at Tencent
Inside CynosDB: MariaDB optimized for the cloud at TencentInside CynosDB: MariaDB optimized for the cloud at Tencent
Inside CynosDB: MariaDB optimized for the cloud at Tencent
 
OSDC 2012 | Scaling with MongoDB by Ross Lawley
OSDC 2012 | Scaling with MongoDB by Ross LawleyOSDC 2012 | Scaling with MongoDB by Ross Lawley
OSDC 2012 | Scaling with MongoDB by Ross Lawley
 
Postgres Vienna DB Meetup 2014
Postgres Vienna DB Meetup 2014Postgres Vienna DB Meetup 2014
Postgres Vienna DB Meetup 2014
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
 
Logging for Production Systems in The Container Era
Logging for Production Systems in The Container EraLogging for Production Systems in The Container Era
Logging for Production Systems in The Container Era
 
Amir Salihefendic: Redis - the hacker's database
Amir Salihefendic: Redis - the hacker's databaseAmir Salihefendic: Redis - the hacker's database
Amir Salihefendic: Redis - the hacker's database
 
DjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling DisqusDjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling Disqus
 
FleetDB
FleetDBFleetDB
FleetDB
 
The Web Scale
The Web ScaleThe Web Scale
The Web Scale
 
Scaling with Python: SF Python Meetup, September 2017
Scaling with Python: SF Python Meetup, September 2017Scaling with Python: SF Python Meetup, September 2017
Scaling with Python: SF Python Meetup, September 2017
 
深入了解Redis
深入了解Redis深入了解Redis
深入了解Redis
 
SD, a P2P bug tracking system
SD, a P2P bug tracking systemSD, a P2P bug tracking system
SD, a P2P bug tracking system
 

Más de 锐 张

Openstack starter-guide-diablo
Openstack starter-guide-diabloOpenstack starter-guide-diablo
Openstack starter-guide-diablo锐 张
 
基于My sql的分布式数据库实践
基于My sql的分布式数据库实践基于My sql的分布式数据库实践
基于My sql的分布式数据库实践锐 张
 
Redis中文入门手册
Redis中文入门手册Redis中文入门手册
Redis中文入门手册锐 张
 
Redis学习笔记
Redis学习笔记Redis学习笔记
Redis学习笔记锐 张
 
淘宝前端优化
淘宝前端优化淘宝前端优化
淘宝前端优化锐 张
 
Sun jdk 1.6内存管理 -实现篇 -毕玄
Sun jdk 1.6内存管理 -实现篇 -毕玄Sun jdk 1.6内存管理 -实现篇 -毕玄
Sun jdk 1.6内存管理 -实现篇 -毕玄锐 张
 
Sun jdk 1.6内存管理 -调优篇-毕玄
Sun jdk 1.6内存管理 -调优篇-毕玄Sun jdk 1.6内存管理 -调优篇-毕玄
Sun jdk 1.6内存管理 -调优篇-毕玄锐 张
 
Sun jdk 1.6内存管理 -使用篇-毕玄
Sun jdk 1.6内存管理 -使用篇-毕玄Sun jdk 1.6内存管理 -使用篇-毕玄
Sun jdk 1.6内存管理 -使用篇-毕玄锐 张
 
Sun jdk-1.6-gc
Sun jdk-1.6-gcSun jdk-1.6-gc
Sun jdk-1.6-gc锐 张
 
Redis介绍
Redis介绍Redis介绍
Redis介绍锐 张
 
Green plum培训材料
Green plum培训材料Green plum培训材料
Green plum培训材料锐 张
 
Greenplum技术
Greenplum技术Greenplum技术
Greenplum技术锐 张
 
新时代的分析型云数据库 Greenplum
新时代的分析型云数据库 Greenplum新时代的分析型云数据库 Greenplum
新时代的分析型云数据库 Greenplum锐 张
 
服务器端性能优化 提升Qps、rt
服务器端性能优化 提升Qps、rt服务器端性能优化 提升Qps、rt
服务器端性能优化 提升Qps、rt锐 张
 
新浪云计算公开课第二期:Sae平台的灵活应用(吕毅、魏世江)
新浪云计算公开课第二期:Sae平台的灵活应用(吕毅、魏世江)新浪云计算公开课第二期:Sae平台的灵活应用(吕毅、魏世江)
新浪云计算公开课第二期:Sae平台的灵活应用(吕毅、魏世江)锐 张
 
新浪云计算公开课第一期:Let’s run @ sae(丛磊)
新浪云计算公开课第一期:Let’s run @ sae(丛磊)新浪云计算公开课第一期:Let’s run @ sae(丛磊)
新浪云计算公开课第一期:Let’s run @ sae(丛磊)锐 张
 
亚马逊云计算Aws
亚马逊云计算Aws亚马逊云计算Aws
亚马逊云计算Aws锐 张
 
20110625.【打造高效能的cdn系统】.易统
20110625.【打造高效能的cdn系统】.易统20110625.【打造高效能的cdn系统】.易统
20110625.【打造高效能的cdn系统】.易统锐 张
 
网易海量数据存储平台的构建和运维
网易海量数据存储平台的构建和运维网易海量数据存储平台的构建和运维
网易海量数据存储平台的构建和运维锐 张
 
09 赵昆
09 赵昆09 赵昆
09 赵昆锐 张
 

Más de 锐 张 (20)

Openstack starter-guide-diablo
Openstack starter-guide-diabloOpenstack starter-guide-diablo
Openstack starter-guide-diablo
 
基于My sql的分布式数据库实践
基于My sql的分布式数据库实践基于My sql的分布式数据库实践
基于My sql的分布式数据库实践
 
Redis中文入门手册
Redis中文入门手册Redis中文入门手册
Redis中文入门手册
 
Redis学习笔记
Redis学习笔记Redis学习笔记
Redis学习笔记
 
淘宝前端优化
淘宝前端优化淘宝前端优化
淘宝前端优化
 
Sun jdk 1.6内存管理 -实现篇 -毕玄
Sun jdk 1.6内存管理 -实现篇 -毕玄Sun jdk 1.6内存管理 -实现篇 -毕玄
Sun jdk 1.6内存管理 -实现篇 -毕玄
 
Sun jdk 1.6内存管理 -调优篇-毕玄
Sun jdk 1.6内存管理 -调优篇-毕玄Sun jdk 1.6内存管理 -调优篇-毕玄
Sun jdk 1.6内存管理 -调优篇-毕玄
 
Sun jdk 1.6内存管理 -使用篇-毕玄
Sun jdk 1.6内存管理 -使用篇-毕玄Sun jdk 1.6内存管理 -使用篇-毕玄
Sun jdk 1.6内存管理 -使用篇-毕玄
 
Sun jdk-1.6-gc
Sun jdk-1.6-gcSun jdk-1.6-gc
Sun jdk-1.6-gc
 
Redis介绍
Redis介绍Redis介绍
Redis介绍
 
Green plum培训材料
Green plum培训材料Green plum培训材料
Green plum培训材料
 
Greenplum技术
Greenplum技术Greenplum技术
Greenplum技术
 
新时代的分析型云数据库 Greenplum
新时代的分析型云数据库 Greenplum新时代的分析型云数据库 Greenplum
新时代的分析型云数据库 Greenplum
 
服务器端性能优化 提升Qps、rt
服务器端性能优化 提升Qps、rt服务器端性能优化 提升Qps、rt
服务器端性能优化 提升Qps、rt
 
新浪云计算公开课第二期:Sae平台的灵活应用(吕毅、魏世江)
新浪云计算公开课第二期:Sae平台的灵活应用(吕毅、魏世江)新浪云计算公开课第二期:Sae平台的灵活应用(吕毅、魏世江)
新浪云计算公开课第二期:Sae平台的灵活应用(吕毅、魏世江)
 
新浪云计算公开课第一期:Let’s run @ sae(丛磊)
新浪云计算公开课第一期:Let’s run @ sae(丛磊)新浪云计算公开课第一期:Let’s run @ sae(丛磊)
新浪云计算公开课第一期:Let’s run @ sae(丛磊)
 
亚马逊云计算Aws
亚马逊云计算Aws亚马逊云计算Aws
亚马逊云计算Aws
 
20110625.【打造高效能的cdn系统】.易统
20110625.【打造高效能的cdn系统】.易统20110625.【打造高效能的cdn系统】.易统
20110625.【打造高效能的cdn系统】.易统
 
网易海量数据存储平台的构建和运维
网易海量数据存储平台的构建和运维网易海量数据存储平台的构建和运维
网易海量数据存储平台的构建和运维
 
09 赵昆
09 赵昆09 赵昆
09 赵昆
 

Último

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 

Último (20)

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 

Redis深入浅出-内存数据库Redis的特性、数据结构、持久化、复制等原理

  • 2. Agenda  Feature&Architecture  Admin&capcity forecast  Replication  Presistence  Table design
  • 3. Feature redis memcached data structure string|list|hash|set|zset string thread model third(main thread, two many auxiliary thread) demultiplexer ae.c libevent(3rd library) persistence yes no replication yes no design weak no
  • 4. String  Set hello world  Set hello 1234567  Set hello 1234
  • 5. List  Lpush list aaaa bbb ccc  Double link list, so can lpush,rpush,lpop,rpop
  • 6. Zipmap Hset test hello world Hset test aliyun dba Zipmap defect:Zmlen one bytes, only 253 subkey
  • 9. Cache forecast string 类型的内存大小 = 键值个数 * (dictEntry 大 小 + redisObject 大小 + 包含 key 的 sds 大小 + 包含 value 的 sds 大小 ) + bucket 个数 * 4 zipmap 类型的内存大小 = hashkey 个数 * (dictEntry 大小 + redisObject 大小 + 包含 key 的 sds 大小 + subkey 的总大小 ) + bucket 个数 * 4 Jemalloc size class
  • 10. Admin  Redis.conf(static), config set(dynamic) – maxmemory <bytes> – Appendfsync everysec(fsync pagecache to disk) – hash-max-zipmap-entries 512 – hash-max-zipmap-value 64
  • 11. Replication  procedure  map  Master slave – slave – slave - slave  defects  Without resume broken transfer  Without lag(slave position)
  • 13. Persistence  Snapshot  Fork process, loop hash table, save file dump.rdb  Yes!!! sequential write  Write dump.rdb need O_DIRECT  Aof  Like binlog, for recover after crash  Auto bgrewrteaof  Auxiliary threads  Postpone fsync
  • 15. Table desgin login user  Design a login user system  Heap table  userid login_times last_login_time  1 5 2011-1-1  2 1 2011-1-2  3 2 2011-1-3  Last login man? Create index on last_login_time  Max login man? Create index on login_times  Index, explan plan, compute statistics is suck!!!
  • 16. Login user  data  Set userid:1:login_times 5  Set userid:2:login_times 1  Set userid:3:login_times 2  Set userid:1:last_login 2011-1-1  Set userid:2:last_login 2011-1-2  Set userid:3:last_login 2011-1-3  Last login  lpush user_last_login 1  lpush user_last_login 2  lpush user_last_login 3  ltrim user_last_login 0 1
  • 17. Login user  Max login man  zadd user:login_times 5 1  zadd user:login_times 1 2  zadd user:login_times 2 3  zcard user:login_times  zrangebyscore user:login_times 3 +inf withscores  Column store data?
  • 18. Suitable Scene  轻量级的高性能消息队列服务 , 生产者消费者  跨机器的共享内存  Redis 的主要缺点是数据库容量受到物理内存 的限制,不能用作海量数据的高性能读写,并 且它没有原生的可扩展机制,不具有 scale (可扩展)能力,要依赖客户端来实现 分布式读写,因此 Redis 适合的场景主要局限 在较小数据量的高性能操作和运算上。