Both changes just pushed on Git.
Cheers,
Salvatore
Perfect timing. I just ran into these issues over the weekend. The
overcommit_memory setting allowed me to push the limits of the RAM on
the system (64G):
INFO:
{:uptime_in_seconds=>"11743",
:changes_since_last_save=>"0",
:uptime_in_days=>"0",
:bgsave_in_progress=>"0",
:redis_version=>"0.100",
:last_save_time=>"1241459212",
:connected_clients=>"1",
:total_connections_received=>"8",
:connected_slaves=>"0",
:total_commands_processed=>"320230613",
:used_memory=>"50910391075"}
1. used_memory is only report 47.41G, but my redis process seems to be
more like 62G. The system's swap is completely full and nothing else
is really taking up any RAM, so I wonder what exactly used_memory is a
sum of?
2. Obviously when you hit the swap performance goes way down. Five
clients inserting records as fast as they could stayed pretty constant
at about 10k inserts in 1.5 seconds each ... when Redis started to
swap that same 10k went to 5 seconds each, then 8, then 16, then 21
and on and on.
3. Redis was able to write out the dump even when it was hitting the
swap space. It wasn't pretty but it wrote it out even with 6 of the 16
cores completely pegged and all available RAM and swap allocated.
4. Oddly, my dump.rdb is only 4.8G for the above redis process. I do
NOT have sharedobjects set to yes, and so this value is much smaller
than I would have expected. The keys are variable in size but the data
is the same two bytes over and over. Is this the result of
compression?
5. Is there anyway the INFO command could list the numbers of keys or
"objects" in the system? This would be very useful. I think we
inserted ~317 million.
6. We would love the maxmemory setting. Any thoughts on when this
might be added?
Looking very promising Salvatore!
--
Brenden C Grace
Hello Brenden,
> 1. used_memory is only report 47.41G, but my redis process seems to be
> more like 62G. The system's swap is completely full and nothing else
> is really taking up any RAM, so I wonder what exactly used_memory is a
> sum of?
It's the sum of all the allocated memory, but internally malloc() is
wasting memory by fragmentation and storing information about the
chunks of allocated memory.
> 2. Obviously when you hit the swap performance goes way down. Five
> clients inserting records as fast as they could stayed pretty constant
> at about 10k inserts in 1.5 seconds each ... when Redis started to
> swap that same 10k went to 5 seconds each, then 8, then 16, then 21
> and on and on.
I expected even worse of this... I wonder what the "curve" of
performance degradation is. I mean, to reach 21 seconds it was needed
to add just a few keys more or, for example, 20% of keys more?
> 3. Redis was able to write out the dump even when it was hitting the
> swap space. It wasn't pretty but it wrote it out even with 6 of the 16
> cores completely pegged and all available RAM and swap allocated.
Nice
> 4. Oddly, my dump.rdb is only 4.8G for the above redis process. I do
> NOT have sharedobjects set to yes, and so this value is much smaller
> than I would have expected. The keys are variable in size but the data
> is the same two bytes over and over. Is this the result of
> compression?
Yep this is probably the result of compression if the values had a lot
of redundancy. Note that Redis is using both string values
compressions and integer encoding of keys and values can look like an
integer and can be reconstructed bit-by-bit as the original string
saving by their integer representation. So for example "2112938487"
will only take four bytes in the DB dump, but instead " 2112938487"
will be stored as a string since there is a space before the number.
> 5. Is there anyway the INFO command could list the numbers of keys or
> "objects" in the system? This would be very useful. I think we
> inserted ~317 million.
Sure, I'll add it in seconds.
317 millions looks cool :)
> 6. We would love the maxmemory setting. Any thoughts on when this
> might be added?
I'll work in this tomorrow. Just to make sure it makes sense, this is
how I want to implement it:
When maxmemory is reached:
- The server replies to -ERR to every "write" command received, but
DEL that will continue to work
- every second will try to get space trying to expire volatile keys
(keys with timeouts associated). The algorithm will be something like
this:
while(memory_used >= maxmemory) {
Get five keys with timeout assoicated at random
Select the key that has the shorter time to live
Delete this key
}
- every second will try to get space trying to remove elements from
the Redis objects free list cache.
Does this look sane?
> Looking very promising Salvatore!
Thanks! your testing is impressive.
I noticed it took Redis a while to start back up when I restarted the
process, so I hacked Redis to exit after it had finished loading in
the DB file mentioned above and it took ~11 minutes. Its not an issue
for me, but I thought I would pass it along for those who might be
interested in data loading times ...
# time ./redis-server redis.conf
- Server started, Redis version 0.100
- DB loaded from disk
real 11m0.194s
user 9m42.540s
sys 1m15.910s
--
Brenden C Grace