I am collecting market prices from different exchanges, the exchanges are set up for 1000's of requests a second however I am concerned that when my website is under heavy use this cURL function will be too resource intensive on my server.
Here is the cURL function, which gets results from between 2 and 4 exchanges (depending if an exchange timeouts):
function curl($exchange,$timeout) { $a = curl_init(); curl_setopt($a, CURLOPT_TIMEOUT, $timeout); curl_setopt($a, CURLOPT_RETURNTRANSFER, 1); curl_setopt($a,CURLOPT_SSL_VERIFYPEER, false); curl_setopt($a, CURLOPT_HTTPHEADER, array('Accept: application/json', 'Content-Type: application/json')); curl_setopt($a, CURLOPT_URL, $exchange); $result = curl_exec($a); $httpCode = curl_getinfo($a, CURLINFO_HTTP_CODE); if($httpCode == 200) { return json_decode($result); } else { return false; } curl_close($a); } I am using AJAX to load the script asynchronously since it takes a few seconds to complete. It is loaded on the homepage and I am anticipating ~15,000 unique hits a day.
Will I run into issues if cURL is called upon many times a second and if so is there a better alternative?