Redis

Shardul | Mar 4, 2024 min read

Redis (Remote Dictionary Server) is a high-performance, in-memory key–value data store widely used as a cache, message broker, and lightweight database. Known for its speed and simplicity, Redis is commonly deployed in modern web applications to improve response times, handle high traffic loads, and support real-time features.

In this guide, we walk through the complete process of installing Redis on a RHEL-based Linux system using dnf, configuring basic settings, enabling remote access, setting up authentication for security, and running performance benchmarks. Whether you’re setting up Redis for development or preparing it for production, this step-by-step tutorial will help you get started quickly and securely.

Installation

sudo dnf install redis -y
rpm -q redis

Verify installation:

redis-server --version

Start and Enable Redis Service

sudo systemctl start redis
sudo systemctl enable redis
systemctl status redis.service

Check if Redis is listening on port 6379:

sudo netstat -pnltu | grep redis

Or (recommended on newer systems):

sudo ss -lntp | grep 6379

Basic Configuration

Edit Redis configuration file:

vim /etc/redis.conf

Allow Remote Connections:

Change:

bind 127.0.0.1

To:

bind 0.0.0.0

Then restart:

sudo systemctl restart redis

Test Redis

redis-cli

Inside CLI:

ping

Expected output:

PONG

Exit:

exit

Enable Authentication

Edit config:

vim /etc/redis.conf

Find and uncomment:

requirepass yourpassword

change to your password:

requirepass G@lxy2030

Restart Redis:

sudo systemctl restart redis

Test Authentication

Without password:

redis-cli
127.0.0.1:6379> ping

Output:

(error) NOAUTH Authentication required.

Authenticate:

redis-cli
127.0.0.1:6379> auth G@lxy2030
OK

Now:

127.0.0.1:6379> ping
PONG

You can also connect with password directly:

redis-cli -a G@lxy2030

Benchmark Redis

Run quick benchmark:

redis-benchmark -q

Test specific commands:

redis-benchmark -t set,get -q

Example output:

SET: 120000.00 requests per second
GET: 150000.00 requests per second

If Redis is exposed externally:

Use Firewall

sudo firewall-cmd --add-port=6379/tcp --permanent
sudo firewall-cmd --reload

Or restrict to specific IP:

sudo firewall-cmd --add-rich-rule='rule family="ipv4" source address="192.168.1.10" port port="6379" protocol="tcp" accept' --permanent

Disable Protected Mode Only If Necessary

In /etc/redis.conf:

protected-mode no

(Only if properly firewalled and authenticated.)

Consider Redis 6+ ACL Instead of requirepass

Modern Redis supports ACL users:

ACL SETUSER appuser on >password ~* +@all

Conclusion

Redis is a powerful and lightweight data store that can be deployed in minutes yet scaled to support enterprise-grade applications. In this tutorial, we covered installation, service management, configuration adjustments, authentication setup, and benchmarking to validate performance.

While the basic setup is straightforward, securing your Redis instance is critical — especially when allowing remote access. Always use authentication, restrict network access with firewall rules, and consider advanced security features such as ACLs in production environments.

With Redis properly configured, you now have a fast and reliable in-memory data store ready to power caching, session management, queues, and real-time applications. From here, you can explore persistence options, replication, clustering, and performance tuning to take your deployment to the next level.