当前位置:网站首页>简述redis特点及其应用场景
简述redis特点及其应用场景
2022-07-23 05:06:00 【wwzroom】
简述redis特点及其应用场景

1.Redis 特性
- 速度快: 10W QPS,基于内存,C语言实现
- 单线程(目前已近支持多线程)
- 持久化(虽然基于内存,但是具有写入磁盘能力,做到断电不丢)
- 支持多种数据结构
- 支持多种编程语言
- 功能丰富: 支持Lua脚本,发布订阅,事务,pipeline(流水线)等功能
- 简单: 代码短小精悍(单机核心代码只有23000行左右),单线程开发容易,不依赖外部库,使用简单
- 主从复制
- 支持高可用和分布式
1.1.单线程(处理客户端请求)
Redis 6.0版本前一直是单线程方式处理用户的请求

单线程为何如此快?
- 纯内存
- 非阻塞
- 避免线程切换和竞态消耗
因为存的数据都比较小,运算速率比较高,单线程反而可以避免切换CPU浪费时间,为了可以提高效率可以实行多实例,一个CPU跑一个实例。

注意事项:
- 一次只运行一条命令
- 拒绝长(慢)命令:keys, flushall, flushdb, slow lua script, mutil/exec, operate big value(collection),排队时间很长。
- 其实不是单线程: 早期版本是单进程单线程,3版本后实际还有其它的线程, 实现特定功能,如: fysncfile descriptor,close file descriptor
2.redis 典型应用场景
Session 共享:常见于web集群中的Tomcat或者PHP中多web服务器session共享
缓存:数据查询、电商网站商品信息、新闻内容
计数器:访问排行榜、商品浏览数等和次数相关的数值统计场景
微博/微信社交场合:共同好友,粉丝数,关注,点赞评论等
消息队列 :ELK的日志缓存、部分业务的订阅发布系统
地理位置:基于GEO(地理信息定位),实现摇一摇,附近的人,外卖等功能



边栏推荐
- Selenium JD crawler
- Redis源码与设计剖析 -- 8.对象系统
- TZC 1283: simple sort - heap sort
- Redis source code and design analysis -- 14. Database implementation
- Analyse du code source et de la conception de redis - - 7. Liste rapide
- Visual Studio 2022有趣又强大的智能辅助编码
- The topic pub instruction of ros2 appears: failed to populate field: 'vector3' object has no attribute 'x:1' error
- Notes and Thoughts on the red dust of the sky (III) as long as the conditions are sufficient, the results will come naturally
- Meituan's 8-year experience on how to improve test engineers (automation, performance, test development)
- C language n battle -- linked list (IX)
猜你喜欢

C语言基础知识梳理(一)

A case study on the collaborative management of medical enterprise suppliers, hospitals, patients and other parties by building a low code platform

部署metersphere

C語言基礎知識梳理(一)

村田muRata电源维修交换机服务器电源维修及主要功能特点

0 basic career change software test, the necessary skills with a monthly salary of 6000 and 11000 are quite different

推荐一款 Shell 装逼神器,已开源!网友:真香。。。

mysql log理解

Solve the Chinese garbled code of post request and get request in servlet

第12届 蓝桥杯 嵌入式设计与开发项目
随机推荐
Comprehensive experiment of realizing private network interworking under mGRE environment
全局事件总线
一次 MySQL 误操作导致的事故,「高可用」都不好使了
C语言基础知识梳理(一)
[warning] recognizing corrupt image/label during yolov5 training: [errno 2]...... it is impossible to complete the training data set. I will take you to solve it quickly
Redis source code and design analysis -- 9. String object
Basic knowledge of C language (I)
0 basic career change software test, the necessary skills with a monthly salary of 6000 and 11000 are quite different
Jump statement and debugger
C语言n番战--共用体和枚举(八)
Visual Studio 2022有趣又强大的智能辅助编码
300 题 第六讲 二次型
Response object
Toco generates tflite model
Li Hongyi machine learning 2022-hw1
Redis源码与设计剖析 -- 11.哈希对象
C# 客户端程序调用外部程序的3种实现方法
Redis source code and design analysis -- 5. Integer set
Redis源码与设计剖析 -- 6.压缩列表
Linux: database connection