Redis - monitoring memory usage

前端 未结 3 1437
广开言路
广开言路 2021-02-07 23:13

I am currently testing insertion of keys in a database Redis (on local). I have more than 5 millions keys and I have just 4GB RAM so at one moment I reach capacity of RAM and sw

3条回答
  •  被撕碎了的回忆
    2021-02-07 23:40

    Concerning memory usage, I'd advise you to look at the redis.io FAQ and this article about using redis as a LRU cache.

    You can either cap the memory usage via the maxmemory configuration setting, in which case once the memory limit is reached all write requests will fail with an error, or you could set the maxmemory-policy to allkeys-lru, for example, to start overwriting the least recently used data on the server with stuff you currently need, etc. For most use cases you have enough flexibility to handle such problems through proper config.

    My advice is to keep things simple and manage this issue through configuration of the redis server rather than introducing additional complexity through os-level monitoring or the like.

提交回复
热议问题