Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

pj_bean's avatar

my laravel site takes forever to send a response back to base site url intermittently

Hi Folks,

I'm new to laravel and haven't dont any real web development in close to a decade and i'm having to quickly ramp up a site for a friend. The problem I have is the following:

Sometimes when I open the site in a new tab, try to hit it fresh, click my home button on my site navbar which redirects to "/", or even empty cache and hard reload the request to my base site takes well over 2 minutes for a response IF it even gets one. if it doesn't it cancels at the end then resends the request and the page loads practically instantaneously on the new request. If it gets there at the end of 2 minutes it finally loads it all at once. I've checked my network tab in the console and it's sitting on the waiting(TTFB) for that entire interval, the content download and request sent happen in a fraction of a millisecond. This issue is intermittent, sometimes laravel decides to be good, and sometimes it just wants to watch the world burn. I had to increase the ng-inx timeout to get this far in the diagnostics because I kept getting a 503 timeout and found some timeout configs via google to stop that.

I've checked my laravel logs and nothing shows up. I tried to search for profile tools and found something called blackfire so I even installed blackfire(upgraded it on my homestead since its already installed) hoping to track this sucker down but now the site is currently working perfectly without any hitch whatsoever.

I also have the site up on a elastic beanstalk instance, and it is now giving me the intermittent problems as well.

Are there any common mistakes that might cause this to happen or possible debugs I can turn on if the site takes longer then normal to load to dump some metrics so I can actually catch it when it happens? I was afraid it was due to having so much data in my database but since its not consistent and multiple other hits to my DB for different data using the same functions (i'm building a directory app, so I can supply different starting points to pull the same data I do on page load at any time by just supplying another location instead of my default location grabbed by my ip) work super fast and function properly, even sites with even more locations they grab in the collection, perform super fast and perfect.

Sorry not trying to ask anyone to fix my dumb code but If that kind of issue rings a bell or if theres some extended debugging for the entire site i can turn on to hunt this down that people would know if I would greatly appreciate it!

Thanks! Paul

0 likes
4 replies
jekinney's avatar

Is it doing this locally or deployed?

If locally how many CSS, scripts etc are being loaded/downloaded?

It's a guess, but I've had random issues using cdn's before and before gulping files together to many CSS and scripts as it will only do 4 at a time.

1 like
pj_bean's avatar

Hi Jekinney, thanks for the response! It happens both locally and deployed via amazon beanstalk again intermittently though. I just went through my master page and index page and I load 2 css file that are my own, 2 javascript that are my own, then pull modernizer, jquery, underscore, bootstrap, leaflet(both css and js but this is only on my index page no other page) from a cdn. the css and js that are mine are built using gulp, the first css and js files are my main style and javscript sheets for my masterpage with everyday code like bootstrap.sass compiled in and my other two are css and javascript specifically for that page itself. The rest of the site uses the same master pages, and follows the 1 extra css and 1 extra javascript per page. Since my index page was the one giving problems and leaflet was something i was using via cdn on that page and no other I downloaded leaflet locally and added it to my gulp files for my index javascript file unfortunately after compile and reload I got hit with the huge timeout spike again but this time I have blackfire running too so hopefully I get something good from it as of right now though no change with that done.

pj_bean's avatar
pj_bean
OP
Best Answer
Level 1

Hi Everyone, I found the problem and it was something I never expected. For some reason all of my geolocation providers stopped providing ip address based lookups and I had completely forgotten the freegeoip provider was in my chain at the very bottom, The long delay was whenever it dropped far enough on the chain in geocoder-laravel it tried to use this and the curl request would just take forever and time out, next run through another provider would actually pick up and provide results. I got this information from that blackfire profile i managed to snag after trying Jekinneys suggestion(which wasnt the problem but helped me trip this sucker up and get the dump Thanks!)

Edit: I should note that it looks like freegeoipprovider is no longer a geocoding solution so if anyone has this in there geocoder provider list they should take it out

jekinney's avatar

Glad you got it! Usually something along those lines. Cdn, API call....

1 like

Please or to participate in this conversation.