Lot of swap usage with LRU

47 views
Skip to first unread message

yam...@gmail.com

unread,
Feb 22, 2018, 8:45:51 AM2/22/18
to Redis DB
Hello,

I'm using Redis 3.2.4. as an LRU cache, single node, no backup.

This instance is managed by AWS (elasticache), it's a cache.r3.8xlarge instance.

Only 2 commands are used : MGET and MSET.
A daily job update/insert 80% of the keys, causing some evictions.

The problem is that there is a lot of swap usage (50+g) despite 60g of reserved memory.

Is it a normal behaviour ?
If no, what do you recommend to avoid swapping ?

Here is the result of the INFO command.

# Server
redis_version:3.2.4
redis_git_sha1:0
redis_git_dirty:0
redis_build_id:0
redis_mode:standalone
os:Amazon ElastiCache
arch_bits:64
multiplexing_api:epoll
gcc_version:0.0.0
process_id:1
run_id:bd7b97acac883a89a5ba60df27aa9875d9ca9684
tcp_port:6379
uptime_in_seconds:1741243
uptime_in_days:20
hz:10
lru_clock:9356334
executable:-
config_file:-

# Clients
connected_clients:16
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0

# Memory
used_memory:189384454240
used_memory_human:176.38G
used_memory_rss:254735060992
used_memory_rss_human:237.24G
used_memory_peak:189402474256
used_memory_peak_human:176.39G
used_memory_lua:37888
used_memory_lua_human:37.00K
maxmemory:189384537600
maxmemory_human:176.38G
maxmemory_policy:allkeys-lru
mem_fragmentation_ratio:1.35
mem_allocator:jemalloc-4.0.3

# Persistence
loading:0
rdb_changes_since_last_save:31846948645
rdb_bgsave_in_progress:0
rdb_last_save_time:1517564531
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:-1
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:399550
total_commands_processed:10091737461
instantaneous_ops_per_sec:8901
total_net_input_bytes:4145120858831
total_net_output_bytes:653366791892
instantaneous_input_kbps:1321.33
instantaneous_output_kbps:519.92
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
evicted_keys:5016194955
keyspace_hits:15107193910
keyspace_misses:14882613992
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:0
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:57548.25
used_cpu_user:248842.08
used_cpu_sys_children:0.00
used_cpu_user_children:0.00

# Cluster
cluster_enabled:0

# Keyspace
db0:keys=1342909032,expires=0,avg_ttl=0

Itamar Haber

unread,
Feb 22, 2018, 9:18:48 AM2/22/18
to Redis DB
Hello Yamo,

> is it a normal behaviour ? 

Yes and no. Yes, if the OS is configured to swap. No, because you usually disable OS swapping when deploying a Redis server (unless you want to swap, but then why use an in-memory database in the first place?).

If no, what do you recommend to avoid swapping ?

Turn it off at the OS level (i.e. usually means don't create a swap fs and turn everything off w/ sysctl or equiv).

--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+unsubscribe@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at https://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.



--

Itamar Haber | Technology Evangelist
Redis Labs ~/redis

Mobile: +972 (54) 567 9692
Twitter: @itamarhaber
Skype: itamar.haber

Plhu

unread,
Feb 22, 2018, 9:46:17 AM2/22/18
to redi...@googlegroups.com

It depends on the reason why the system gets in the swap which may
happen also due to a different process than your redis server. Check
that overall with

sar -r 1 10

and look for all the columns namely kbbuffers, kbcached, kbmemfree,
kbmemmused, kbdirty. Then check the top to see the memory consumption of
redis itself. If you turn off the swap and the problem would be caused
by other processes than redis, you may get a system in out of memory
state which would be worse.

Lukas

yam...@gmail.com

unread,
Feb 22, 2018, 10:03:44 AM2/22/18
to Redis DB
Hi,

Thanks a lot for quick answer.

As I'm using elasticache, I can't disable swapping.
It seems the only parameter that I can tune is reserved memory. The current value is 60g. It seems pretty high but maybe still not sufficient …
Is there a way or at least some rule to determine the right value for this parameter according my use case ?
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.

To post to this group, send email to redi...@googlegroups.com.
Visit this group at https://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages