Reputation: 535
I am working on an API mashup in PHP of various popular APIs and would liek to implement rate limiting to ensure i am playing nice.
I did some research and have taken a look at CURLOPT_MAXCONNECTS and CURLOPT_TIMEOUT but I have some confusion about how they function.
As I understand it, likely incorrectly:
CURLOPT_MAXCONNECTS
---
Each script that calls a cUrl request opens a connection.
When the MAXCONNECTS limit is reached, then the server delays the request.
CURLOPT_TIMEOUT
---
The amount of time that the server will wait to make a connection.
Working with MAXCONNECTS, does that mean that cUrl will make the listed
number of connections and then wait up to TIMEOUT for an open thread?
So-- I am, obviously, very confused about how cUrl actually functions with these parameters. The application I am developing needs to limit cUrl requests at different limits for each API I am calling. As I understand things, the cUrl options are server wide? Is there some method of attaching a token to a specific cUrl call and applying the limit per API that way? Do I need to work some global/shared memory magic?
Your truly and considerably confused, Samantha.
Upvotes: 1
Views: 1988
Reputation: 657
CURLOPT_MAXCONNECTS is just the maximum number of simultaneous requests. CURLOPT_TIMEOUT is the time cURL will wait before abording request in the case that there is no answer.
You'll have to work you limits manually
Upvotes: 0