【发布时间】:2016-08-17 16:23:59
【问题描述】:
我有一个 Redis 实例,它充当 Logstash 的队列和 Sensu 的数据库,所以理想情况下,队列几乎总是空的,因为 Logstash 能够以提交给 Redis 的速率处理日志,而 Sensu 只存储最近的测量。但是,当我在 Redis 上执行检查内存使用情况时,会说:
root@b7588aa11859:/data# redis-cli info | grep memory
used_memory:751751344
used_memory_human:716.93M
used_memory_rss:774729728
used_memory_peak:754163560
used_memory_peak_human:719.23M
used_memory_lua:154624
但是当我检查dump.rdb 文件的大小时,它说:
root@b7588aa11859:/data# ls -lah
total 212K
drwxr-xr-x 2 redis redis 4.0K Apr 24 08:22 .
drwxr-xr-x 49 root root 4.0K Apr 21 06:07 ..
-rw-r--r-- 1 redis redis 203K Apr 24 08:22 dump.rdb
Logstash 似乎工作正常;日志流入 Kibana,指标流入 Grafana。
当我运行 rdb -c memory dump.rdb 时,我得到很多使用很少内存的键,只有 topbeat 键(我使用 topbeat 收集指标)使用大量内存:
database,type,key,size_in_bytes,encoding,num_elements,len_largest_element
0,list,"topbeat",797811,linkedlist,1686,986
但是,797811 字节仍然只有 779 KB。
那么,为什么 Redis 仍然占用所有内存?在过去的约 2200 分钟内,其内存使用量一直以约 300KB/分钟的速度稳步增长。
这里有一些日志:
1:M 24 Apr 08:22:07.312 * 10000 changes in 60 seconds. Saving...
1:M 24 Apr 08:22:07.333 * Background saving started by pid 5648
5648:C 24 Apr 08:22:07.346 * DB saved on disk
5648:C 24 Apr 08:22:07.362 * RDB: 1 MB of memory used by copy-on-write
1:M 24 Apr 08:22:07.449 * Background saving terminated with success
1:M 24 Apr 08:25:07.403 * 10000 changes in 60 seconds. Saving...
1:M 24 Apr 08:25:07.427 * Background saving started by pid 5657
5657:C 24 Apr 08:25:07.462 * DB saved on disk
5657:C 24 Apr 08:25:07.473 * RDB: 1 MB of memory used by copy-on-write
1:M 24 Apr 08:25:07.527 * Background saving terminated with success
1:M 24 Apr 08:29:07.375 * 10000 changes in 60 seconds. Saving...
1:M 24 Apr 08:29:07.391 * Background saving started by pid 5660
5660:C 24 Apr 08:29:07.419 * DB saved on disk
5660:C 24 Apr 08:29:07.433 * RDB: 1 MB of memory used by copy-on-write
1:M 24 Apr 08:29:07.492 * Background saving terminated with success
1:M 24 Apr 08:33:07.372 * 10000 changes in 60 seconds. Saving...
1:M 24 Apr 08:33:07.396 * Background saving started by pid 5661
5661:C 24 Apr 08:33:07.423 * DB saved on disk
5661:C 24 Apr 08:33:07.435 * RDB: 2 MB of memory used by copy-on-write
1:M 24 Apr 08:33:07.496 * Background saving terminated with success
【问题讨论】:
标签: redis