Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory usage growth #208

Closed
kuinak opened this issue Jul 25, 2018 · 8 comments
Closed

Memory usage growth #208

kuinak opened this issue Jul 25, 2018 · 8 comments
Assignees

Comments

@kuinak
Copy link

kuinak commented Jul 25, 2018

We noticed memory utilization growing on some of our lesser used apps running on Heroku. I looked at our logs, and the only entries I saw were related to Scout. As a test, I decided to deploy 2 versions of the same app. One with Scout enabled, the other without. Memory usage grew very quickly and maxed out after a couple hours on the instance with Scout enabled. On the instance without scout, memory utilization remained stable. Both of these instances received no web traffic during that period. On instances with web traffic, we frequently see timeouts (requests exceeding 30s), presumably due to garbage collection pauses or swapping.

screen_shot_2018-07-22_at_1_16_32_pm

Is this behavior expected?

@dlanderson
Copy link
Contributor

Some more info:

  • Unicorn 5.4.0, and Scout 2.4.11
  • 1 Unicorn worker
  • The apps were completely idle during this time
  • Memory does not appear to be affected if even a single request is served
  • Gemfile.lock was sent to support address

We're attempting to reproduce the issue.

@itsderek23 itsderek23 self-assigned this Jul 26, 2018
@itsderek23
Copy link
Contributor

To test, I've started w/a bare-bones Rails 5.2.0 / Ruby 2.5.1 app, running 2 web dynos, but Scout only enabled on web.1.

I'm going to let this run for a bit and see how the memory usage compares.

@itsderek23
Copy link
Contributor

So far memory usage is flat (4 hour period):

image

@kuinak - have you applied any GC settings that override the Heroku defaults?

@kuinak
Copy link
Author

kuinak commented Jul 26, 2018

@itsderek23 I reviewed the configuration and didn't see anything different with the GC options (e.g. MALLOC_ARENA_MAX).

However, I did notice that we didn't have any SCOUT_* vars set. I added the free version of the Scout addon to the app and noticed that the following log entry stopped appearing:

2018-07-26T23:16:47.307974+00:00 app[web.1]: [Scout] [07/26/18 23:16:47 +0000 web.1 (23)] INFO : [23:14] Delivering 2 Metrics for 0 requests and 0 Slow Transaction Traces and 0 Job Traces, Recorded from 1 processes.

The web.1 dyno appears to be reporting in the scout dashboard.

I'm wondering if it's a case of the APM failing to report because the key wasn't set, and something being held on to in memory related to your layaway process?

@kuinak
Copy link
Author

kuinak commented Jul 27, 2018

I removed the Scout addon and turned logging up to debug. It does appear the requests are succeeding, so I'm going to retract my previous thought regarding the layaway process.

@itsderek23
Copy link
Contributor

Thanks @kuinak.

Clarifying:

One with Scout enabled, the other without.

I'm assuming scout_apm was installed in both test cases, correct? The only difference was setting SCOUT_MONITOR=true or monitor: true in the config of the app that showed the memory increase?

@kuinak
Copy link
Author

kuinak commented Jul 27, 2018

@itsderek23 That's correct. The gem is installed in both branches. The branch with memory growth has monitor: true, the branch without memory growth has monitor: false.

@cschneid
Copy link
Contributor

cschneid commented Aug 7, 2018

After some back and forth over email, I'm going to close this issue, although without a really satisfying answer of exactly what's happening.

@kuinak collected heap dumps which showed garbage being created from what looks like code reloading, but all attempts at reproduction on our end failed.

We attempted to reproduce locally with a copy of his Gemfile, but that didn't work. If there's an interaction occurring, it's likely with one of the Gems when it is fully configured, not simply present.

What we found:

  • Each garbage collection generation added 3-4mb of usage, the vast majority of which are from activerecord, activesupport and activemodel objects.
  • The chart levels off near heroku's memory limit, indicating that its identifiable garbage, and not a true leak.
  • The heap dump isn't showing any scout agent objects in the GC'd generations.

@cschneid cschneid closed this as completed Aug 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants