+91 9619904949

Redis Server is an open-source, in-memory data structure store that is widely used as a caching layer, message broker, and database. It is designed for high performance, low latency, and where data needs to be stored and retrieved quickly.

Redis is often referred to as a “data structure server” because it provides a variety of data structures like strings, lists, sets, sorted sets, hashes, bitmaps, and more, which can be manipulated using a rich set of commands.

Key features of Redis Server:

1 Transactions: Redis supports multi-command transactions, ensuring that a series of operations are executed as a single unit.
2 In-Memory Storage: Redis stores all data in memory, which allows for extremely fast read and write operations. While this provides high performance, it also means that Redis is more suitable for datasets that can fit within the available memory.
3 Lua Scripting: Redis supports Lua scripting, allowing you to execute custom logic directly on the server side.
4 Persistence: Redis offers different mechanisms for data persistence, allowing you to save your data to disk so it can survive server restarts or failures. This persistence can be configured to be either asynchronous (using snapshotting or append-only files) or synchronous.
5 Atomic Operations: Redis provides atomic operations on various data structures, ensuring that certain operations are executed without being interrupted by other commands.
6 Replication: Redis supports master-slave replication, allowing you to create copies of your Redis dataset on multiple servers. This can be used for high availability and load distribution.
7 Pub/Sub Messaging: Redis can be used as a publish-subscribe messaging system, enabling communication between different parts of an application or different applications altogether.
8 Caching: One of the most common use cases for Redis is caching. It can store frequently accessed data in memory, reducing the need to fetch data from slower data stores like databases.

 

Redis Server Provides numerous benefits, but it also has some limitations. Below are the  pros and cons of Redis:

pros cons
(1) High performance: Redis is designed for speed, providing fast read and write performance due to its in-memory nature.

(2) Versatile data structures: Redis supports a wide range of data structures, making it suitable for a variety of uses beyond simple key-value storage.

(3) Atomic Operations: Redis supports atomic operations on data structures, ensuring consistency and reliability in multi-step operations.

(4) Caching: Redis is an excellent choice for caching frequently accessed data, reducing the load on primary data sources and improving application performance.

(5) Pub/Sub Messaging: Redis’ publish-subscribe mechanism enables real-time communication between different parts of an application or between completely separate applications.

(6) Replication and high availability: Redis provides master-slave replication for data redundancy and failover, increasing system reliability.

(7) Persistence: Redis provides options for data persistence, allowing you to store data on a disk and retrieve it after a restart.

(8) Lua Scripting: Redis supports server-side scripting, which allows you to perform complex operations without multiple round-trips to the server.

(9) Geospatial Indexing: Redis has built-in support for geospatial data and can perform distance calculations and queries based on geographic coordinates.

(10) Community and Ecosystem: Redis has a large and active community, with a rich ecosystem of client libraries and tools for various programming languages.

(1) Memory usage:- Redis stores all data in memory, so it may not be suitable for datasets or datasets larger than available memory.

(2) Data Durability: While Redis offers persistent options, it does not provide as much durability as traditional disk-based databases.

(3) Single-threaded: Redis is primarily single-threaded, which means it cannot fully utilize modern multi-core CPUs for certain workloads.

(4) Complex queries: Redis is optimized for simple data access patterns; Complex questions are not his primary strength.

(5) No SQL language: Redis does not provide a SQL-like query language, so advanced query and filtering capabilities are limited.

(6) Limited use for complex transactions: While Redis supports transactions, it may not be suitable for very complex transaction scenarios.

(7) Learning curve: Advanced features and data structures of Redis can have a steep learning curve for newcomers.

(8) Scaling challenges: Scaling Redis horizontally across multiple nodes can involve more complexity than some other data stores.

 

Install Redis-server:-

Ubuntu Centos
apt update
apt install redis-server
systemctl start redis-server
systemctl status redis-server
systemctl enable redis-server edit /etc/redis/redis.conf as per your requirement.
dnf update
dnf install redis
systemctl start redis
systemctl status redis
systemctl enable revised/etc/redis.conf as per your requirement.

 

OS tunning for Redis:-

1 vm.swappiness=0 # turn off swapping
2 net.ipv4.tcp_sack=1 # enable selective acknowledgments
3 net.ipv4.tcp_timestamps=1 # needed for selective acknowledgments
4 net.ipv4.tcp_window_scaling=1 # scale the network window
5 net.ipv4.tcp_congestion_control=cubic # Better congestion algorithm
6 net.ipv4.tcp_syncookies=1  # enable syn cookies
7 net.ipv4.tcp_tw_recycle=1 # Recycle sockets quickly
8 net.ipv4.tcp_max_syn_backlog=NUMBER  # backlog setting
9 net.core.somaxconn=NUMBER # up the number of connections per port
10 net.core.rmem_max=NUMBER # Up the receive buffer size
11 net.core.wmem_max=NUMBER # Up the buffer size for all connections
12

 

“redis.conf” changes:-

bind 0.0.0.0
protected-mode yes
port 6379
tcp-backlog 511
timeout 10
tcp-keepalive 300
daemonize yes
supervised no
pidfile /var/run/redis/redis-server.pid
loglevel notice
logfile /var/log/redis/redis-server.log
databases 16
always-show-logo yes
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression no
rdbchecksum yes
dbfilename dump.rdb
dir /var/lib/redis
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
maxclients 102400
maxmemory 1gb
maxmemory-policy allkeys-lru
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
slave-lazy-flush no
appendonly no
appendfilename “appendonly.aof”
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 512mb
aof-load-truncated yes
aof-use-rdb-preamble no
lua-time-limit 5000
cluster-enabled yes
#cluster-config-file nodes.conf
cluster-node-timeout 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events “”
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 0 0 0
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes
replica-priority 100
replica-lazy-flush no
stream-node-max-bytes 4096
stream-node-max-entries 100
dynamic-hz yes
rename-command CONFIG “NIT-CONFIG”
rename-command FLUSHDB “NIT-FLUSHDB”
rename-command FLUSHALL “NIT-FLUSHALL”
rename-command DEBUG “NIT-DEBUG”
rename-command SHUTDOWN “NIT-SHUTDOWN”
lua-time-limit 5000