On the frontend I have AJAX form. In the controller that is called on submit of that form I make 2 API calls to the outside API. When I do that, the response for the first API call takes 20s.
$res = $taxamo->validateTaxNumber("AT", $vat_id);
$country_code = $taxamo->locateGivenIP($ip_address)->country_code;
$res = $taxamo->validateTaxNumber($country_code, $vat_id);
I only use events 1 and 2. I've added event "3" just to prove that it's not "locateGivenIP" fault and that only the first call to the outside API takes 20 seconds. Also Taxamo has operation logs and it says there that their server responed in 2ms. So its not their fault either. I tried to make API call to Braintree. It also takes 20 seconds.
It worked perfectly few days ago (short response time), but all of the sudden this problem appeared. I'm really wondering why. Trust when I tell you that I only made small changes to 1 controller and I'm sure that is not a cause of the problem. But then again, problems dont appear by themselves.
When I try to update data on some other AJAX form where controller doesnt make outside API calls, it is exxecuted in ~1s.
I've googled this issue but I havent found anything that could be related to my problem.
I use Cloudflare, maybe that could be a problem?? I've tried
php artisan optimize --force and no luck. Also my project is live on Vultr $20 server. Maybe it's their fault?
Funny thing that every outside API call takes 20s. Sometimes, really rarely 5s.