转 What is Redis and what do I use it for?
原文: http://stackoverflow.com/questions/7888880/what-is-redis-and-what-do-i-use-it-for
Redis = Remote Dictionary Service
TL;DR: If you can map a use case to Redis and discover you aren't at risk of running out of RAM by using Redis there is a good chance you should probably use Redis.
It's a "NoSQL" key-value data store. More precisely, it is a data structure server.
Not like MongoDB (which is a disk-based document store), though MongoDB could be used for similar key/value use cases.
The closest analog is probably to think of Redis as Memcached, but with built-in persistence (snapshotting or journaling to disk) and more datatypes.
Those two additions may seem pretty minor, but they are what make Redis pretty incredible. Persistence to disk means you can use Redis as a real database instead of just a volatile cache. The data won't disappear when you restart, like with memcached.
The additional data types are probably even more important. Key
values can be simple strings, like you'll find in memcached, but they
can also be more complex types like Hashes, Lists (ordered collection,
makes a great queue), Sets (unordered collection of non-repeating
values), or Sorted Sets (ordered/ranked collection of non-repeating
values).
This is only the tip of the Redis iceberg, as there are other
powerful features like built-in pub/sub, transactions (with optimistic
locking), and Lua scripting.
The entire data set, like memcached, is stored in-memory so it is
extremely fast (like memcached)... often even faster than memcached.
Redis had virtual memory, where rarely used values would be swapped out
to disk, so only the keys had to fit into memory, but this has been
deprecated. Going forward the use cases for Redis are those where its
possible (and desirable) for the entire data set to fit into memory.
Redis is a fantastic choice if you want a highly scalable data store
shared by multiple processes, multiple applications, or multiple
servers. As just an inter-process communication mechanism it is tough to
beat. The fact that you can communicate cross-platform, cross-server,
or cross-application just as easily makes it a pretty great choice for
many many use cases. Its speed also makes it great as a caching layer.
Update 4/1/2015: Redis 3.0 (stable) was released today. This version of Redis brings cluster support, which makes it much easier to scale Redis.
@acidzombie24 Its possible you could use Redis in-place-of MySQL but it really depends on the use case. If your data set could grow to 20GB or you need to use some business analytic tools, you need to make heavy use of joins, etc. then it might not make sense. It's really hard to make a blanket statement except to say that there are certainly cases where Redis would be appropriate in place of MySQL.
@KO. Just like Redis offers features which memcached doesn't, RDBMS offers many many features which Redis does not. Redis should be FAR faster than any RDBMS, but it also can't do as much. If you can map your RDBMS use case to Redis then it might be worth taking a look, but if you can't don't force it. Best tool for the job and all that. A No-SQL store that has a better chance of replacing your RDBMS is MongoDB, but even that needs to be evaluated carefully and you should go with the best fit, which may be an RDBMS
A very thought-provoking thread here. Being an old dog, it was quite a thunder-clap when I realized the reason most data is now persisted to DBs is simply because a whole generation of programmers have grown up with cheap, ubiquitous DBs and they don't KNOW any other way of persisting data. No clue what qsort() & bsearch() are capable of for example. RE: joins with Redix, if people knew how simple it is to do joins in memory they'd be shocked. The data value you join on simply becomes a token that is replaced by the data the FK indexes. It's ~ string replacement problem
DBs are wonderful, and very flexible, but horribly expensive in terms of resources, and very slow. Slow, not because the internals aren't fast, but because they have a large fixed cost which is realized as a lot of latency. As an example, my employer has an ENUM server with 45 ms latency - good by industry standards. I am writing a CPS throttle with .067 microsecond latency. Not even in the same ballpark. Likewise, bsearch() against a pointer array, the result of a ptr qsort(), and fetching data from SSDs, is thousands of times faster than any DB - even in-memory ones like ours.
With respect to Redix only holding indexes in memory, with SSDs, I hope this option is still available. The latest generation of SSD focused RAIDs by Adaptec (ASR-8885 RAID) and LSI perform at 12Gbps - spectacular for 256 -2k byte random I/Os a data structure server would be fetching. The reason so many alternative to SQL, like NoSQL, are showing up, is because SQL is the problem. Too much parsing, too much data conversion, metadata driving the very internals of your database, and too much conversion again on the backend. With data structures you have the answer before the SQL gets to the NIC
|
109 down vote
|
What it can be use for? Few examples from http://highscalability.com/blog/2011/7/6/11-common-web-use-cases-solved-in-redis.html:
|
Yet another one: A very simple, but useful tool for programmers. A build-counter server. Eg. your application version may be 1.2.7 (build #473). It's very easy to add a new build number for your project, and your build-script can easily request a new (unique) number.
Oh, and it's awfully easy to use this for making two scripts that run on two different platforms communicate with eachother. For instance one of those Cortex-A based TV-boxes can send data back and forth to my desktop computer - so I'm using it like a FIFO.
转 What is Redis and what do I use it for?的更多相关文章
- 使用redis构建可靠分布式锁
关于分布式锁的概念,具体实现方式,直接参阅下面两个帖子,这里就不多介绍了. 分布式锁的多种实现方式 分布式锁总结 对于分布式锁的几种实现方式的优劣,这里再列举下 1. 数据库实现方式 优点:易理解 缺 ...
- Ignite性能测试以及对redis的对比
测试方法 为了对Ignite做一个基本了解,做了一个性能测试,测试方法也比较简单主要是针对client模式,因为这种方法和使用redis的方式特别像.测试方法很简单主要是下面几点: 不作参数优化,默认 ...
- mac osx 安装redis扩展
1 php -v查看php版本 2 brew search php|grep redis 搜索对应的redis ps:如果没有brew 就根据http://brew.sh安装 3 brew ins ...
- Redis/HBase/Tair比较
KV系统对比表 对比维度 Redis Redis Cluster Medis Hbase Tair 访问模式 支持Value大小 理论上不超过1GB(建议不超过1MB) 理论上可配置(默认配置1 ...
- Redis数据库
Redis是k-v型数据库的典范,设计思想及数据结构实现都值得学习. 1.数据类型 value支持五种数据类型:1.字符串(strings)2.字符串列表(lists)3.字符串集合(sets)4.有 ...
- redis 学习笔记(2)
redis-cluster 简介 redis-cluster是一个分布式.容错的redis实现,redis-cluster通过将各个单独的redis实例通过特定的协议连接到一起实现了分布式.集群化的目 ...
- redis 学习笔记(1)
redis持久化 snapshot数据快照(rdb) 这是一种定时将redis内存中的数据写入磁盘文件的一种方案,这样保留这一时刻redis中的数据镜像,用于意外回滚.redis的snapshot的格 ...
- python+uwsgi导致redis无法长链接引起性能下降问题记录
今天在部署python代码到预生产环境时,web站老是出现redis链接未初始化,无法连接到服务的提示,比对了一下开发环境与测试环境代码,完全一致,然后就是查看各种日志,排查了半天也没有查明是什么原因 ...
- nginx+iis+redis+Task.MainForm构建分布式架构 之 (redis存储分布式共享的session及共享session运作流程)
本次要分享的是利用windows+nginx+iis+redis+Task.MainForm组建分布式架构,上一篇分享文章制作是在windows上使用的nginx,一般正式发布的时候是在linux来配 ...
- windows+nginx+iis+redis+Task.MainForm构建分布式架构 之 (nginx+iis构建服务集群)
本次要分享的是利用windows+nginx+iis+redis+Task.MainForm组建分布式架构,由标题就能看出此内容不是一篇分享文章能说完的,所以我打算分几篇分享文章来讲解,一步一步实现分 ...
随机推荐
- LeetCode高频148错题记录
3. Max Points on a Line 共线点个数3种解法 思路一:思考如何确定一条直线,两点法,确定斜率后带入一点.有三种情况,1. 两点重合,2. 斜率不存在,3. 正常算,依次以每个点为 ...
- 剑指offer错题记录
错误重点: 1. 传递vector参数时,如果调用函数改变了vector的内容,一定一定要&,传引用保持一致 旋转数组的最小数字:有重复数字情况,二分查找照样搞.情况考虑要周全,当a[mid] ...
- JS浮点计算精度问题分析与解决
问题描述 在JS计算四则运算时会遇到精度丢失的问题,会引起诸多问题,看看以下例子: 例如:在chrome控制台输入 0.1 + 0.7 输出结果是 0.7999999999999999 例如:0.1+ ...
- XNginx - nginx 集群可视化管理工具
之前团队的nginx管理,都是运维同学每次去修改配置文件,然后重启,非常不方便,一直想找一个可以方便管理nginx集群的工具,翻遍web,未寻到可用之物,于是自己设计开发了一个. 效果预览 集群gro ...
- 如何扩展Orchard
翻译自: http://msdn.microsoft.com/en-us/magazine/hh708754.aspx 动态类型系统 Content item是Orchard中的原子, 比如b ...
- net core体系-API-1Ocelot-(1)概要
从这篇开始探讨Ocelot,Ocelot是一个.NET API网关,仅适用于.NET Core,用于.NET面向微服务/服务的架构中.当客户端(web站点.ios. app 等)访问web api时, ...
- Codeforces 873E Awards For Contestants ST表
原文链接https://www.cnblogs.com/zhouzhendong/p/9255885.html 题目传送门 - CF873E 题意 现在要给 $n(n\leq 3000)$ 个学生颁奖 ...
- AtCoder Regular Contest 082 (ARC082) E - ConvexScore 计算几何 计数
原文链接http://www.cnblogs.com/zhouzhendong/p/8934254.html 题目传送门 - ARC082 E 题意 给定二维平面上的$n$个点,定义全集为那$n$个点 ...
- BZOJ2084 [Poi2010]Antisymmetry Manachar
题目传送门 - BZOJ2084 题解 对于一个0我们把它看作01,1看作10,然后只要原串中的某个子串可以通过这两个变换成为回文串就可以满足条件了. 对于转换过的串,Manachar随便弄几下就可以 ...
- 数学建模:2.监督学习--分类分析- KNN最邻近分类算法
1.分类分析 分类(Classification)指的是从数据中选出已经分好类的训练集,在该训练集上运用数据挖掘分类的技术,建立分类模型,对于没有分类的数据进行分类的分析方法. 分类问题的应用场景:分 ...