cURL sometimes is slow
cURL is slow:
curl_exec() extensions/BugtrackerStatus/ForgeIssue.php:44 loadJsonFromRedmineApi() extensions/BugtrackerStatus/BugtrackerItem.php:77 getRenderedResult() extensions/BugtrackerStatus/BugtrackerStatus_body.php:47 renderForgeIssue() unknown:0
This slowness happened 130 times in 7 days.
The code runs a small request on the API of forge.typo3.org.
curl_exec() is using the cURL binary from UNIX, which should be fast, even faster than a webbrowser as it e.g. does not load images and such.
Most likely it is the network, which makes it respond slowly.
#1 Updated by Chris topher almost 3 years ago
- Try to set
curl_setopt($ch, CURLOPT_ENCODING, '');to enable gzip compression?
- Maybe also
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );helps?
- Another idea might be reusing the same cURL handle.
$ch = curl_init( $json_url );with
curl_setopt($ch, CURLOPT_URL, $url);.
Then before that point have exactly one and not multiple
$ch = curl_init();. See http://stackoverflow.com/questions/3787002/reusing-the-same-curl-handle-big-performance-increase#answer-18047230 for an example.
Reusing the cURL handle keeps the connection to the server open. This only works if the server is the same between requests, as it is in our case.
- Yet another option would be using forger instead of the Redmine API. It is basically mirroring the information from Redmine. E.g. https://forger.typo3.org/api/issue/25470 for https://forge.typo3.org/issues/25470.json.
Differences compared to the Redmine API result are: If using forger, the content will be inside of the key "issue". Special chars, which had to be decoded manually until now (
$this-\u003EunzipPath), will then be decoded already (