On redis memory footprint

At present, most programmers have to put some data into the cache (redis) in, but if you understand this redis memory footprint it? Here we look at it redis optimal use of memory:

1, we first introduce us into a lot of data to the redis partial data loss situations occur:

  Redis is used as cache memory. Memory is infinite it? Instead, the memory is very precious and limited, disks are cheap and lots of. It may be a machine on the memory of dozens of G, but there are a few T of hard disk space. Redis mainly based memory to high performance, high concurrency of reading and writing operations.

  Now that memory is limited, such as Redis can only use 10 G, you have been entered, and write data has been written has been written the last 10 G are used almost, you will write, what you think will happen? Of course, kill some of the data, then the data retention of 10 G. You said you would not cause data loss?

  What Redis data that will get rid of? What data retention do? Of course, is to get rid of infrequently accessed data, the common data retention.

  So, this is a cache of the most basic concepts: data will expire. Either you set a expiration time, either to kill himself Redis.

  So your Redis if used improperly, to keep production data into it, and did not go to the persistent mysql, then there will likely be lost.

2, let us introduce Expires:

  One is that if you set up a key to the expiration time, you know, to a certain time to go check that there is no key, but you know how you ended up redis is expired yet? When removed?

  If you do not know, in the actual use of the process you might find such a problem: why should obviously a lot of data has expired, and found that redis memory usage is still high? That's because you do not know Redis key is how to delete those expired in .

  For example, Redis memory, a total of 10 G, you write the data entered, now five G's, then you are all set after 10 minutes of these data has expired, the result after 10 minutes, check back to see you, Redis memory usage how is it 50%? 5 G data have expired, I checked the redis years, is finding out, knot

  If stale data also why it occupied the Redis memory.

  Even if you do not know the problem, come up on the ignorant, the answer does not come out, I suggest you do more homework before using Redis, or you write code, granted that written Redis data will certainly exist, resulting in back systems of various loopholes and bug, not Haonong.

Well, these introduce it today, after a time to continue to talk! ! ! !

Guess you like

Origin www.cnblogs.com/lv-books/p/12119765.html