Redis-监视内存使用情况 [英] Redis - monitoring memory usage

查看:87
本文介绍了Redis-监视内存使用情况的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在测试将密钥插入数据库Redis(在本地)中的情况. 我有超过500万个密钥,而且我只有4GB的RAM,因此,一会儿我就达到了RAM的容量并交换了数据(并且我的PC掉了)...

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 swap fill in (and my PC goes down)...

我的问题:如何在具有Redis数据库的计算机上监视内存使用情况,并以此方式发出警报,不再在Redis数据库中插入某些键?

My problematic : How can I make monitoring memory usage on the machine which has the Redis database, and in this way alert no more insert some keys in the Redis database ?

谢谢.

推荐答案

关于内存使用情况,建议您查看redis.io 常见问题解答以及有关将redis用作LRU缓存.

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

您可以通过maxmemory配置设置来限制内存使用量,在这种情况下,一旦达到内存限制,所有写请求都会因错误而失败,或者可以将maxmemory-policy设置为allkeys-lru,例如,开始用您当前需要的东西等覆盖服务器上最近最少使用的数据.对于大多数用例,您具有足够的灵活性,可以通过适当的配置来处理此类问题.

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.

我的建议是使事情简单化,并通过配置redis服务器来解决此问题,而不是通过os级监视等引入额外的复杂性.

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.

这篇关于Redis-监视内存使用情况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