Implement connection queueing to avoid nodejs connection limits
See original GitHub issueI sometimes get this error after doing some requests:
{ [Error: getaddrinfo ENOTFOUND www.googleapis.com www.googleapis.com:443]
code: 'ENOTFOUND',
errno: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'www.googleapis.com',
host: 'www.googleapis.com',
port: 443 }
Here is the last request I’m recording:
{ url: 'https://www.googleapis.com/youtube/v3/channels',
method: 'GET',
json: true,
qs: { part: 'id, contentDetails', id: 'UChu4DxadETMAMlgwBREcNvQ' },
useQuerystring: true,
headers: { Authorization: 'Bearer mytoken' } }
Issue Analytics
- State:
- Created 8 years ago
- Reactions:15
- Comments:24 (10 by maintainers)
Top Results From Across the Web
How To Avoid Bottlenecks in Node.js Applications
In this article, we looked at how connection pools may become bottlenecks in your Node.js application. Knowing what a connection pool is and...
Read more >Understanding and implementing rate limiting in Node.js
As requests get queued up, they are processed at a relatively constant rate. This means that even when the server is hit with...
Read more >Effect of connection pooling on node.js performance
The benefit of connection pooling is only when we run multiple requests together. So now, lets execute in series of 5 queries as...
Read more >Why is node.js only processing six requests at a time?
There are no TCP connection limits imposed by Node itself. (The whole point is that it's highly concurrent and can handle thousands of ......
Read more >Don't Block the Event Loop (or the Worker Pool) - Node.js
Because Node.js handles many clients with few threads, if a thread blocks handling one client's request, then pending client requests may not get...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Greetings folks! I’d love to do something here, but with hundreds of API endpoints, it’s hard to come up with a unified queuing strategy that’s going to work for everyone. There’s no magic concurrency that’s going to be right for anyone, and changing the current behavior would be a breaking change for many.
Instead - I am going to recommend that y’all take a look at
p-queue
: https://github.com/sindresorhus/p-queueWe use this internally for a lot of our modules, and we’ve been really happy with it. Using this with
googleapis
should be pretty easy 😃Let us know what you think!
getaddrinfo ENOTFOUND
sounds like a connectivity, or that it’s intermittently failing to resolve the dns. I’ll have to give your code a try.