• Skip to main content
  • Skip to primary sidebar
  • Home
  • WordPress
  • web Hosting
  • linux
  • mysql
  • nginx
  • apache2
  • devops

Raju Ginni

wordpress tutorials seo hosting etc

You are here: Home / tutorials / Redis performance metrics & tuning for nginx apache ubuntu & debian

Redis performance metrics & tuning for nginx apache ubuntu & debian

Table of Contents

Toggle
  • Redis performance metrics
  • #1 memory
  • #2 total_commands_processed & latency
  • #3Latency  not info command
    • slow log
  • #5 client connections concurrent
  • #6 Memory Fragmentation Ratio or  redis used_memory vs maxmemory
  • $5 Evictions
  • #6 Throughput operations per second
  • ideal Cache Hit Ratio in redis
    • Evicted/Expired Keys
  • Performance tuning
  • Increase max connections  limit by linux kernel

Redis performance metrics

Connection status: accepted and rejected clients
Throughput: commands per seconds
Key evictions: when max memory reached
Memory fragmentation ratio: 1-1.5 system allocated memory for redis.
Cache hit ratio: 0.8 to 1 (1=100%)
Latency: Average time for the Redis server to respond to a request
Redis: single threaded, persistent to disk, more than strings
memcached multithreaded, not persistent to disk, only strings

#1 memory

info memory
root@instance-1:~# redis-cli
127.0.0.1:6379> info memory
# Memory
used_memory:34693568
used_memory_human:33.09M
used_memory_rss:41807872
used_memory_rss_human:39.87M
used_memory_peak:38860568
used_memory_peak_human:37.06M
used_memory_peak_perc:89.28%
used_memory_overhead:1684088
used_memory_startup:782504
used_memory_dataset:33009480
used_memory_dataset_perc:97.34%
total_system_memory:4126593024
total_system_memory_human:3.84G
used_memory_lua:37888
used_memory_lua_human:37.00K
maxmemory:268435456
maxmemory_human:256.00M
maxmemory_policy:allkeys-lru
mem_fragmentation_ratio:1.21
mem_allocator:jemalloc-3.6.0
active_defrag_running:0
lazyfree_pending_objects:0
127.0.0.1:6379>
(used_memory > total available memory   then it uses disk 0.1 μs for memory vs. 10 ms for disk)
setting max memory in redis command line
“volatile-ttl” (expiring keys quickly) or “allkeys-lru”
config set maxmemory

#2 total_commands_processed & latency

127.0.0.1:6379> info stats
# Stats
total_connections_received:19990
total_commands_processed:8900629
total_net_input_bytes:39738291466
total_net_output_bytes:75634761441
rejected_connections:0
expired_keys:855714
expired_stale_perc:0.16
expired_time_cap_reached_count:0
evicted_keys:0
keyspace_hits:4970741
keyspace_misses:2033652
127.0.0.1:6379>
commands in queue
slow commands may blocking

#3Latency  not info command

typical latency for a 1Gb/s network is about 200 μs in redis cluster
go to your redis-cli, change directory to the location of your Redis installation, and type the following: ./redis-cli –latency -h ‘host’ -p ‘port’
./redis-cli –latency -h ‘127.0.0.1’ -p ‘6379’

slow log

Default 10 ms
including network latency 200ms
127.0.0.1:6379> slowlog get
1) 1) (integer) 1
   2) (integer) 1597245698
   3) (integer) 29204
   4) 1) “FLUSHDB”
   5) “127.0.0.1:48666”
   6) “”
2) 1) (integer) 0
   2) (integer) 1596389191
   3) (integer) 14310
   4) 1) “GET”
      2) “w3tc_793616459_rajuginni.com_0_object_0optionsalloptions“
   5) “127.0.0.1:50420”
   6) “”
127.0.0.1:6379>
for setting slow query log to 5ms
try
redis cli:
127.0.0.1:6379> config set slowlog-log-slower-than 5000.

#5 client connections concurrent

127.0.0.1:6379> info clients
# Clients
connected_clients:6
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0
default maximum number of client connections is 10,000
(connected_clients)
maxclients limit in redis.conf
or
config set maxclients  value
110-150% of expected peak number connections

#6 Memory Fragmentation Ratio or  redis used_memory vs maxmemory

mem_fragmentation_ratio
memory used as seen by the operating system (used_memory_rss) to memory allocated by Redis (used_memory)
mem_fragmentation_ratio = used_memory_rss /used_memory
 
RSS stands for Resident Set Size OS value
 
