oyed
oyed

Reputation: 570

NodeJS HTTP Agent?

I'm developing a NodeJS Application that will send a lot of requests to a RESTful API (For TwitchTV). I have permission from TwitchTV to make the mass of requests, but I was wondering if I could implement anything to decrease the stress on my server.

I've yet to perform tests, but I can have anything up to 200 Users at a time who would I would need to request data from TwitchTV's RESTful API every 2-3 seconds per user. I've looked in to the HTTP Agent and keep-alive for NodeJS but I can't find any applications of it under my circumstances. I'll only ever be requesting data from a single host (https://api.twitch.tv), and with 200 concurrent users that would be 200 HTTPS requests every 2-3 seconds.

Is there anything I can do to reduce stress for both my server and the TwitchTV API? Caching isn't really an option due to requiring the new data.

Upvotes: 0

Views: 2646

Answers (1)

clay
clay

Reputation: 6017

If you need fresh data every 2-3 seconds, and the only API available to you is a single call, then you will need to make a lot of calls. Not a great way around that. Some thoughts are below.

Other ideas to reduce load on HTTP:

  • Request data less often. Is 2-3 seconds what you really need or think you'll need? Perhaps the data does not really change that often.
  • Request data for more than one user. If the API supported some sort of batch information that you sorted/filtered in your app, that would reduce load on the HTTP service.
  • Request a different way. Is there a different API call that would give the same results?
  • Limit your server. Create a queueing system for your user's requests and do not exceed some limit. Might be necessary if a call limit (or charge limit) is imposed on your app that you do not wish to exceed.

Upvotes: 1

Related Questions