{"action":"created","issue":{"url":"https://api.github.com/repos/bitinn/node-fetch/issues/110","repository_url":"https://api.github.com/repos/bitinn/node-fetch","labels_url":"https://api.github.com/repos/bitinn/node-fetch/issues/110/labels{/name}","comments_url":"https://api.github.com/repos/bitinn/node-fetch/issues/110/comments","events_url":"https://api.github.com/repos/bitinn/node-fetch/issues/110/events","html_url":"https://github.com/bitinn/node-fetch/issues/110","id":151284631,"number":110,"title":"keep-alive connections and http / https agents","user":{"login":"dendril","id":29705,"avatar_url":"https://avatars.githubusercontent.com/u/29705?v=3","gravatar_id":"","url":"https://api.github.com/users/dendril","html_url":"https://github.com/dendril","followers_url":"https://api.github.com/users/dendril/followers","following_url":"https://api.github.com/users/dendril/following{/other_user}","gists_url":"https://api.github.com/users/dendril/gists{/gist_id}","starred_url":"https://api.github.com/users/dendril/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dendril/subscriptions","organizations_url":"https://api.github.com/users/dendril/orgs","repos_url":"https://api.github.com/users/dendril/repos","events_url":"https://api.github.com/users/dendril/events{/privacy}","received_events_url":"https://api.github.com/users/dendril/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-04-27T02:31:54Z","updated_at":"2016-04-29T15:35:37Z","closed_at":null,"body":"Hey!\r\n\r\nI have been dealing with some performance stuff using node-fetch, and after a lot of debugging I finally found the issue.\r\n\r\nUse case: around 10k requests to the same cdn using keep-alive.\r\n\r\n```js\r\nconst fetch = require('node-fetch');\r\nconst agent = new https.Agent({\r\n\tkeepAlive: true,\r\n\tkeepAliveMsecs: 1500,\r\n\tmaxSockets: 70\r\n});\r\n\r\nfor (let i=0; i < 10000; i++) fetch(`https://cdn.test.io/${i}`, {\r\n\theaders,\r\n\tagent,\r\n\tcompress: true\r\n});\r\n```\r\n\r\nIf you check https://github.com/bitinn/node-fetch/blob/master/index.js#L77-L79 we are explicitly saying `Connection: close`, so, each time I made a request to the server, I need to negotiate a new connection before make a request, doesn't matter if I could reuse an already established connection from the pool.\r\n\r\nWe should change the default to do nothing, because if I set keepAlive in the agent, `Connection: close` prevents the expected behavior. \r\n\r\nWhat do you think?"},"comment":{"url":"https://api.github.com/repos/bitinn/node-fetch/issues/comments/215761860","html_url":"https://github.com/bitinn/node-fetch/issues/110#issuecomment-215761860","issue_url":"https://api.github.com/repos/bitinn/node-fetch/issues/110","id":215761860,"user":{"login":"dendril","id":29705,"avatar_url":"https://avatars.githubusercontent.com/u/29705?v=3","gravatar_id":"","url":"https://api.github.com/users/dendril","html_url":"https://github.com/dendril","followers_url":"https://api.github.com/users/dendril/followers","following_url":"https://api.github.com/users/dendril/following{/other_user}","gists_url":"https://api.github.com/users/dendril/gists{/gist_id}","starred_url":"https://api.github.com/users/dendril/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dendril/subscriptions","organizations_url":"https://api.github.com/users/dendril/orgs","repos_url":"https://api.github.com/users/dendril/repos","events_url":"https://api.github.com/users/dendril/events{/privacy}","received_events_url":"https://api.github.com/users/dendril/received_events","type":"User","site_admin":false},"created_at":"2016-04-29T15:35:37Z","updated_at":"2016-04-29T15:35:37Z","body":"@bitinn ping"}}