我们在heroku上使用sidekiq pro 1.7.3和sidekiq 3.1.4,Ruby 2.0,Rails 4.0.5,带有1.75G内存的redis green插件。
我们经营了很多sidekiq批处理工作,每天大约有200万个工作岗位。我们注意到,redis内存在一周内稳步增加。我原本以为当队列是空的并且没有工作人员忙时,redis的内存使用率会很低,但它看起来仍然很高。我每周都被迫做一次flushdb,因为我们接近redis内存限制。
我与Redisgreen有一系列的通信,他们建议我联系sidekiq社区。以下是redisgreen的一些统计数据:
以下是整个数据库中RAM使用情况的快速摘要: 数据库中的绝大多数键都是简单值,每个键占用2个字节。 “queue:low”正在消耗200MB,即低优先级sidekiq队列的内容。 下一个最大的关键是“死”,占用大约14MB。
和
We just ran an analysis of your database - here is a summary of what we found in 23129 keys: 18448 strings with 1048468 bytes (79.76% of keys, avg size 56.83) 6 lists with 41642 items (00.03% of keys, avg size 6940.33) 4660 sets with 3325721 members (20.15% of keys, avg size 713.67) 8 hashs with 58 fields (00.03% of keys, avg size 7.25) 7 zsets with 1459 members (00.03% of keys, avg size 208.43) It appears that you have quite a lot of memory occupied by sets. For example - each of these sets have more than 10,000 members and occupies nearly 300KB: b-3819647d4385b54b-jids b-3b68a011a2bc55bf-jids b-5eaa0cd3a4e13d99-jids b-78604305f73e44ba-jids b-e823c15161b02bde-jids These look like Sidekiq Pro "batches". It seems like some of your batches are getting filled up with very large numbers of jobs, which is causing the additional memory usage that we've been seeing. Let me know if that sounds like it might be the issue.
答案 0 :(得分:3)
不要害怕打开Sidekiq问题或直接发送电子邮件至prosupport @ sidekiq.org。
Sidekiq Pro批次的默认有效期为3天。如果您将Batch的expires_in设置设置得更长,则数据将更长时间位于Redis中。与工作不同,批次一旦完成就不会从Redis中消失。它们需要随着时间的推移而过期。这意味着您需要Redis中足够的内存来保存N天的批次,对大多数人来说通常不是问题,但是如果您有繁忙的Sidekiq安装并且正在创建大量批次,您可能会注意到内存使用量增加。