设为首页 收藏本站
查看: 780|回复: 0

[经验分享] Redis, from the Ground Up(1)

[复制链接]

尚未签到

发表于 2016-12-19 08:18:28 | 显示全部楼层 |阅读模式
  

A deep dive into Redis' origins, design decisions, feature set, and a look at a few potential applications.
DSC0000.png
Redis (“REmote DIctionary Service”) is an open-source (BSD-licensed) database server.


  • History
  • Data Structure Server

  • Key Advantages

    • Performance
    • Atomicity
    • Foundational Data Types
    • Polyglot Persistence
    • Client Protocol
    • Getting Started


  • Key Disadvantages

    • RAM
    • Persistence
    • Memory Bloat


  • Diving In

    • String Keys
    • Expiry
    • Sidenote: memcached?
    • Replication

    • Persistence

      • Options
      • Binary Dumps and In-Memory Representation
      • Problems


    • Expiry

      • Redis Versions Prior to 2.1.3
      • Redis Versions 2.1.3 and Above


    • More on Strings

      • Increment
      • SETNX and Locking

    • Lists
    • Sets
    • Sorted Sets
    • Hashes
    • Redis Transactions

    • Redis Virtual Memory

      • Limitations
      • Implementation Details


    • Publish/Subscribe

      • Example


    • Usage Examples

      • Caching
      • Nginx + Redis
      • Interprocess Communication
      • Views
      • Job Management
      • Locking

    • Designing with Redis
    • Other Resources


 



History

The Redis project was started in early 2009 by an Italian developer named Salvatore Sanfilippo. Redis was initially written to improve the performance of LLOOGG, a real-time web analytics product out of Salvatore’s startup.
By June of 2009, Redis was stable enough, and had enough of a base feature set, to serve production traffic at LLOOGG. On June 19, 2009, an important milestone was hit:Salvatore deployed Redis to LLOOGG’s production environment and retired the MySQL installation.
Over the next months, Redis rapidly grew in popularity. Salvatore fostered a great community, added features at a very rapid pace, and dealt with any and all reports of database corruption, instability, etc. with the utmost severity.
In March of 2010 VMWare hired Salvatore to work full-time on Redis. (Redis itself remains BSD licensed.) Shortly thereafter, VMWare hired Pieter Noordhuis, a key Redis contributor, to give the project an additional momentum boost.
The rest, as they say, is history.

Data Structure Server

The most apt description of Redis is that it is a “data structure server”. This is a very natural label for the database, because Redis natively supports many of the foundational data types of computer science, and provides a rich set of familiar primitives for manipulating these types.
The supported data types are:


  • Strings
  • Lists
  • Sets
  • Sorted Sets
  • Hashes

Key Advantages

Performance

Redis can perform >100k+ SETs per second, and >80k+ GETs per second.
The redis-benchmark utility included with the project can be used to reproduce these findings. (More on benchmarks here and here.)

Atomicity

Every operation that Redis exposes via the available command primitives is atomic. (And, as we’ll see later, there are ways to combine multiple primitive commands into larger atomic units.) This makes application-level code easier to build and reason about.
Atomic guarantees are a direct consequence of Redis' single-threaded core; as a result, Redis' internals are simpler (no complex locking and synchronization code complicating the codebase, introducing bugs, and burning up CPU cycles).

Foundational Data Types

The data types that Redis offers are foundational. All computer scientists are very familiar with these data types and have already used them to solve countless problems.Lists, sets, etc. are more fundamental to computer scientists than relational database tables, columns, and rows.
The documentation for all Redis commands includes complexity measurements, in big O notation. This makes it very straightforward for computer scientists and software engineers to visualize, reason about, optimize, and understand the performance of Redis queries. Is it this straightforward to understand query performance in a relational database?

Polyglot Persistence

This is not specifically an advantage inherent to Redis, but is worth noting. Using Redis does not require a commitment to use it exclusively. Use Redis to solve problems that can be naturally modelled using its primitives, and embrace polyglot persistence for everything else.

Client Protocol

The client protocol is very straightforward. This makes it simple to build client libraries.

Getting Started

It is very easy to get started. Redis has no external dependencies, and getting up and running only involves the following steps:


  • Clone the git repository or unpack the tarball
  • Run make
  • Run ./src/redis-server

Then, from another terminal, start the interactive command line interface by running./src/redis-cli.
Feel free to issue a few commands:

    redis> PING
PONG
redis> INFO
redis_version:2.1.1
...



(Alternatively, to try Redis from your browser, visit try.redis-db.com.)

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-316140-1-1.html 上篇帖子: redis所有命令 下篇帖子: redis渐入佳境(03) list类型
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表