Somtochukwu is a Technical Writer who enjoys writing technical articles that explain technical concepts.
Published on
Software engineers have always been tasked with integrating third-party applications for multiple components of a product. This may have underlying consequences later on when engineers have many third-party applications to work with within the product. In turn, it may cause inefficient management of components within the application, which will cause different issues.
Over time, developers have sought to build more robust third-party applications that can handle more than one task at a time. Today we will be looking at one of those applications called Redis.
In this article, we are going to know how to set up Redis on a remote server, but first, how about we go through the basics of Redis; what Redis is, the different use cases of Redis, and most importantly, why we should use Redis. Without further delay, let's get right into it.
According to the official Redis documentation:
Redis is an open-source (BSD licensed), in-memory data structure store used as a database, cache, message broker, and streaming engine.
In short, Redis which stands for Remote Dictionary Server is an open-source software with an in-memory data store that can function as a database, cache, message broker, or streaming engine.
It also provides data structures for us to work with in development or production such as strings, lists, hashes, sets, sorted lists, etc.
Redis has a lot packed within it, you need to find out what you particularly need it for.
As discussed earlier, Redis can be used as a primary or a secondary database, depending on your use case. It is most commonly used as a primary database rather than a secondary database.
There are benefits to using Redis as a primary database, such as:
The most common use of Redis is as a cache, because of the in-memory data store Redis offers, it is most efficient as a cache. It is by far one of the best caching systems we have there.
There are advantages to using Redis as a Cache as well, some of which are:
Redis can also be used as a message broker, it can be used to allow communication between two services. An example would be using Redis as a message broker within microservices. It is efficient, fast, and reliable.
There are tons of reasons to use Redis. It depends on what area you want to use Redis for, but as a tool, Redis is amazing. I will highlight some reasons why you should use Redis.
In this section, we will see how to set up Redis on a remote server so we can access it anywhere on the internet.
For this setup, we will need to have a Linode account. If you do not have a Linode account, you can head up to cloud.linode.com to signup for a free tier account to follow up with this setup.
After completing the signup process, you should be greeted with this page.
Next, we will need to create a virtual machine(VM) on which we will install Redis on. To create a virtual machine, click on the Create Linode button.
We should see a configuration screen next, on here, we are going to select the configurations of our virtual machine.
For our Linux distribution, make sure to choose Ubuntu 22.04, and for the region, choose a region that is closest to you for faster availability.
The next configuration is the Linode Plan. Make sure to choose the Nanode 1GB, this is the smallest Linode plan Linode has to offer, for this tutorial, we are going to stick with the configurations that have the smallest amount.
Next, we can see the Linode Label. Linode assigns a default label to every VM if a custom label is not provided. We can change the Linode Label if we want to.
We can see the Root Password, this is the root password we will use to log in to our VM.
Make sure to select the smallest, or the least resources for the virtual machine so as not to burn through the free tier package.
We do not need to worry about the additional settings below. To create our VM click the Create Linode button.
After setting up our VM, we need to login into the VM so we can install Redis. On the right side of the management console, we should see an SSH login command.
We need to copy the command and run it on our terminal like so:
Now, we should be logged in to our VM, we need to run these commands to upgrade and update our VM:
Next, we need to install Redis, like so:
After Redis is done installing, to check if Redis is up and running, we need to type in this command into our terminal:
We should see this output
We have confirmed that Redis is running successfully on our server. But we have not set it up for us to access it anywhere. Now we need to make a few changes to the Redis configuration file to make sure we can access our Redis server anywhere.
If we type in the redis-cli command, we will see this output:
This shows that Redis is still running on our VM’s localhost.
We need to edit the config file at /etc/redis/redis.conf.
Firstly, we need to open the file, we can do this with nano like so:
Next, we need to scroll down to line 66 where we have bind 127.0.0.1 ::1, like so:
We need to replace 127.0.0.1 ::1 with our IP address. For me it will be:
After the edit, we need to run this command in our VM so that Redis picks up the changes
Now, when we run this command, we can access the Redis server on our VM anywhere
After running this command we should get an output with this form
Now we can use the Redis Server we set up on our VM.
To summarize, we went through some important areas of Redis, for example, what Redis is, the major applications of Redis, why we should use Redis, and most importantly, how to set up Redis on a remote server. We hope you found this article informative and interesting.
Get visual proof, steps to reproduce and technical logs with one click
Continue reading
Try Bird on your next bug - you’ll love it
“Game changer”
Julie, Head of QA
Try Bird later, from your desktop