{"action":"created","issue":{"url":"https://api.github.com/repos/aws/aws-sdk-js/issues/1231","repository_url":"https://api.github.com/repos/aws/aws-sdk-js","labels_url":"https://api.github.com/repos/aws/aws-sdk-js/issues/1231/labels{/name}","comments_url":"https://api.github.com/repos/aws/aws-sdk-js/issues/1231/comments","events_url":"https://api.github.com/repos/aws/aws-sdk-js/issues/1231/events","html_url":"https://github.com/aws/aws-sdk-js/issues/1231","id":190040689,"number":1231,"title":"Severe SQS memory leak when sslEnabled is true","user":{"login":"AndrewBarba","id":1316152,"avatar_url":"https://avatars.githubusercontent.com/u/1316152?v=3","gravatar_id":"","url":"https://api.github.com/users/AndrewBarba","html_url":"https://github.com/AndrewBarba","followers_url":"https://api.github.com/users/AndrewBarba/followers","following_url":"https://api.github.com/users/AndrewBarba/following{/other_user}","gists_url":"https://api.github.com/users/AndrewBarba/gists{/gist_id}","starred_url":"https://api.github.com/users/AndrewBarba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndrewBarba/subscriptions","organizations_url":"https://api.github.com/users/AndrewBarba/orgs","repos_url":"https://api.github.com/users/AndrewBarba/repos","events_url":"https://api.github.com/users/AndrewBarba/events{/privacy}","received_events_url":"https://api.github.com/users/AndrewBarba/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-17T13:00:30Z","updated_at":"2016-11-17T18:35:56Z","closed_at":null,"body":"When using a basic `AWS.config` with `sslEnabled: true` we saw severe memory leaks from our polling node and web nodes (which write to SQS). Config:\r\n\r\n```\r\nAWS.config = new AWS.Config({\r\n  accessKeyId: config.amazon.key,\r\n  secretAccessKey: config.amazon.secret,\r\n  region: 'us-east-1',\r\n  sslEnabled: true\r\n});\r\n```\r\n\r\nScreen shot of polling node (SSL disabled around 10:15pm):\r\n\r\n<img width=\"1223\" alt=\"screen shot 2016-11-17 at 7 53 57 am\" src=\"https://cloud.githubusercontent.com/assets/1316152/20390192/aa1bead8-ac9b-11e6-93bb-d8a4a0c275a3.png\">\r\n\r\nScreenshot of web node (SSL disabled around 10:15pm):\r\n\r\n<img width=\"1227\" alt=\"screen shot 2016-11-17 at 7 54 39 am\" src=\"https://cloud.githubusercontent.com/assets/1316152/20390196/b2d2c8f4-ac9b-11e6-90fe-0867ace36aaa.png\">\r\n\r\nFinal config that I deployed which finally stopped the leaks:\r\n\r\n```\r\nAWS.config = new AWS.Config({\r\n  accessKeyId: config.amazon.key,\r\n  secretAccessKey: config.amazon.secret,\r\n  region: 'us-east-1',\r\n  sslEnabled: false,\r\n  httpOptions: {\r\n    agent: new http.Agent({\r\n      keepAlive: true\r\n    })\r\n  }\r\n});\r\n```\r\n\r\nRelevant Versions:\r\n\r\nNode.js v6.9.1 LTS\r\nAws-sdk v2.7.2\r\nHeroku Cedar Stack - Ubuntu 14.04, 512mb RAM\r\nStart command - `node --max_old_space_size=$WEB_MEMORY server-cluster.js`\r\nNode cluster - yes\r\n"},"comment":{"url":"https://api.github.com/repos/aws/aws-sdk-js/issues/comments/261329959","html_url":"https://github.com/aws/aws-sdk-js/issues/1231#issuecomment-261329959","issue_url":"https://api.github.com/repos/aws/aws-sdk-js/issues/1231","id":261329959,"user":{"login":"chrisradek","id":14189820,"avatar_url":"https://avatars.githubusercontent.com/u/14189820?v=3","gravatar_id":"","url":"https://api.github.com/users/chrisradek","html_url":"https://github.com/chrisradek","followers_url":"https://api.github.com/users/chrisradek/followers","following_url":"https://api.github.com/users/chrisradek/following{/other_user}","gists_url":"https://api.github.com/users/chrisradek/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisradek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisradek/subscriptions","organizations_url":"https://api.github.com/users/chrisradek/orgs","repos_url":"https://api.github.com/users/chrisradek/repos","events_url":"https://api.github.com/users/chrisradek/events{/privacy}","received_events_url":"https://api.github.com/users/chrisradek/received_events","type":"User","site_admin":false},"created_at":"2016-11-17T18:35:56Z","updated_at":"2016-11-17T18:35:56Z","body":"@AndrewBarba \r\nIs the script you ran in the test something you can share, or can you provide a simplified form of it so I can reproduce on my end?\r\n\r\nDid you try setting `keepAlive` while also keeping `sslEnabled: true`?\r\n\r\nOften times when we see reports of memory leaks, it's due to a huge number of requests being sent in a loop, faster than the connection pool can assign a socket to a request. The queue of requests can then fill up, taking up space in memory. The SDK by default will set `maxSockets` to `50` for https hosts if the global configuration is `Infinity` or undefined, which is the case by default in node v0.12 and higher. If you supply your own `https.Agent`, similar to what you're doing above, you can override `maxSockets`. Can you change the `maxSockets` value to something larger and see if the observed leak diminishes?"}}
{"actor":{"display_login":"chrisradek"}}