内存使用量随着Ruby 2.1与Ruby 2.0或1.9的增加而增加 [英] Memory usage increase with Ruby 2.1 versus Ruby 2.0 or 1.9

查看:203
本文介绍了内存使用量随着Ruby 2.1与Ruby 2.0或1.9的增加而增加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近部署了一个从2.0升级到2.1.5的Ruby到我的Heroku网络应用程序,现在我一直在处理内存配额错误,而2.0和1.9这种情况从未发生过。正常的Heroku Dyno有512MB的限制,我在Unicorn上运行了2个进程,并且在两个dynos上运行了一个带有Sidekiq的线程。

阅读 Phusion Passenger内存消耗在Ubuntu上从1.9.3(系统)增加到2.1.2(RVM),我试着将环境变量 RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR 设置为0.9来禁用世代垃圾收藏家,它确实提高了内存消耗量,但仍然远远不及2.0或1.9的消耗。现在内存是我最关心的问题,我想看看是否可以用ruby 2.1.x来解决这个问题,而不是回复到2.0。



以下是一些图证明了这个问题:

在下午2点之前,我将Ruby 2.0.0-p598降级到了Ruby 2.1.5,并且内存问题得到了解决,限制。






然后,我尝试升级到Ruby 2.1.5,但将环境变量 RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR 设置为0.9。正如你所看到的,内存使用情况比原来的2.1.5图略好一些,但仍然违反了内存配额。 b
$ b


解决方案

所以答案显然是升级到Ruby 2.2版本。



看到内存使用量在升级到2.2之后实际上已经下降了,而升级到2.1则是内存消耗的巨大增加。见下图。





在负载最低的情况下,2.0的内存消耗约为386mb,而2.2的消耗现在约为365mb。


I recently deployed an upgrade of Ruby from 2.0 to 2.1.5 to my Heroku web application, and I am consistently hitting memory quota errors now, whereas with 2.0 and 1.9 this never happened. There is a limit of 512MB for a normal Heroku Dyno, and I am running 2 processes with Unicorn, along with one thread with Sidekiq across two dynos.

After reading Phusion Passenger memory consumption increase from 1.9.3 (system) to 2.1.2 (RVM) on Ubuntu, I tried setting the environment variable RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR to 0.9 to disable generational garbage collector, and it did improve memory consumption somewhat, but still left me nowhere near what 2.0 or 1.9 consumed. As memory right now is my primary concern, I would like to see if I can fix this problem with ruby 2.1.x instead of reverting to 2.0.

Here are some graphs demonstrating the problem:

At just before 2pm, I downgraded to Ruby 2.0.0-p598 to Ruby 2.1.5 and the memory issues were resolved and remained under the limit.

Then later, I tried upgrading to Ruby 2.1.5 but setting the environment variable RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR to 0.9. As you can see, the memory usage is slightly better than the original 2.1.5 graph, but still breaches the memory quota.

解决方案

So the answer is clearly upgrade to Ruby version 2.2.

I am impressed to see that memory usage has actually gone down following the upgrade to 2.2, whereas upgrading to 2.1 was a huge increase in memory consumption. See the graph below.

On the far left memory consumption on 2.0 sits at around 386mb when under load, whereas with 2.2 it now sits at around 365mb.

这篇关于内存使用量随着Ruby 2.1与Ruby 2.0或1.9的增加而增加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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