PDF
Testing with docker1Redis Memory limit and eviction policy configurationContentsTesting with docker .................................................................................. 1Eviction policy ........................................................................................ 3Testing with dockerCreate a simple application@PostMapping("/generate")public Item generate() { Item item = Item.random(); redisTemplate.opsForValue().set(item.getId(), item); return item;}Keep inserting data via jmeter Testing with docker2Round1: Redis with 128m memorydocker run --name redis-128 \ -d \ -p 6381:6379 \ --memory="128m" \ -v /Users/hfli/Downloads/redis-test-data/redis-128:/data \ redis redis-server--memory="128m"docker stats# docker statsCONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDSa38d4615af6b redis-128 0.12% 126.8MiB / 128MiB 99.06% 182MB / 18.6MB 3.08GB / 264MB 6Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.data.redis.RedisSystemException: Error in execution; nested exception is io.lettuce.core.RedisCommandExecutionException: MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error.] with root causeinfoinfo memorydbsize# redis-cli127.0.0.1:6379> info...# Memoryused_memory:238777840used_memory_human:227.72Mused_memory_rss:134189056used_memory_rss_human:127.97Mused_memory_peak:238777840used_memory_peak_human:227.72Mused_memory_peak_perc:100.00%used_memory_overhead:42998602used_memory_startup:791264 Eviction policy3used_memory_dataset:195779238used_memory_dataset_perc:82.26%127.0.0.1:6379> dbsize(integer) 843802keys *Round2: Redis with 128m memory and maxmemory# redis.confmaxmemory 100mbdocker run -v /Users/hfli/Downloads/redis-test-data/redis-128.conf:/usr/local/etc/redis/redis.conf \ --name redis-128-max \ -d \ -p 6381:6379 \ --memory="128m" \ -v /Users/hfli/Downloads/redis-test-data/redis-128-max:/data \ redis redis-server /usr/local/etc/redis/redis.confnested exception is org.springframework.data.redis.RedisSystemException: Error in execution; nested exception is io.lettuce.core.RedisCommandExecutionException: OOM command not allowed when used memory > 'maxmemory'.] with root causeRound3: Redis with 128m memory and maxmemory and lru# redis.confmaxmemory 100mbmaxmemory-policy allkeys-lrudbsizeEviction policy Eviction policy4config set maxmemory 100mbinfo127.0.0.1:6379> info memory# Memory...maxmemory:104857600maxmemory_human:100.00M0noevictionallkeys-lruvolatile-lruallkeys-randomvolatile-randomvolatile-ttlvolatile-lfuallkeys-lfuHow to choose policyallkeys-lruallkeys-randomvolatile-ttlvolatile-lru/volatile-randomBUTControll LRU precision Eviction policy5maxmemory-samples 5maxmemory_human:0Bmaxmemory_policy:noeviction

HTML view coming soon.

Download PDF for the full formatted version.