Score:0

How do I detect why PHP requests to external servers are slow?

fr flag
ose

For the last two months, some days, my requests(get/post) to external links are working with a delay. However, this issue only occurs in my code running on a server that I use heavily. I have three servers. (Centos 7, Centos7, Windows Server) Both of have the same features. (One is the server that I use heavily and the request I send to the external link returns slowly).

While it turns very fast on Windows and 2nd centos server, it takes 5 seconds for it to turn on the heavily used Centos server. Why does this occur? I checked the ram & disk usage of the server, nothing abnormal. I turned the server off and turned it back on, still didn't fix it. This situation did not exist three days ago, when I woke up one morning, it started to be slow. As in the previous ones, I will wake up one morning and it will be fixed again.

Vesta is installed on my server, I am using Apache. Which service do I need to specifically control? The slowness is not specific to this link alone, it also loads slowly when I make a curl request elsewhere.

All servers are running in a data center located in Germany.

function tcmbKurlari(){
$url= 'https://www.tcmb.gov.tr/kurlar/today.xml';
$context = stream_context_create(array('ssl'=>array(
    'verify_peer' => false, 
    "verify_peer_name"=>false
)));
libxml_set_streams_context($context);
$currency = simplexml_load_file($url);

return $currency;
}

print_r(tcmbKurlari());
djdomi avatar
za flag
if ngix is involved why not cache it?
fr flag
ose
@djdomi The data I have taken is updated every minute. Can I cache here? I'm also experiencing this delay on servers where I sent post request.
jp flag
Use `curl` to measure request timing - https://stackoverflow.com/a/22625150/95985
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.