Will Taylor
Will Taylor

Reputation: 2304

Heroku Memory Quota Exceeded

I'm running a Heroku app that gets 10 - 20 hits per day, and probably 2 - 3 simultaneous users max.

New Relic (server monitoring software) has started giving me the following emails recently, a couple of hundred times per day:

"Memory quota exceeded: Heroku/yourapp"

In context:
2015-04-13 13:14:09.645 155 <190>1 2015-04-13T13:14:08.997129+00:00 app web.1 - - Completed 200 OK in 11ms (Views: 8.4ms | ActiveRecord: 1.8ms)
2015-04-13 13:14:09.645 155 <190>1 2015-04-13T13:14:08.997133+00:00 app web.1 - - Completed 200 OK in 11ms (Views: 8.4ms | ActiveRecord: 1.8ms)
2015-04-13 13:14:09.721 155 <190>1 2015-04-13T13:14:08.997146+00:00 app web.1 - - Completed 200 OK in 11ms (Views: 8.4ms | ActiveRecord: 1.8ms)
2015-04-13 13:14:13.836 128 <45>1 2015-04-13T13:14:13.677706+00:00 heroku web.1 - - Process running mem=513M(100.4%)
2015-04-13 13:14:13.912 129 <45>1 2015-04-13T13:14:13.677878+00:00 heroku web.1 - - Error R14 (Memory quota exceeded)
2015-04-13 13:14:33.615 276 <158>1 2015-04-13T13:14:33.446005+00:00 heroku router - - at=info method=HEAD path="/" host=www.driverhunt.com request_id=3570e6f5-7a0f-464d-b50f-c71da525ea0c fwd="54.248.250.232" dyno=web.1 connect=1ms service=37ms status=200 bytes=823
2015-04-13 13:14:33.916 128 <45>1 2015-04-13T13:14:33.782614+00:00 heroku web.1 - - Process running mem=513M(100.4%)
2015-04-13 13:14:33.992 129 <45>1 2015-04-13T13:14:33.782787+00:00 heroku web.1 - - Error R14 (Memory quota exceeded)
2015-04-13 13:14:49.679 281 <158>1 2015-04-13T13:14:49.403609+00:00 heroku router - - at=info method=GET path="/jobs/49" host=www.driverhunt.com request_id=65854be8-4d50-4c20-9fff-31fcd701a301 fwd="180.76.5.28" dyno=web.1 connect=1ms service=31ms status=200 bytes=10347
2015-04-13 13:15:33.685 128 <45>1 2015-04-13T13:15:33.556253+00:00 heroku web.1 - - Process running mem=513M(100.4%)
2015-04-13 13:15:33.761 129 <45>1 2015-04-13T13:15:33.556253+00:00 heroku web.1 - - Error R14 (Memory quota exceeded)

Is this something to be worried about? Should I be scaling Heroku already - seems very early! We only have about 200 registered users.

I'm currently still serving my static assets through the app. Could this be the cause? If so, are there any suggested reading material for serving static assets in a smarter way (minimising cost above all else)?

Upvotes: 1

Views: 2102

Answers (2)

zawhtut
zawhtut

Reputation: 8541

I used the following build pack which is Nginx+Unicorn. By using Ngix as the front web server, unicorn can do it's application server jobs smoothly.

https://elements.heroku.com/buildpacks/kazw/nginx-buildpack

Upvotes: 0

rdegges
rdegges

Reputation: 33824

It's hard to tell what the reason is without seeing your code, but here are a few things to keep in mind:

  • Your application is using more than 512MB memory regardless of how many users you have -- this just means your code itself (and any dependencies) are taking up quite a bit of space.
  • If you're using rails, make sure you're only running on thread if possible -- each rails instance takes up quite a bit of memory, so if you are running many instances on a single dyno this is the likely culprit.
  • If you're doing any sort of large memory intensive stuff (processing PDFs, uploading files larger than a few MB, etc.) -- you might want to consider refactoring your approach -- doing this stuff on a dyno is NOT optimal.
  • If you're leaking memory, your new relic graphs will show a rise in application memory over time. Look out for this -- you might have a leak somewhere!

Upvotes: 2

Related Questions