Fragmentation Ratio 1 means 100%.
Fragmentation Ratio 1.5 means 150% memory usage
127.0.0.1:6379> info memory
# Memory
used_memory_human:29.32M
used_memory_rss_human:36.29M
used_memory_peak_human:37.06M
used_memory_peak_perc:79.11%
total_system_memory_human:3.84G
used_memory_lua_human:37.00K
maxmemory_human:256.00M
maxmemory_policy:allkeys-lru
mem_fragmentation_ratio:1.24
mem_allocator:jemalloc-3.6.0
maxmemory_human:256.00M
127.0.0.1:6379>
r: If your fragmentation ratio is above 1.5, restarting your Redis server
restart command
shutdown save
if fragment ration is below 1 then its swapping to disk
memory allocator
(glibc’s malloc, jemalloc11, tcmalloc
re comiling required
redis used_memory vs maxmemory
 
Used Memory is greater than max memory
when new command added, redis checks the memory usage, and if it is greater than the max memory limit , it evicts keys according to the policy
redis used memory vs used memory rss
used memory rss operating system has allocated to Redis.

$5 Evictions

Key evictions only occur if the max memory limit is set
127.0.0.1:6379> info stats
# Stats
expired_keys:858694
evicted_keys:0

#6 Throughput operations per second

instantaneous_ops_per_sec Total number of commands processed per second
127.0.0.1:6379> info commandstats
# Commandstats
cmdstat_slowlog:calls=1,usec=48,usec_per_call=48.00
cmdstat_setex:calls=1102770,usec=7149047,usec_per_call=6.48
cmdstat_mget:calls=12985,usec=256438,usec_per_call=19.75
cmdstat_flushdb:calls=3,usec=29215,usec_per_call=9738.33
cmdstat_get:calls=6965970,usec=49868844,usec_per_call=7.16
cmdstat_del:calls=56983,usec=155292,usec_per_call=2.73
cmdstat_zrangebyscore:calls=141,usec=23262,usec_per_call=164.98
cmdstat_select:calls=30887,usec=56887,usec_per_call=1.84
cmdstat_set:calls=680125,usec=1680851,usec_per_call=2.47
cmdstat_echo:calls=30745,usec=78815,usec_per_call=2.56
cmdstat_ping:calls=19934,usec=21616,usec_per_call=1.08
cmdstat_zremrangebyscore:calls=166,usec=5380,usec_per_call=32.41
cmdstat_info:calls=19994,usec=1363202,usec_per_call=68.18
cmdstat_monitor:calls=4,usec=4,usec_per_call=1.00
cmdstat_command:calls=4,usec=2220,usec_per_call=555.00
cmdstat_zadd:calls=19917,usec=615735,usec_per_call=30.92
127.0.0.1:6379>
peak load, the frequency of peak load, average load
Active Connections

ideal Cache Hit Ratio in redis

keep your cache hit ratio at 0.8 or higher
keyspace_hits:4998497
keyspace_misses:2043235
(Total key hits)/ (Total keys hits + Total key misses).
keyspace = Total number of keys in your database

Evicted/Expired Keys

expired_keys:859846
expired_stale_perc:0.00
expired_time_cap_reached_count:0
evicted_keys:0
allkeys-lru removes the least recently used key from the set of all keys
volatile-lru removes the least recently used key among the ones with an expiration set
allkeys-random removes a random key from the set of all keys
volatile = expiration set
allkeys = from all keys without expiration
lfu: least frequently used
lru: least recently used
random: random key
ttl: time to live (shortest)
volatile-ttl,
volatile-lru,volatile-random,allkeys-lru,allkeys-random,volatile-lfu,allkeys-lfu
info replication

Performance tuning

/etc/redis/redis.conf
RDB Persistence disable it if  you don’t use it. (persist data on disk)

Increase max connections  limit by linux kernel

Max-Connection
sysctl -w net.core.somaxconn=65365
root@instance-1:~# sysctl -w net.core.somaxconn=65365
net.core.somaxconn = 65365
consider server specification.
Pipelining
TCP-KeepAlive  

Redis will get OOM (Out of Memory) error causes by overcommit memory value is 0

Overcommit memory is a kernel parameter which checks if the memory is available or not

nano /etc/sysctl.conf

vm.overcommit_memory = 1

timeout  300 sec

maxmemory 70-90% in dedicated

maxmemory-policy volatile-lru if expires quickly otherwise lru.

 

Also read install & configure redis in ubuntu & debian nginx / apache

 

Primary Sidebar

tutorials

  • Core Java Tutorial Free online
  • HTML & CSS Tutorials
  • Php tutorials
  • ubuntu tutorials installation download issues etc
  • redis install ubuntu 20.04 with wordpress php redis mysql configuration
  • [INTRO] Ethical hacking / cyber Security / Penetration testing Tutorial -{updates frequently}
  • Android Studio tutorials syllabus Topics Course details #AndroidApplicationDevelopment
  • AUdio Editing Background Noise removal (Audacity, Adobe Premiere Addition, Camtasia Filmora Windows Obs)
  • what is vpn vs proxy vs tor, http vs https, http2, tcp vs udp, kali linux sql source code injection
  • how to create a website free of cost on google
  • CCNA Syllabus pdf (CCNA / CCNP vs devops vs mcsa /MCSE)
  • Redis performance metrics & tuning for nginx apache ubuntu & debian
  • xampp tutorials 2021 installation errors fix wordpress phpmyadmin mysql apache
  • new relic installation linux (infrastructure agent , php, mysql , nginx)
  • new relic mysql install integration - 2 ways fix problems
  • new relic php agent install in 3 steps
  • aws load balancer tutorial
  • git branches merge fetch pull conflicts

hi i am raju ginni, primalry i manage wordpress websites on GCP cloud platform as a cloud engineer, and create content on passionate things.
you can follow me on youtbe

© 2025 - All Rights Reserved Disclaimer & Privacy Policy