I’ve quoted the following from the configuration file of Redis:
...
maxmemory
MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
is reached? You can select among five behavior:
...
And here my question goes: What is the correct condition to check when maxmemory is reached?
First, I thought the answer is [used_memory >= maxmemory], where used_memory is showed by the INFO command.
But, now I am confusing that the answer maybe [used_memory_rss >= maxmemory].
What is the correct answer?
The maxmemory parameter is compared to a value calculated from used_memory, not used_memory_rss.
Now, the exact behavior is not trivial, because Redis tries to estimate the amount of memory taking in account master/slave replication, and AOF buffering. The value is used_memory (as calculated by the allocator wrapper) minus the size of slaves output buffers, minus the size of AOF buffers. Then this value is compared to maxmemory.