我试图对我的应用程序进行压力测试,该应用程序大量使用 Redis。
1)首先,我杀死了 redis-server 进程,并释放了内存。
2)我开始使用相同的请求参数运行压力测试
3)对于每个请求,我从redis中检索了一些键,然后将其设置回来,因此键的数量保持不变
4)当我查看 INFO 输出时,我无法弄清楚使用的内存如何快速增加而键的数量保持不变:
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
从上面可以看出,used_memory 从几乎为零增加到了 2.9G,而 key 的数量只有 46 个,我很确定每个 key 的 value size 不会达到 2.9G 高。
任何人都可以帮助解释什么是占用内存以及“已用内存”的实际含义是什么