The Easiest Way to Set Up Redis in 2022
Tags: programming, beginners, tutorial, webdev
Published: 2022-05-15 01:17:36

Have you been struggling with setting up Redis? 

Or are you looking for an easier way of getting it up and running? 

Either way, you might want to check out this FREE simple Redis setup that will save you time!

_If you don't know what Redis is and what it is used for, don't worry. Here is a brief outline that will help you understand it better._ 

## Redis: Multipurpose In-memory Data Storage

Let's go over a quick overview of Redis before discussing the setup method. 

In short, Redis is an open-source, in-memory data store, that can serve as a cache, database, and message broker. On top of that, it supports various data structures.

![Redis Is Amazing](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0ilcuhe8u7c54y4nfkq2.png)

<small><cite>Image from <a href="https://youtu.be/DOIWQddRD5M">Fireship.io</a> </cite></small>

**In the database world, Redis is considered revolutionary.**

It is an impressive hybrid of in-memory, schema-less design (noSQL) with high-performance, versatile data structures and modules that can be tailored to your data needs. On top of storing data in-memory, Redis allows for high durability and availability through backups and replication. 

Redis is one of the _most adept, optimal, multi-purpose databases_ out there: It scales horizontally like a key-value data store, but it also provides various functionalities, despite its simplicity.

You would want to use Redis to implement a _highly available, in-memory cache_ to: 

- reduce data access latency
- improve throughput 
- minimize the load on your SQL or NoSQL database and on your application itself

Alright, time to set up Redis!

## Redis Cloud Setup

The easiest way of getting Redis up and running is by using Redis Enterprise Cloud. 

This method reduces the likelihood of running into operating system-specific issues, such as the lack of Windows support for Redis. It also allows you to reach the cloud database endpoint anywhere, whether you are using other computers or VMs.

### Short Outline of the Process

1. Sign up for an account on Redislabs.
2. Add a new subscription.
3. Create a new database.
4. Choose a protocol and modules.
5. Retrieve database information.

### 1. Redislabs Account Registration

First, you need a Redislabs account to be able to set up a database. 

Thankfully, their registration process is hassle-free, since you can just sign up with either your Google account or GitHub account! If you have neither of the two, you can fill in the registration form.

![Try redis cloud](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lh3abt48ua9zp47dnw2v.jpg)

![Authorize](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pf6a60f1hbbt6vfcxfhp.png)

For this example, I'm using GitHub to register for a Redislabs account. 

### 2. Add New Subscription

Before you can set up a database, you'll need to have a subscription plan. Click `New subscription`. 

Then, **choose fixed plans**.

![This is what you want](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9njj5tag6xtscz26s6rb.png)

Select the **cloud vendor** that you want to use. For this example, I'm using AWS.

You also need to choose which **region** you want the service to be located in, choose the closest one near where your application will be hosted.

![New subscription select region](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q0te5s5f92fiuaqq43bv.png)

_For the FREE plan, you get 30MB of in-memory storage and no replication/high-availability._

Next, choose a **subscription name** that makes sense for your use case (e.g. your app's name). Then, click `Create subscription`.  

![Subscription name](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/40gk7pn00rynku25d6c5.png)

_You should now have a subscription number (Subscription #1715073) and the option to create a new database._

### 3. Create New Database

Now, you can proceed to create a new database! 

You can do this by clicking `New database` on either the top-right of your screen or at the center.

![Make a new database](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/shxdngn2k3v92r8by7ua.png)

Choose a **database name** that suits what you are doing with it (e.g. your app's name). 

### 4. Choose Database Protocol and Modules

Select `Redis` as your database protocol. As for the modules you'll be using, you can choose both `RediSearch` and `RedisJSON`. These two modules are usually enough for most projects.

![Database name](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fkr0qeu6m8kqvf1oq771.png)

Click `Activate database` once you are done filling out the database creation form. After that, you just need to wait for Redislabs to finish setting up your database.

### 5. Retrieve Database Information

After the database is created, you're probably wondering how you're supposed to connect with the Redis data store.

You can look for the `Public endpoint` information on your newly created database.   

![Database Host and port number](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9166bwqwehx2r8qf1541.png)

Take note of the Redis hostname and the port number. 

For this example, I have the public endpoint of `redis-19827.c83.us-east-1-2.ec2.cloud.redislabs.com:19827`. The hostname is `redis-19827.c83.us-east-1-2.ec2.cloud.redislabs.com` and the port number is `19827`.

![Database default password](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ztzrny0rg3aq8a01fa3u.png)

**Note:** You may also need a password to connect to your newly created Redis database. 

1. Scroll further down the database information page.
2. Go to the `Security` section. 
3. Retrieve your `Default user password`. 

While you can use the default credentials to connect your Redis database, it is best to update it to a more secure one later on. 

You can do it by clicking the `Edit database` and changing the information that you'd like updated. 

Congratulations! You should have a Redis Cloud database successfully set up now.

## Frequently Asked Questions (FAQ)

![Common Questions and Answers](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qm21usun2fo2ju9plffb.png)

**Which programming languages can I use Redis with?**

_Redis supports most modern programming languages._ These include (and are not limited to) Node.js, PHP, Java, Python, Ruby, C#, C++, and so on. 

Check your language and framework's libraries or packages for utilizing Redis. For example, Node.js has the [node-redis npm  package](https://www.npmjs.com/package/redis) for interacting with a Redis database.

**Am I going to be charged for this Redis set up?**

If you choose the _free, fixed subscription plan, you will not be charged._ 

However, the free plan does come with its limitations such as 30MB storage, lack of replication, 30 maximum connections, and so on. Usually, this is enough for local development needs, so don't worry about it too much.

**Can't you just install and run Redis on Docker? That would be faster than clicking through all the GUI on Redislabs.**

This tutorial aims to provide the _easiest way to set up Redis._

One issue with a Docker set up is that it requires someone to know (or learn) how to configure Docker images and containers. This intermediate step can be intimidating for beginners who are just starting out.

## Resources/Recommended Reading:

- [Official Redis Page](https://redis.com/)
- [Try Redis Enterprise | Redis](https://redis.com/try-free/)
- [Official Redis Documentation](https://docs.redis.com/latest/)

A fun resource for learning Redis:

- [Fireship's Video on Redis](https://www.youtube.com/watch?v=DOIWQddRD5M)

![Thank You Banner](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wyi1ip2bzgnxx6zfbr8m.png)

## DISCLAIMER:

**This is a Starter Guide meant for helping beginners easily set up Redis.** This guide only expresses my thoughts and opinions (based on my limited knowledge) and is in no way a substitute for actual references. 

If I ever make a mistake or if you disagree, I would appreciate corrections and discussions in the comments!

## Other Media

Feel free to reach out to me in other media!

<span><a target="_blank" href="https://www.rammina.com"><img src="https://res.cloudinary.com/rammina/image/upload/v1638444046/rammina-button-128_x9ginu.png" alt="Rammina Logo" width="128" height="50"/></a></span>

<span><a target="_blank" href="https://twitter.com/RamminaR"><img src="https://res.cloudinary.com/rammina/image/upload/v1636792959/twitter-logo_laoyfu_pdbagm.png" alt="Twitter logo" width="128" height="50"/></a></span>

<span><a target="_blank" href="https://github.com/Rammina"><img src="https://res.cloudinary.com/rammina/image/upload/v1636795051/GitHub-Emblem2_epcp8r.png" alt="Github logo" width="128" height="50"/></a></span>