Filed in by Zachary Schneider | May 4, 2011 10:32 am
This post was contributed by Zachary Schneider, RHCE, System Engineer for the Rackspace Cloud.
Redis is an open source, in-memory, persistent, advanced key-value data store. It has also been referred to as a data structure server since keys can contain not only strings, but also hashes, lists, sets and sorted sets.
Redis is similar to memcached but possesses additional features that can be utilized in order to address a number of problems common to today’s resource intensive web applications.
Redis was originally written in order to help address the scaling needs of http://lloogg.com/, a web analytics startup, by Salvatore (antirez) Sanfilippo. Following its open source debut in March of 2009, Redis quickly gained popularity due to its unique feature set and outstanding performance. VMware now funds ongoing development of the product.
Features Unique to Redis
Virtual memory is a method of supplementing the storage available in RAM by mapping additional virtual space to disk based storage.
• If your working dataset is simply larger than the amount of RAM available to store that dataset.
• If data access is biased to a relatively small set of keys, yet the keys are large enough that they will all not fit into memory simultaneously.
Persist data to disk
In memory data may be saved to disk at configurable intervals. These intervals are defined by the number of key changes per second, allowing for a great deal of flexibility if disk performance is a concern.
• If your application requires a persistent database like data store
• If your application would place too much load on the backend infrastructure should an event occur that would expunge the contents of the in-memory store. I.E. your application requires that its cache be warm following cache system restart.
Redis supports simple master to slave replication. When a relationship is established all data from the master is transferred to the slave. After this is complete all changes to the master replicate to the slave.
• If your application requires redundancy in the event of hardware failure relating to the primary cache system.
• If you require an off system backup of the data store it is a best practice to perform a backup from the slave system
Most key value stores do not allow you to enumerate the names of the stored keys. In order to access a key you must know the key name. Redis allows you to enumerate the names of the stored keys via a KEYS command and a matching construct.
• If your application requires that you are able to list and/or act upon a list of present keys.
Redis supports more data types than simple strings. This allows complex, heavily used data structures to be utilized within the data store in order to take advantage of in-memory performance.
STRING: A simple string
LIST: A list of strings. Stacks and queues can be easily modeled utilizing lists.
SET: An unordered collection of unique items. Union, diff, and intersection operations can be performed on sets. Sets can be utilized to build highly optimized indexes.
SORTED SET: Similar to sets, but each member of the set has an associated floating point score. Sorted sets are essential whenever a range type query is needed. Sorted sets are also an important tool for constructing indexes.
HASH: Redis hashes are similar to Ruby hashes, or Python dictionaries. They are ideal for storing serialized objects.
Channel publish and subscribe
Redis allows clients to PUBLISH and SUBSCRIBE to channels. Multiple clients can subscribe to a channel. Another client can then publish to that channel and all the subscribed clients will receive the published value.
• This functionality can allow you to create a simple high performance shared message bus for a distributed application.
Redis was designed to address performance issues encountered with large distributed web applications as such it currently does not support strong authentication or transport layer encryption, as these features would degrade performance.
When using Redis in the cloud it is important that the redis traffic not traverse publicly accessible networks, and that the appropriate precautions are taken to ensure security to the port that Redis is listening on (6379 by default). These precautions would typically take the form of packet filter rule sets and binding Redis to non-publicly facing interfaces on cloud servers.
A significant number of companies are utilizing Redis in order to help them address application-scaling issues. The following is a short list of some of the larger parties.
• Blizzard Entertainment
You can find more information about Redis at: http://redis.io
Source URL: http://www.rackspace.com/blog/redis-an-introduction/
Copyright ©2013 The Official Rackspace Blog unless otherwise noted.