I tried to stress test my app, which uses Redis heavily.
1) firstly, I killed the the redis-server process, and freed the memory.
2) I started running the stress test with the same request parameter
3) with each request, I retrieved some keys from redis, and then set it back, so the number of keys remains the same
4) When I looked at INFO output I couldn't figure out how used memory increases fast while number of keys remains no change:
127.0.0.1:6379> info
# Server
redis_version:3.0.2
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:3a8a5d4db573b07
redis_mode:standalone
os:Linux 2.6.32-573.el6.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.4.7
process_id:4313
run_id:deadf706ed1cbee05e95785ad051ea2f23efffea
tcp_port:6379
uptime_in_seconds:19176
uptime_in_days:0
hz:10
lru_clock:4456391
config_file:/usr/local/src/redis/conf/redis_6379.conf
# Clients
connected_clients:107
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0
# Memory
used_memory:3170867080
used_memory_human:2.95G
used_memory_rss:3249754112
used_memory_peak:3175951208
used_memory_peak_human:2.96G
used_memory_lua:36864
mem_fragmentation_ratio:1.02
mem_allocator:jemalloc-3.6.0
# Persistence
loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1480851049
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:35
rdb_current_bgsave_time_sec:-1
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok
# Stats
total_connections_received:22547
total_commands_processed:31077781
instantaneous_ops_per_sec:0
total_net_input_bytes:10791364560
total_net_output_bytes:11082643358
instantaneous_input_kbps:0.00
instantaneous_output_kbps:0.00
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:16
evicted_keys:0
keyspace_hits:16252798
keyspace_misses:1477572
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:20579
migrate_cached_sockets:0
# Replication
role:master
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
# CPU
used_cpu_sys:405.70
used_cpu_user:185.58
used_cpu_sys_children:105.62
used_cpu_user_children:796.15
# Cluster
cluster_enabled:0
# Keyspace
db0:keys=46,expires=14,avg_ttl=39773540
As can be seen from above, the used_memory increased from almost zero to 2.9G, while the number of keys is only 46, and I am pretty sure, the value size of each key would not amount to 2.9G high.
Anyone can help explain what is taking up the memory and what's the actual meaning of 'used memory'