-
Notifications
You must be signed in to change notification settings - Fork 57
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
High memory overhead when patching aws-sdk #13
Comments
Thank you for reporting the issue and all the deep dive. We will profile the |
We're using Here's the configuration, in config/initializers/aws.rb: require 'aws-sdk'
Aws.config.update(
logger: ::Rails.logger,
region: ENV["S3_EXPORT_REGION"] || "eu-west-1",
credentials: Aws::Credentials.new(ENV["EVENT_LOG_AWS_ACCESS_ID"] || 'id', ENV["EVENT_LOG_AWS_SECRET_KEY"] || 'key')
) |
AWS Ruby SDK v3 is fully modularized and it allows you to require the gem you needed (AWS services you are using). This reduces your bundle size and client loaded in memory. It also gives you flexibility of update individual gems. https://aws.amazon.com/sdk-for-ruby/ As you can see in the patcher link, it tries to require all the possible gems and patch those clients if no explicit gems are specified. If you only require Do you mind changing |
I've changed it to only require It's hard to tell if it's better or not, it looks like a similar amount as the jump towards the end of my second graph. |
Hello,
We recently added
aws-xray-sdk
to a bunch of applications, and those where we patchaws_sdk
started using significantly more memory than usual. Here is how it's configured:I don't think this is a memory leak, but an overhead incurred when the patching is performed. Here is the memory usage of our publishing-api application, which shot up dramatically when the X-Ray configuration was deployed:
The application doesn't actually use any AWS stuff, but it depends on some AWS gems because there are a couple of rake tasks to import and export data to S3. So despite the application itself not doing any AWS stuff, the memory usage is still dramatically increased.
The reason I think this is a problem with the
aws_sdk
patching is because the same problem does not occur when onlynet_http
is patched. The same application, with onlynet_http
patched, looks like this:When the change was deployed, the memory usage plummeted. Towards the end of the graph, a branch which enabled patching of
aws-sdk
was deployed, and the memory usage goes up. This seems like too much of a coincidence for it not to be theaws-sdk
patching at fault.There's some more details, including graphs for a second application, here: alphagov/govuk_app_config#61
The text was updated successfully, but these errors were encountered: