Heroku R14错误&亚马逊S3& RefineryCMS

时间:2016-07-08 16:03:27

标签: ruby-on-rails heroku amazon-s3 refinerycms

我目前正在使用与Amazon S3帐户集成的Heroku(免费版)上设置的RefineryCMS来存储和提供图像。

我继续在Ruby(MRI)中获得超过R14内存配额。它只发生在我有Rails代码服务我的文件的页面上(例如https://scape-cms.herokuapp.com/projects)。我通过Refinery CMS(例如https://scape-cms.herokuapp.com/contact-page)直接插入图像的其他页面也没问题。

以下是我从Heroku获得的重复错误日志:

2016-07-08T15:56:50.216836+00:00 heroku[web.1]: source=web.1 dyno=heroku.52592468.db487335-3609-4b63-b664-46863302a117 sample#load_avg_1m=0.00 sample#load_avg_5m=0.00 sample#load_avg_15m=0.02
2016-07-08T15:56:50.217679+00:00 heroku[web.1]: Error R14 (Memory quota exceeded)
2016-07-08T15:56:50.216975+00:00 heroku[web.1]: source=web.1 dyno=heroku.52592468.db487335-3609-4b63-b664-46863302a117 sample#memory_total=531.41MB sample#memory_rss=429.12MB sample#memory_cache=0.00MB sample#memory_swap=102.28MB sample#memory_pgpgin=496494pages sample#memory_pgpgout=386638pages sample#memory_quota=512.00MB
2016-07-08T15:56:50.217679+00:00 heroku[web.1]: Process running mem=531M(103.8%)
2016-07-08T15:57:11.876186+00:00 heroku[web.1]: source=web.1 dyno=heroku.52592468.db487335-3609-4b63-b664-46863302a117 sample#load_avg_1m=0.00 sample#load_avg_5m=0.00 sample#load_avg_15m=0.02
2016-07-08T15:57:11.876186+00:00 heroku[web.1]: source=web.1 dyno=heroku.52592468.db487335-3609-4b63-b664-46863302a117 sample#memory_total=531.59MB sample#memory_rss=429.31MB sample#memory_cache=0.00MB sample#memory_swap=102.28MB sample#memory_pgpgin=496542pages sample#memory_pgpgout=386638pages sample#memory_quota=512.00MB
2016-07-08T15:57:11.878013+00:00 heroku[web.1]: Process running mem=531M(103.8%)
2016-07-08T15:57:11.878528+00:00 heroku[web.1]: Error R14 (Memory quota exceeded)
2016-07-08T15:57:31.826483+00:00 heroku[web.1]: source=web.1 dyno=heroku.52592468.db487335-3609-4b63-b664-46863302a117 sample#load_avg_1m=0.00 sample#load_avg_5m=0.00 sample#load_avg_15m=0.02
2016-07-08T15:57:31.826483+00:00 heroku[web.1]: source=web.1 dyno=heroku.52592468.db487335-3609-4b63-b664-46863302a117 sample#memory_total=531.59MB sample#memory_rss=429.31MB sample#memory_cache=0.00MB sample#memory_swap=102.28MB sample#memory_pgpgin=496952pages sample#memory_pgpgout=387048pages sample#memory_quota=512.00MB
2016-07-08T15:57:31.827268+00:00 heroku[web.1]: Error R14 (Memory quota exceeded)
2016-07-08T15:57:53.071612+00:00 heroku[web.1]: source=web.1 dyno=heroku.52592468.db487335-3609-4b63-b664-46863302a117 sample#memory_total=531.77MB sample#memory_rss=427.56MB sample#memory_cache=0.00MB sample#memory_swap=104.21MB sample#memory_pgpgin=497018pages sample#memory_pgpgout=387562pages sample#memory_quota=512.00MB
2016-07-08T15:57:53.071535+00:00 heroku[web.1]: source=web.1 dyno=heroku.52592468.db487335-3609-4b63-b664-46863302a117 sample#load_avg_1m=0.00 sample#load_avg_5m=0.00 sample#load_avg_15m=0.02
2016-07-08T15:57:53.072554+00:00 heroku[web.1]: Process running mem=531M(103.9%)
2016-07-08T15:57:53.072554+00:00 heroku[web.1]: Error R14 (Memory quota exceeded)

我的源代码可以在这里找到: github.com/lltheis/scape-cms。

我不知道从哪里开始 - 在概念上似乎我应该能够提供存储在我的S3上的图像,因为它们是164KB到500KB - 所以它们应该在极限之下。但在某些地方,我的流程达到了512MB的限制。

谢谢!

1 个答案:

答案 0 :(得分:2)

问题可能是多方面的:

  1. 使用imagemagick,Dragonfly可以消耗大量内存: http://astrails.com/blog/2014/7/28/dragonfly-imagemagick-and-memory-bloat
  2. 可以通过添加以下内容来解决:

    # config/initializers/dragonfly.rb
    Dragonfly.app.configure do
      plugin :imagemagick, identify_command: "identify -limit memory 0 -limit map 0"
    end
    
    1. 这可能是缓存策略的问题,您在生产中使用了什么?
    2. 目前Heroku应用程序上使用的工作人员数量可能存在问题: https://devcenter.heroku.com/articles/ruby-memory-use
    3. 我希望这可以提供帮助,很难找到R14错误的问题。