I have a website in shared hosting with the Entry Processes limit of 30. I fetch data periodically from another URL using cURL function on a PHP cron job. The relevant code is as below.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
Most of the time my website runs pretty well with only around 4-5 entry processes being used. Whenever this target $url is doesn't response for some reason (and it happens frequently). I quickly get into Entry Process limit and all further requests are denied.
The CURLOPT_CONNECTTIMEOUT doesn't seem to be working as expected. How can I avoid this situation ? I have checked other cURL options but none seem to be working.