Value percentage for maxmemory

289 views
Skip to first unread message

chilumb...@gmail.com

unread,
Nov 17, 2015, 10:41:03 AM11/17/15
to Redis DB
All our Redis master instances have maxmemory set to 80% of total RAM. Each of these master also have a slave. RDB is disabled on the master (yet still enabled on the slaves) to minimize disk I/O waste. The maxmemory policy used is volatile-lru. 

We noticed that Redis is using a lot of memory. I read somewhere that the best percentage for maxmemory is 45% of total RAM since almost the same amount (45% more) will be used for performing replication. 

With mexmemory already set to 80% and redis already using almost all of that, would adjusting it down to 45% impact performance? What would be the implications for doing so?

Josiah Carlson

unread,
Nov 17, 2015, 2:45:14 PM11/17/15
to redi...@googlegroups.com
Replies inline.

On Tue, Nov 17, 2015 at 7:41 AM, <chilumb...@gmail.com> wrote:
All our Redis master instances have maxmemory set to 80% of total RAM. Each of these master also have a slave. RDB is disabled on the master (yet still enabled on the slaves) to minimize disk I/O waste. The maxmemory policy used is volatile-lru. 

Just in case you didn't know, volatile-lru will only delete keys that have an expiration set.

We noticed that Redis is using a lot of memory. I read somewhere that the best percentage for maxmemory is 45% of total RAM since almost the same amount (45% more) will be used for performing replication.

I am curious to know where you read that, because those numbers and information are at best misleading, and are most certainly wrong.

Generally speaking, Redis doesn't really use any additional memory for slaving, except for initial slave connection that can cause a full snapshot to be created. During snapshot creation, memory use can double, but that depends on how long it takes to perform the snapshot, how many write operations you are performing at the same time, etc. You can look at your Redis log to see how much additional memory is used during the snapshot and/or bgrewriteaof process to get an idea of how much memory is actually being used to slave/snapshot/rewrite the AOF.

With mexmemory already set to 80% and redis already using almost all of that, would adjusting it down to 45% impact performance?

Not Redis itself; it will just delete your data earlier. Your clients may need to hit the DB more often, depending on your app.
 
What would be the implications for doing so?

Less memory used by Redis, less data stored in Redis, hit rates will go down if you are using Redis as a cache, and your working set is bigger than 45% of memory.

 - Josiah

--
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+u...@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at http://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.

chilumb...@gmail.com

unread,
Nov 18, 2015, 2:36:47 AM11/18/15
to Redis DB
Each of the Redis Instance in the cluster has total RAM of 15G. And each Redis instance has "maxmemory" set to 12G (80% of total RAM).

However, we noticed in our xymon monitoring system that Redis is using swap (sometimes all the swap 100%) even if it seems that there is still free memory. Is this because setting maxmeory in Redis to 80% means that when all 80% memory is used, Redis will start using swap (or push other processes to use swap) instead of maybe just deleting some data? I really do not understand why Redis is using swap at all.

The system snappiness is set to =0 on all Redis instances. So far, i was just able to release the swap and did not adjust the system value for snappiness. 

Below is what is being logged by our monitoring system xymon:

redis-2-1.memory (ip_address) yellow (1089813 seconds)
yellow Wed Nov 18 14:16:38 CST 2015 - Memory low
             Memory              Used       Total            Percentage
&green Physical          15234M      16043M         94%

&green Actual            11733M       16043M          73%
&yellow Swap                839M        953M             88%


redis-2-1.memory (ip_addresss) red (1077170 seconds)
red Wed Nov 18 10:46:21 CST 2015 - Memory CRITICAL
            Memory              Used       Total            Percentage
&green Physical          15193M      16043M         94%
&green Actual            11698M      16043M         72%
&red     Swap                953M        953M           100%
Reply all
Reply to author
Forward
0 new messages