2

I wrote a small Rails 5 API-only application that I am hosting on Heroku. All the application has to do is to retrieve some Data from a DB (currently less than 5K records) and output it as JSON. After deploying the application and running a couple of test queries from the browser (with different parameters to filter the result), I noticed the following on Heroku:

enter image description here

The gem that handles the JSON conversion is

gem 'jsonapi-utils', '~> 0.6.0.beta'

but I've also tried it without, and as far as the RAM consumption goes it makes no difference at all.

Besides that everything in my application is the default from generating a Rails 5 API-only application. The Puma config looks like this:

threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
threads threads_count, threads_count
port        ENV.fetch("PORT") { 3000 }
environment ENV.fetch("RAILS_ENV") { "development" }
workers ENV.fetch("WEB_CONCURRENCY") { 2 }
preload_app!
on_worker_boot do
  ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
end
plugin :tmp_restart

which is the one recommended by Heroku here: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server

As you can see from the releases, the idle application consumes very little RAM. How can it be that a couple of requests (< 20) can increase the RAM usage that heavily, and what can I do about that?

P.S. I am using Rails 5.0.2 and Ruby 2.4.1

Severin
  • 8,508
  • 14
  • 68
  • 117
  • Possible duplicate of [How to debug an ajax request raising "Error R15 (Memory quota vastly exceeded)"](http://stackoverflow.com/questions/42785631/how-to-debug-an-ajax-request-raising-error-r15-memory-quota-vastly-exceeded) – Max Woolf Apr 28 '17 at 15:27
  • Just out of curiosity, what's the behavior when you have only one worker? Does it stabilize or does it also grow until you get R14? – Gaston Apr 29 '17 at 02:32

0 Answers0