What is Redis?
Redis or “REmote DIctionary Server” is defined as an open source, “key-value” database storage medium, which is additionally known as a data structure server. At its heart, Redis works with key-value pairs and stores data in a location that’s easily referenceable by two specific values. These key-value associations are usually a set of two linked data entries which are made up by a key, which is a unique identifier for a type of data and, the value, which can be either the particular data that is identified or, an indicator to the location of that data.
Redis has five main data types it can utilize:
- Strings – Strings are a basic value in Redis. They can contain any kind of data size up to 512Mb including jpegs or other objects like blobs.
- Lists – Lists are exactly as the name implies; simply lists of strings, sorted by the order in which they are applied
- Sets – Sets are simply a group of unordered strings
- Sorted Sets – Sorted Sets are akin to regular sets. The main difference is that sorted set items are associated with, and sorted by a weighted score field. This allows for priority items to be set when entered data into the sorted set
- Hashes – Hashes map the string fields and values themselves. They are capable of defining multiple elements and can store more than 4 billion field-value pairs
Redis holds the database entries entirely in memory, and will only use the hard disk for persistent storage. These key-value pair values are often used in hash tables, lookup tables and configuration files. Redis can accept key-values for a wide variety of formats so operations can be run on the server with a reduced server workload. Redis can also replicate data to any number of slave servers which makes it a prime candidate for large database replication setups.
What Are the Advantages of Redis?
- Redis is extremely fast − Redis can perform hundreds of thousands of (set, get) commands per second.
- It supports well know data types − As noted above, Redis supports most of the data types normally used by developers such as strings, lists, sets, sorted sets, and hashes.
- Operations are protected (or atomic) which means:
- All operations in a transaction are chronological and executed in sequence
- All operations in a transaction are performed as a single unit of work which limits interference from other operations
- .Multifunction database − Redis is a multifunction, noSQL database that can be used in a wide variety of use cases including caching, large dataset, full-text searches, spark data processing or any other short-lived data manipulation.
All of these options place Redis firmly in the middle of the NoSQL ecosystem.
What is NoSQL?
NoSQL is a type of database design that takes into consideration a wide group of data models, including key-value, document, columnar and graph formats.
NoSQL stands for “not only SQL” and is an alternative to the more traditional relational databases like MySQL in which data is laid out in tables, and the data scheme is carefully constructed before the actual database is created. NoSQL databases are especially useful for working with very large distributed datasets
A quick breakdown of how NoSQL stacks up against other database schemes:
Install Redis on Ubuntu
To install Redis on Ubuntu, SSH into your server, once at the command prompt type the following commands. This will install Redis on your server.
apt-get install redis-server
Next, let’s ensure Redis starts at boot:
systemctl enable redis-server.service
Also, let’s set one of the main memory variables in the Redis config (this value will depend on your servers available memory)
Finally, let’s restart Redis to ensure the values are retained:
systemctl restart redis-server.service
Check If Redis is Active
Run the following command at the servers command prompt:
This will open a Redis prompt.
After running the above command, your servers IP address (10.0.0.1) and the port Redis is running on will be shown (6379).
Now type in the following command at the Redis prompt:
redis 10.0.0.1:6379> ping“PONG” shows that Redis is successfully installed on your machine.
Install Redis via Source
To install Redis manually via source, simply SSH into your server and run the following command:
wget http://download.redis.io/redis-stable.tar.gz && tar xvzf redis-stable.tar.gz && cd redis-stable && make && make install
The Redis configuration file will be in the current install directory. Let’s copy it to a better location:
cp redis.conf /etc/redis/
Now, let start Redis:
redis-server /etc/redis/redis.conf &
Lastly, here is a fun way to test Redis out. Try it! Overall, if you need a fast, robust, and highly scalable NoSQL solution for use with your application or as a project adjunct Redis can meet your needs! Try it out on one of our Private Cloud product offerings or one of our stable, reliable Dedicated servers!