-
Notifications
You must be signed in to change notification settings - Fork 591
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
Possible Memory Leak with gRPC #1356
Comments
Thanks for reporting! We had a report a while back suspecting gRPC of a leak as well (#1164). We made some corrections in how we were caching connections. (If you're interested, here's a nice explanation of the lifecycle of a gRPC call: #1164 (comment)) I opened an issue on gRPC about it (grpc/grpc#5970), but the maintainer wasn't able to reproduce, so we called it case closed. Is it possible to get some sample code together to reproduce? And just to make sure, are you using a version of gcloud-node >= 0.30.0? |
yep, I'm using version 0.34.0. I'm having hard time to replicate the memory leak by performing immediate operations as it seems to increase over time instead. I'll try to put something together today and come back to you. |
Hi @adamkundrat and @stephenplusplus I have also seen this problem running nodejs 4.2.4 LTS and gcloud ^0.32.0 when running a lot of topic.publish Please let me know how I can help! |
I put together a repo that might be a framework which we can test this: https://github.com/stephenplusplus/gissue-1356 -- feel free to modify anything to get it to reproduce, even if it takes leaving it running for 9 hours. 🕘 |
sorry @stephenplusplus I didn't see your post early enough and went straight into coding. I just put this attached example together trying to replicate similar way we are using it. You can see over time the memory usage is growing. I did this in last hour I hope I didn't introduce another memory leak... I tried not to use any external libraries to isolate this. I hope async (eachLimit) is not responsible for any memory usage. I'll work to remove the "async" just to make sure but I hope it's a good start. https://gist.github.com/adamkundrat/6c994b9086404e807592e2e679ae1428 BTW - I've slower connection where are I'm so it does not publish large number of items. Although if you're on the fast network it could be a different story:) |
Here is a gist without using async - eachLimit: https://gist.github.com/adamkundrat/1dc2631e260a2f380d187fb9a0ce1825 I ran it for few minutes and you can see memory usage is growing: Based on the monitoring I'm submitting around 8 items per second per queue (script is creating 40 queues). Thank you for any help guys. Highly appreciated. |
I've adapted your test to one that can switch between using gRPC-only and gcloud-node: https://github.com/stephenplusplus/gissue-1356/blob/master/test-2.js I noticed you're bypassing errors that To fairly compare between gRPC and gcloud-node isn't easily done right now, because of some bugs I caught while investigating (#1357). It requires going into the gcloud-node code... # node_modules/gcloud-node/lib/common/grpc-service.js#260
- maxRetries: this.maxRetries
+ retries: this.maxRetries However, once you do that, the memory usage is pretty similar between both. Here's the output when using gcloud-node: $ export USE_GCLOUD=1 && node ./test-2.js
Using gcloud-node...
Date: Fri Jun 03 2016 14:41:13 GMT-0400 (EDT), Memory: 47.36Mb
gRPC service created
Topics found or created
Date: Fri Jun 03 2016 14:41:23 GMT-0400 (EDT), Memory: 299.19Mb
Date: Fri Jun 03 2016 14:41:33 GMT-0400 (EDT), Memory: 311.04Mb
Date: Fri Jun 03 2016 14:41:43 GMT-0400 (EDT), Memory: 318.4Mb
Messages published
Date: Fri Jun 03 2016 14:41:51 GMT-0400 (EDT), Memory: 318.5Mb
Done!
Date: Fri Jun 03 2016 14:41:53 GMT-0400 (EDT), Memory: 318.51Mb gRPC alone looked like this: $ export USE_GCLOUD= && node ./test-2.js
Date: Fri Jun 03 2016 14:42:15 GMT-0400 (EDT), Memory: 52.92Mb
gRPC service created
Topics found or created
Date: Fri Jun 03 2016 14:42:25 GMT-0400 (EDT), Memory: 242.35Mb
Date: Fri Jun 03 2016 14:42:35 GMT-0400 (EDT), Memory: 253.85Mb
Date: Fri Jun 03 2016 14:42:45 GMT-0400 (EDT), Memory: 261.26Mb
Messages published
Date: Fri Jun 03 2016 14:42:51 GMT-0400 (EDT), Memory: 277.63Mb
Done!
Date: Fri Jun 03 2016 14:42:55 GMT-0400 (EDT), Memory: 277.64Mb So, if you need to just have a constant throughput, without handling the QPS limit being reached, you would want to set the If possible within the requirements of your application, a better solution might involve throttling the rate of publishing. You can limit the QPS by batching multiple messages together per @adamkundrat and @dennismartensson: does this research sound relevant to your experiences, or did I miss any nuances? I'll let you know as soon as we release the fix for // cc @tmatsuo since we're talking Pub/Sub. |
Hi, I think that could make sense. I have just made some changes and are deploying them to some of our servers so we can see if those machines gets the same problem when only postings ones a second on two topics. Instead of around 10 times per second per topic. |
Thanks @stephenplusplus |
@adamkundrat did you see any improvements? |
sry for the delayed response. I was away for the best part of the week. Your suggestion actually helps and the memory consumption is much better now. Thanks heaps! |
No problem, and that's great! |
#618) * build(node): add feat in node post-processor to add client library version number in snippet metadata Co-authored-by: Benjamin E. Coe <bencoe@google.com> Source-Link: googleapis/synthtool@d337b88 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:d106724ad2a96daa1b8d88de101ba50bdb30b8df62ffa0aa2b451d93b4556641
#618) * build(node): add feat in node post-processor to add client library version number in snippet metadata Co-authored-by: Benjamin E. Coe <bencoe@google.com> Source-Link: googleapis/synthtool@d337b88 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:d106724ad2a96daa1b8d88de101ba50bdb30b8df62ffa0aa2b451d93b4556641
#618) * build(node): add feat in node post-processor to add client library version number in snippet metadata Co-authored-by: Benjamin E. Coe <bencoe@google.com> Source-Link: googleapis/synthtool@d337b88 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:d106724ad2a96daa1b8d88de101ba50bdb30b8df62ffa0aa2b451d93b4556641
#78) * build(node): add feat in node post-processor to add client library version number in snippet metadata Co-authored-by: Benjamin E. Coe <bencoe@google.com> Source-Link: googleapis/synthtool@d337b88 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:d106724ad2a96daa1b8d88de101ba50bdb30b8df62ffa0aa2b451d93b4556641 Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Benjamin E. Coe <bencoe@google.com>
#141) * build(node): add feat in node post-processor to add client library version number in snippet metadata Co-authored-by: Benjamin E. Coe <bencoe@google.com> Source-Link: googleapis/synthtool@d337b88 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:d106724ad2a96daa1b8d88de101ba50bdb30b8df62ffa0aa2b451d93b4556641
#78) * build(node): add feat in node post-processor to add client library version number in snippet metadata Co-authored-by: Benjamin E. Coe <bencoe@google.com> Source-Link: googleapis/synthtool@d337b88 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:d106724ad2a96daa1b8d88de101ba50bdb30b8df62ffa0aa2b451d93b4556641 Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Benjamin E. Coe <bencoe@google.com>
#141) * build(node): add feat in node post-processor to add client library version number in snippet metadata Co-authored-by: Benjamin E. Coe <bencoe@google.com> Source-Link: googleapis/synthtool@d337b88 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:d106724ad2a96daa1b8d88de101ba50bdb30b8df62ffa0aa2b451d93b4556641
#561) * build(node): add feat in node post-processor to add client library version number in snippet metadata Co-authored-by: Benjamin E. Coe <bencoe@google.com> Source-Link: googleapis/synthtool@d337b88 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:d106724ad2a96daa1b8d88de101ba50bdb30b8df62ffa0aa2b451d93b4556641
#522) * build(node): add feat in node post-processor to add client library version number in snippet metadata Co-authored-by: Benjamin E. Coe <bencoe@google.com> Source-Link: googleapis/synthtool@d337b88 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:d106724ad2a96daa1b8d88de101ba50bdb30b8df62ffa0aa2b451d93b4556641
#703) * build(node): add feat in node post-processor to add client library version number in snippet metadata Co-authored-by: Benjamin E. Coe <bencoe@google.com> Source-Link: googleapis/synthtool@d337b88 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:d106724ad2a96daa1b8d88de101ba50bdb30b8df62ffa0aa2b451d93b4556641
#126) * build(node): add feat in node post-processor to add client library version number in snippet metadata Co-authored-by: Benjamin E. Coe <bencoe@google.com> Source-Link: googleapis/synthtool@d337b88 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:d106724ad2a96daa1b8d88de101ba50bdb30b8df62ffa0aa2b451d93b4556641 Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Benjamin E. Coe <bencoe@google.com>
#41) * build(node): add feat in node post-processor to add client library version number in snippet metadata Co-authored-by: Benjamin E. Coe <bencoe@google.com> Source-Link: googleapis/synthtool@d337b88 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:d106724ad2a96daa1b8d88de101ba50bdb30b8df62ffa0aa2b451d93b4556641
#128) * build(node): add feat in node post-processor to add client library version number in snippet metadata Co-authored-by: Benjamin E. Coe <bencoe@google.com> Source-Link: googleapis/synthtool@d337b88 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:d106724ad2a96daa1b8d88de101ba50bdb30b8df62ffa0aa2b451d93b4556641 Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Benjamin E. Coe <bencoe@google.com>
#365) * build(node): add feat in node post-processor to add client library version number in snippet metadata Co-authored-by: Benjamin E. Coe <bencoe@google.com> Source-Link: googleapis/synthtool@d337b88 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:d106724ad2a96daa1b8d88de101ba50bdb30b8df62ffa0aa2b451d93b4556641
#172) * build(node): add feat in node post-processor to add client library version number in snippet metadata Co-authored-by: Benjamin E. Coe <bencoe@google.com> Source-Link: googleapis/synthtool@d337b88 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:d106724ad2a96daa1b8d88de101ba50bdb30b8df62ffa0aa2b451d93b4556641
#174) * build(node): add feat in node post-processor to add client library version number in snippet metadata Co-authored-by: Benjamin E. Coe <bencoe@google.com> Source-Link: googleapis/synthtool@d337b88 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:d106724ad2a96daa1b8d88de101ba50bdb30b8df62ffa0aa2b451d93b4556641
#716) * build(node): add feat in node post-processor to add client library version number in snippet metadata Co-authored-by: Benjamin E. Coe <bencoe@google.com> Source-Link: googleapis/synthtool@d337b88 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:d106724ad2a96daa1b8d88de101ba50bdb30b8df62ffa0aa2b451d93b4556641
#481) * build(node): add feat in node post-processor to add client library version number in snippet metadata Co-authored-by: Benjamin E. Coe <bencoe@google.com> Source-Link: googleapis/synthtool@d337b88 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:d106724ad2a96daa1b8d88de101ba50bdb30b8df62ffa0aa2b451d93b4556641
#356) * build(node): add feat in node post-processor to add client library version number in snippet metadata Co-authored-by: Benjamin E. Coe <bencoe@google.com> Source-Link: googleapis/synthtool@d337b88 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:d106724ad2a96daa1b8d88de101ba50bdb30b8df62ffa0aa2b451d93b4556641
#703) * build(node): add feat in node post-processor to add client library version number in snippet metadata Co-authored-by: Benjamin E. Coe <bencoe@google.com> Source-Link: googleapis/synthtool@d337b88 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:d106724ad2a96daa1b8d88de101ba50bdb30b8df62ffa0aa2b451d93b4556641
#1006) * build(node): add feat in node post-processor to add client library version number in snippet metadata Co-authored-by: Benjamin E. Coe <bencoe@google.com> Source-Link: googleapis/synthtool@d337b88 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:d106724ad2a96daa1b8d88de101ba50bdb30b8df62ffa0aa2b451d93b4556641
#874) * build(node): add feat in node post-processor to add client library version number in snippet metadata Co-authored-by: Benjamin E. Coe <bencoe@google.com> Source-Link: googleapis/synthtool@d337b88 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:d106724ad2a96daa1b8d88de101ba50bdb30b8df62ffa0aa2b451d93b4556641
#874) * build(node): add feat in node post-processor to add client library version number in snippet metadata Co-authored-by: Benjamin E. Coe <bencoe@google.com> Source-Link: googleapis/synthtool@d337b88 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:d106724ad2a96daa1b8d88de101ba50bdb30b8df62ffa0aa2b451d93b4556641
#290) * build(node): add feat in node post-processor to add client library version number in snippet metadata Co-authored-by: Benjamin E. Coe <bencoe@google.com> Source-Link: googleapis/synthtool@d337b88 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:d106724ad2a96daa1b8d88de101ba50bdb30b8df62ffa0aa2b451d93b4556641
#606) * build(node): add feat in node post-processor to add client library version number in snippet metadata Co-authored-by: Benjamin E. Coe <bencoe@google.com> Source-Link: googleapis/synthtool@d337b88 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:d106724ad2a96daa1b8d88de101ba50bdb30b8df62ffa0aa2b451d93b4556641
Hi Guys,
I hope someone will be able to help me with this one. I spend over few days on this and I can't figure out the issue. We used RabbitMQ as our messaging queue system but now switched over to Google Pub/Sub. All the other code stayed same. We suddenly experiencing memory leak so I naturally assumed it's an issue with gcloud-node lib. See graph below:
I fully reviewed our implementation of the "gcloud-node" twice and it's following all the standard guidelines. I went down the debugging path and it seems "Rc" object is continuously growing. See attached screenshot where I'm compering Heaps snapshots 48 minutes apart:
Few notes:
The text was updated successfully, but these errors were encountered: