How to practice good ethics by doing many curl requests in php

I have done quite a bit of reading about this, and I'm not quite sure how to do it right.

I access api websites that provide the information I use on my site. On average, I will process more than 400 different API requests, which means more than 400 curl requests. What is the right way to pause my code for a while and then continue. The site does not limit the number of views, so I will not be forbidden to just pull on all things at once, but I do not want to be the server when 10,000 people like me do the same. What I'm trying to do is pause my code and politely use the service they offer.

What is the best way to pause php while consuming resources?

What is the most amiable number of requests per wait loop?

What is the most polite amount of expectation per cycle?

With all these questions, I would also like to receive information as quickly as possible, trying to stay in the above questions.

answer the central API response

Thank you in advance for your time and patience.

+4
source share
1 answer

Here's a thought: you asked? If the API cannot handle the high load, they usually include a constraint in their conditions. If not, I would recommend sending an email to the service provider, explain what you want to do, and ask what they think will be a reasonable burden. Although it is possible that their servers are quite capable of handling any load that you could reasonably give it, therefore they do not indicate.

If you want to make a service from a service provider, don't just guess what they want. Ask, and then you will know exactly how far you can go without breaking the people who built the API.

For real pause mechanics, I would use the proposed alex method (but has since been removed) PHP usleep .

+3
source

All Articles