我正在调查我们系统上的redis内存问题。
我试图找出所做的10000次更改(在我看来太多了)
奇怪的是,我得到了10000 changes in 60 seconds. Saving...
但是每3分钟而不是60秒,就像我预期的那样。
记录样本:
[10993] 03 Jan 06:37:46.166 * 10000 changes in 60 seconds. Saving...
[10993] 03 Jan 06:37:46.167 * Background saving started by pid 4802
[4802] 03 Jan 06:37:46.170 * DB saved on disk
[4802] 03 Jan 06:37:46.170 * RDB: 2 MB of memory used by copy-on-write
[10993] 03 Jan 06:37:46.268 * Background saving terminated with success
[10993] 03 Jan 06:40:27.140 * 10000 changes in 60 seconds. Saving...
[10993] 03 Jan 06:40:27.141 * Background saving started by pid 5081
[5081] 03 Jan 06:40:27.145 * DB saved on disk
[5081] 03 Jan 06:40:27.145 * RDB: 2 MB of memory used by copy-on-write
[10993] 03 Jan 06:40:27.242 * Background saving terminated with success
[10993] 03 Jan 06:43:08.335 * 10000 changes in 60 seconds. Saving...
redis_version:2.8.4
答案 0 :(得分:3)
save 60 10000
表示redis会定期检查自上次rdb保存以来 至少有至少 60秒后是否至少有10000次更改和 。只有当满足这两个条件时(对于任何保存点),才会启动新的rdb保存。
另外,如果您认为~3分钟内10000次变化听起来很多,请不要忘记一个命令可以将变化次数增加一个以上,例如MSET
。
答案 1 :(得分:1)
这是从 redis.conf 文件中复制的,它解释了所有内容。
################################ SNAPSHOTTING ################################
#
# Save the DB on disk:
#
# save <seconds> <changes>
#
# Will save the DB if both the given number of seconds and the given
# number of write operations against the DB occurred.
#
# In the example below the behaviour will be to save:
# after 900 sec (15 min) if at least 1 key changed
# after 300 sec (5 min) if at least 10 keys changed
# after 60 sec if at least 10000 keys changed
#
# Note: you can disable saving completely by commenting out all "save" lines.
#
# It is also possible to remove all the previously configured save
# points by adding a save directive with a single empty string argument
# like in the following example:
#
# save ""
save 900 1
save 300 10
save 60 10000
如果您想查看所有活动,请使用监视器
命令$ redis-cli monitor
1339518083.107412 [0 127.0.0.1:60866] "keys" "*"
1339518087.877697 [0 127.0.0.1:60866] "dbsize"
1339518090.420270 [0 127.0.0.1:60866] "set" "x" "6"
1339518096.506257 [0 127.0.0.1:60866] "get" "x"
1339518099.363765 [0 127.0.0.1:60866] "del" "x"
1339518100.544926 [0 127.0.0.1:60866] "get" "x"