regarding Q1: As already noted, there are several solutions to problems with this algorithm. First of all, it probably exhausts local (handles, etc.), as well as remote (maxConnections, maxThreads, etc.) resources. Do not do it this way.
regarding Q2: you do not need (see below), but please get error answers before guessing errors.
regarding Q3: yes, there are several options on the REMOTE web server depending on the provider of the remote web server (restrictions on stream numbers, maximum number of connections, maximum number of connections per client, etc.). If this is also your server, you can configure them to better meet your needs, but first you must configure the client algorithm.
In general, it makes no sense to run more than a few connections at a time. Reusing connections is much faster and does not spoil your local handles, etc. And does not do DOS attacks for remote systems. The only reason for this is because the server takes a long time to process the request than io takes.
Did you check the speed when you do this, say 4 connections at a time and reuse them instead of creating new ones? Indeed, you populate curl_handles [] for one use of each of them. Creating IO objects takes time.
source share