Sean McDonald
Sean McDonald

Reputation: 43

Waiting for multiple cUrls from PHP and when is too much?

I have created a "boggle"-like game for personal programming practice/portfolio.

I found a free API where I can verify words.

My question: if 3 players each have 15-20 words and a script starts running the calls to the api (it's an unlimited use API as far as I can tell from research), then is there a "guarantee" that every call will run? How does php compare to JS's promise/asyncronous style? Is there anything to worry about with a lot of cUrls in a row? How many requests/responses can an instance of php handle at one time?

Upvotes: 0

Views: 550

Answers (1)

Theo
Theo

Reputation: 1633

PHP code runs asynchronously, if you are using standard curl_exec(), then it will only process one request at a time, and the only limit for a single script is how long the calls take, and the configured time limit.

If you are using curl_multi_exec() then you can make asynchronous requests, and there is theoretically no limit, but it is dependent on a number of other factors, such as available bandwidth etc, limits of number of network connections and/or open files on your system.

Some relevant info here:

libcurl itself has no particular limits, if you're referring to amount of 
concurrent transfer/handles or so. Your system/app may have a maximum amount 
of open file handles that'll prevent you from adding many thousands. Also, 
when going beyond a few hundred handles the regular curl_multi_perform() 
approach start to show that it isn't suitable for many transfers and you 
should rather switch to curl_multi_socket() - which I unfortunately believe 
the PHP binding has no support for. 

Upvotes: 1

Related Questions