Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
15
Help us understand the problem. What is going on with this article?
@colorrabbit

[heroku] memory quota exceeded のエラーへの対応

More than 5 years have passed since last update.

前置き

Heroku で Rails 4.1, Ruby 2.1.3 アプリを動かしてます。
Papertrail や FlyData でログを回収していたら、やたらエラーが出ることが分かりました。

heroku/web.1: Error R14 (Memory quota exceeded)

Heroku Error Code

Heroku の Error Code 一覧から参照します。

R14
R14 - Memory quota exceeded
A dyno requires memory in excess of its quota (512 MB on 1X dynos, 1024 MB on 2X dynos) . If this error occurs, the dyno will page to swap space to continue running, which may cause degraded process performance.
====

2011-05-03T17:40:10+00:00 app[worker.1]: Working
2011-05-03T17:40:10+00:00 heroku[worker.1]: Process running mem=528MB(103.3%)
2011-05-03T17:40:11+00:00 heroku[worker.1]: Error R14 (Memory quota exceeded)
2011-05-03T17:41:52+00:00 app[worker.1]: Working
R15 - Memory quota vastly exceeded

対応

環境変数 WEB_CONCURRENCY の設定

使用中のDynoの数に合わせる。

$ heroku config:set WEB_CONCURRENCY=1 # Dynoが1の場合

Unicornの設定

webサーバーに Unicorn を使っているので、Unicorn の worker 数を下げることがひとつの解決策の様です。

config/unicorn.rb
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 2) # 2の部分

他にもrubyのバージョンを 2.0 に下げるといいなどあるようですが。。。

References

15
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
colorrabbit
creator.

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
15
Help us understand the problem. What is going on with this article?