0

Per the title, is there a maximum number of Get requests?

I need to make a couple hundred get requests to a rest API in order to dynamically load data into webpage, but I find that if I make a Promise.All array and output the promise result in the .then, eventually I get undefined due to request time outs.

Is this due to a limit on the number of connections? Is there a best practice for making large number of simultaneous requests?

Thanks for your insight!

  • https://stackoverflow.com/questions/985431/max-parallel-http-connections-in-a-browser – Amerrnath Nov 30 '17 at 05:29
  • This is outside of your control. It entirely depends on API server. They may pose limitaitons. – marekful Nov 30 '17 at 05:30
  • in a browser you'll find there's a maximum concurrent connections to any one host ... but, the browser usually queues requests up ... if you're getting `undefined` - it could be that the API your hitting has some sort of rate limit? In which case you'll need to rate limit your requests in order to not get errors – Jaromanda X Nov 30 '17 at 05:30

1 Answers1

0

A receiving server has a particular capability for how many simultaneous requests it can handle. It could be a small number or a very large number depending upon a whole bunch of things including the server configuration, the server software architecture, the types of request being sent, etc...

If you're getting timeouts from the server, then you are probably sending enough requests that the server can't process all of them before whatever request timeout is configured (on either client or server) and thus you get a timeout error.

The usual way of handling this on the client is to control how many simultaneous requests you will send at once and then when one finishes, you can send the next and so on. You will have to test to find out what the capabilities are of the receiving server and then you should back off a bit from that to allow other load from other sources some room to execute while your requests are running.

Assuming your requests are not unusually heavy-weight things to do on the server, I would typically test 5 or 10 requests at a time and see how the receiving server handles that.

There's a discussion of a lot of options for controlling this here:

Promise.all consumes all my RAM

Make several requests to an API that can only handle 20 request a minute

Concurrency control is also part of Promise.map() in the Bluebird promise library.

Is there a maximum number of Get requests?

Servers are limited on how many requests they can handle at once for a whole variety of reasons. Every server setup will likely be different and it also depends upon the types of requests you're sending too (and what they have to do). Some servers may be able to handle hundreds of thousands of requests (probably because there's a cluster behind them and they're configured for big load). Smaller configurations may only handle dozens at a time.

Is this due to a limit on the number of connections?

Any receiving server will have a limit on how many incoming connections it will allow to queue. What that is will depend upon many factors and there is no way for you (from the outside) to know exactly what that limit is. Timeout errors usually don't mean you're hitting this limit.

jfriend00
  • 683,504
  • 96
  • 985
  • 979