5

我能够在大约 15 分钟内插入 1000 万个值。我对速度很满意。我有两个问题:

1) 如果我有 30 倍以上的数据,我会有什么问题吗?(大约 3 亿)如有必要,我可以选择增加 RAM。

2)我为此测试目的使用了默认的redis安装。有没有推荐的配置更改?以下是日志输出...

[3112] 20 Oct 09:53:50.074 * 10000 changes in 60 seconds. Saving...
[3112] 20 Oct 09:53:50.101 * Background saving started by pid 3389
[3389] 20 Oct 09:53:51.258 * DB saved on disk
[3389] 20 Oct 09:53:51.260 * RDB: 1 MB of memory used by copy-on-write
[3112] 20 Oct 09:53:51.301 * Background saving terminated with success
[3112] 20 Oct 09:54:52.101 * 10000 changes in 60 seconds. Saving...
[3112] 20 Oct 09:54:52.127 * Background saving started by pid 3394
[3394] 20 Oct 09:54:53.348 * DB saved on disk
[3394] 20 Oct 09:54:53.351 * RDB: 1 MB of memory used by copy-on-write
[3112] 20 Oct 09:54:53.427 * Background saving terminated with success
[3112] 20 Oct 09:55:54.099 * 10000 changes in 60 seconds. Saving...
[3112] 20 Oct 09:55:54.140 * Background saving started by pid 3399
[3399] 20 Oct 09:55:56.345 * DB saved on disk
[3399] 20 Oct 09:55:56.348 * RDB: 16 MB of memory used by copy-on-write
[3112] 20 Oct 09:55:56.440 * Background saving terminated with success
[3112] 20 Oct 09:56:57.044 * 10000 changes in 60 seconds. Saving...
[3112] 20 Oct 09:56:57.115 * Background saving started by pid 3402
[3402] 20 Oct 09:56:59.955 * DB saved on disk
[3402] 20 Oct 09:56:59.961 * RDB: 158 MB of memory used by copy-on-write
[3112] 20 Oct 09:57:00.015 * Background saving terminated with success
[3112] 20 Oct 09:58:01.052 * 10000 changes in 60 seconds. Saving...
[3112] 20 Oct 09:58:01.144 * Background saving started by pid 3404
[3404] 20 Oct 09:58:04.864 * DB saved on disk
[3404] 20 Oct 09:58:04.874 * RDB: 31 MB of memory used by copy-on-write
[3112] 20 Oct 09:58:04.944 * Background saving terminated with success
[3112] 20 Oct 09:59:05.044 * 10000 changes in 60 seconds. Saving...
[3112] 20 Oct 09:59:05.137 * Background saving started by pid 3405
[3405] 20 Oct 09:59:10.468 * DB saved on disk
[3405] 20 Oct 09:59:10.480 * RDB: 32 MB of memory used by copy-on-write
[3112] 20 Oct 09:59:10.537 * Background saving terminated with success
[3112] 20 Oct 10:00:11.091 * 10000 changes in 60 seconds. Saving...
[3112] 20 Oct 10:00:11.238 * Background saving started by pid 3406
[3406] 20 Oct 10:00:16.301 * DB saved on disk
[3406] 20 Oct 10:00:16.316 * RDB: 310 MB of memory used by copy-on-write
[3112] 20 Oct 10:00:16.438 * Background saving terminated with success
[3112] 20 Oct 10:01:17.091 * 10000 changes in 60 seconds. Saving...
[3112] 20 Oct 10:01:17.251 * Background saving started by pid 3408
[3408] 20 Oct 10:01:23.907 * DB saved on disk
[3408] 20 Oct 10:01:23.925 * RDB: 63 MB of memory used by copy-on-write
[3112] 20 Oct 10:01:24.051 * Background saving terminated with success
[3112] 20 Oct 10:02:25.051 * 10000 changes in 60 seconds. Saving...
[3112] 20 Oct 10:02:25.208 * Background saving started by pid 3409
[3409] 20 Oct 10:02:32.606 * DB saved on disk
[3409] 20 Oct 10:02:32.627 * RDB: 63 MB of memory used by copy-on-write
[3112] 20 Oct 10:02:32.708 * Background saving terminated with success
[3112] 20 Oct 10:03:33.008 * 10000 changes in 60 seconds. Saving...
[3112] 20 Oct 10:03:33.182 * Background saving started by pid 3411
[3411] 20 Oct 10:03:41.532 * DB saved on disk
[3411] 20 Oct 10:03:41.555 * RDB: 63 MB of memory used by copy-on-write
[3112] 20 Oct 10:03:41.682 * Background saving terminated with success
[3112] 20 Oct 10:04:42.082 * 10000 changes in 60 seconds. Saving...
[3112] 20 Oct 10:04:42.272 * Background saving started by pid 3413
[3413] 20 Oct 10:04:51.376 * DB saved on disk
[3413] 20 Oct 10:04:51.401 * RDB: 63 MB of memory used by copy-on-write
[3112] 20 Oct 10:04:51.472 * Background saving terminated with success
[3112] 20 Oct 10:05:52.072 * 10000 changes in 60 seconds. Saving...
[3112] 20 Oct 10:05:52.279 * Background saving started by pid 3414
[3414] 20 Oct 10:06:02.434 * DB saved on disk
[3414] 20 Oct 10:06:02.461 * RDB: 64 MB of memory used by copy-on-write
[3112] 20 Oct 10:06:02.579 * Background saving terminated with success
[3112] 20 Oct 10:07:03.065 * 10000 changes in 60 seconds. Saving...
[3112] 20 Oct 10:07:03.366 * Background saving started by pid 3416
[3416] 20 Oct 10:07:15.095 * DB saved on disk
[3416] 20 Oct 10:07:15.129 * RDB: 634 MB of memory used by copy-on-write
[3112] 20 Oct 10:07:15.266 * Background saving terminated with success
[3112] 20 Oct 10:08:16.013 * 10000 changes in 60 seconds. Saving...
[3112] 20 Oct 10:08:16.331 * Background saving started by pid 3420
[3420] 20 Oct 10:08:27.988 * DB saved on disk
[3420] 20 Oct 10:08:28.024 * RDB: 125 MB of memory used by copy-on-write
[3112] 20 Oct 10:08:28.131 * Background saving terminated with success
4

1 回答 1

8

如果您计划拥有 30 倍以上的数据,您可以运行“INFO memory”命令,检查 used_memory_human 的值,乘以 30,获取安全边际,看看它是否仍然适合您的服务器。安全边际取决于应用在 Redis 实例上的写入吞吐量。你写的越多,转储时的写时复制开销就越大。

规则是一切都应该适合物理内存。请注意,如果您的服务器还运行其他一些软件,则需要考虑它们的内存消耗。运行 Redis 的服务器不应该交换。

关于您的第二个问题,针对生产环境进行更改的参数并不多。我通常只检查日志级别(将其设置为通知)和持久性选项(即存储转储文件的位置等......)。

您可能希望在加载数据时停用 RDB 转储,然后再重新激活。您可以从 redis-cli 执行此操作:

# To deactivate RDB dump
config set save ""

# To reactivate RDB dump (1 dump every 2 hours)
config set save "7200 1"
于 2013-10-21T17:45:15.647 回答