Skip to content
Advertisement

Fastest way to send 500 requests using JS

I need to write a function that fetches the rate limit test page 500 times with a 200 status code as fast as possible. Cloudflare will rate limit you if you make more than 10 requests within a minute to https://www.cloudflare.com/rate-limit-test.

This is my code so far:

JavaScript

Is there a better way of doing this and using setTimeOut?

Advertisement

Answer

10 requests per minute is 1 every 6 seconds

So, just wait between requests

Here is code using async/await – no error checking, that’s up to you

JavaScript

Why do you res.send the first status though?


edit: thinking about it, you want as fast as possible,

First, make the request start every 6 seconds, and remove the last delay

JavaScript

This should make 500 requests over 2994 seconds – which is as fast as you can go I believe


edit: of course, if you can make 10 requests, then wait a minute, then make 10 requests, then wait a minute … rinse and repeat … you can do it in 2940 + some seconds for the last 10 requests – that would knock another 50-54 seconds off the time it takes

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement