Redis is an in-memory data store used to store metadata about users’ profiles, authentication information, and manifest files. It is primarily used as an application cache or quick-response database. It is designed for real-time applications such as gaming, ad-tech, and financial services. It allows you to write fewer lines of code to store, access, and use data in your applications.

In this post, we will show you how to install Redis on Fedora Linux.

Step 1 – Install Redis

By default, the Redis package is included in the Fedora default repo. You can install it using the following command.

dnf install redis -y

After the installation, start and enable the Redis service using the following command.

systemctl enable --now redis

You can check the status of the Redis service using the following command.

systemctl status redis

Output:

● redis.service - Redis persistent key-value database
     Loaded: loaded (/usr/lib/systemd/system/redis.service; disabled; vendor preset: disabled)
    Drop-In: /etc/systemd/system/redis.service.d
             └─limit.conf
     Active: active (running) since Tue 2023-09-19 00:45:48 EDT; 14min ago
   Main PID: 4066 (redis-server)
     Status: "Ready to accept connections"
      Tasks: 5 (limit: 2328)
     Memory: 2.0M
        CPU: 1.619s
     CGroup: /system.slice/redis.service
             └─4066 /usr/bin/redis-server 127.0.0.1:6379

Sep 19 00:45:48 fedora systemd[1]: Starting Redis persistent key-value database...
Sep 19 00:45:48 fedora systemd[1]: Started Redis persistent key-value database.

At this point, Redis is started and listens on port 6379. You can check it with the following command.

ss -antpl | grep -i redis

Output:

LISTEN 0      511        127.0.0.1:6379      0.0.0.0:*    users:(("redis-server",pid=4066,fd=6))                   
LISTEN 0      511            [::1]:6379         [::]:*    users:(("redis-server",pid=4066,fd=7))                   

Step 2 – Configure Redis

Redis’ default configuration file is located at /etc/redis/redis.conf. You will need to edit it to secure Redis.

nano /etc/redis/redis.conf

Change the following lines.

bind 0.0.0.0

requirepass  yourpass

appendonly yes
appendfilename "appendonly.aof"

Save and close the file, then restart the Redis service to apply the changes.

systemctl restart redis

Step 3 – Verify Redis Connection

At this point, Redis is installed and configured. Now, connect to the Redis instance using the Redis CLI.

redis-cli

Next, authenticate Redis using a password.

127.0.0.1:6379> AUTH yourpass

Next, check the Redis connectivity.

127.0.0.1:6379> PING

Output:

PONG

Run the following command to get Redis server information.

127.0.0.1:6379> INFO Server

Output:

# Server
redis_version:6.2.7
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:63e4c6cb7f542ebb
redis_mode:standalone
os:Linux 5.12.8-300.fc34.x86_64 x86_64
arch_bits:64
monotonic_clock:POSIX clock_gettime
multiplexing_api:epoll
atomicvar_api:c11-builtin
gcc_version:11.2.1
process_id:6207
process_supervised:systemd
run_id:4e86466f757313d4572daf01911d9914c5cfb3ec
tcp_port:6379
server_time_usec:1695099789257222
uptime_in_seconds:25
uptime_in_days:0
hz:10
configured_hz:10
lru_clock:600973
executable:/usr/bin/redis-server
config_file:/etc/redis/redis.conf
io_threads_active:0

Step 4 – Benchmark Redis

Redis has a built-in benchmark tool used to send a pre-defined number of requests to the server to measure performance.

Let’s run the following command to check the average number of requests per second that Redis can handle.

redis-benchmark -a yourpass -h 127.0.0.1 -q

Output:

PING_INLINE: 165837.48 requests per second
PING_BULK: 156006.25 requests per second
SET: 156006.25 requests per second
GET: 136425.66 requests per second
INCR: 155038.77 requests per second
LPUSH: 173913.05 requests per second
RPUSH: 139275.77 requests per second
LPOP: 136798.91 requests per second
RPOP: 137362.64 requests per second
SADD: 149031.30 requests per second
HSET: 168067.22 requests per second
SPOP: 151975.69 requests per second
ZADD: 170648.45 requests per second

You can also use the -c and -t options to use 20 parallel connections to run 100000 SET requests on the server:

redis-benchmark -a yourpass -h 127.0.0.1 -p 6379 -n 100000 -c 20

Output:

====== PING_INLINE ======                                                   
  100000 requests completed in 3.87 seconds
  20 parallel clients
  3 bytes payload
  keep alive: 1
  host configuration "save": 3600 1 300 100 60 10000
  host configuration "appendonly": yes
  multi-thread: no

Latency by percentile distribution:
0.000% <= 0.159 milliseconds (cumulative count 2129)
50.000% <= 0.391 milliseconds (cumulative count 50188)
75.000% <= 0.503 milliseconds (cumulative count 75368)
87.500% <= 0.567 milliseconds (cumulative count 88337)
93.750% <= 0.631 milliseconds (cumulative count 93856)
96.875% <= 0.703 milliseconds (cumulative count 97127)
98.438% <= 0.751 milliseconds (cumulative count 98549)
99.219% <= 0.791 milliseconds (cumulative count 99243)
99.609% <= 0.839 milliseconds (cumulative count 99630)
99.805% <= 0.999 milliseconds (cumulative count 99808)
99.902% <= 1.279 milliseconds (cumulative count 99903)
99.951% <= 1.599 milliseconds (cumulative count 99953)
99.976% <= 2.007 milliseconds (cumulative count 99976)
99.988% <= 2.151 milliseconds (cumulative count 99988)
99.994% <= 2.687 milliseconds (cumulative count 99994)
99.997% <= 2.791 milliseconds (cumulative count 99997)
99.998% <= 2.847 milliseconds (cumulative count 99999)
99.999% <= 2.863 milliseconds (cumulative count 100000)
100.000% <= 2.863 milliseconds (cumulative count 100000)

To see the real-time latency stats for your Redis server, run the following command.

redis-cli --latency

Output:

min: 0, max: 8, avg: 0.25 (5217 samples)

Conclusion

In this post, we explained how to install the Redis server on Fedora Linux. We also showed you how to secure Redis with a password and verify its connectivity. Then, we used the redis-benchmark tool to measure the performance of the Redis server. You can now try Redis on dedicated server hosting from Atlantic.Net!