SlideShare a Scribd company logo
1 of 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

More Related Content

What's hot

Hadoop 20111117
Hadoop 20111117Hadoop 20111117
Hadoop 20111117
exsuns
 
HDFS introduction
HDFS introductionHDFS introduction
HDFS introduction
injae yeo
 
Basic command ppt
Basic command pptBasic command ppt
Basic command ppt
Rohit Kumar
 
Kicking ass with redis
Kicking ass with redisKicking ass with redis
Kicking ass with redis
Dvir Volk
 

What's hot (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
 

Viewers also liked (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 to Redis深入浅出

Redis深入浅出
Redis深入浅出Redis深入浅出
Redis深入浅出
ruoyi ruan
 
SD, a P2P bug tracking system
SD, a P2P bug tracking systemSD, a P2P bug tracking system
SD, a P2P bug tracking system
Jesse Vincent
 

Similar to 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
 

More from 锐 张

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 赵昆
锐 张
 

More from 锐 张 (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 赵昆
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
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...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
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
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

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 适合的场景主要局限 在较小数据量的高性能操作和运算上。