-
Notifications
You must be signed in to change notification settings - Fork 691
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Painfully slow response times in Valet + tons of 504 gateway timeouts #744
Comments
How long has this been happening? Did you recently switch between PHP versions? which ones? Is this problem manifesting only with Laravel apps? specific ones? Which non-Laravel apps? Does running When last did you run |
Great questions, @drbyte, thanks!
Since I installed it — ±3 months ago
☝️
Not sure. I'm not doing much with installs. I'm running a pretty old machine (2011) and running High Sierra
N/A—I only build Craft CMS sites.
Not sure. I haven't seen any difference in either the amount of 504s I get or how fast the reload times are, no matter what I do to MacOS or what sort of composer packages I have. 504s are intermittent and I've always seen at least a 10-15 second reload time since the first install.
I did a clean install of Valet recently (±2 months ago) and went straight to 7.1
I don't do anything besides Craft CMS installs, so I couldn't say. But every single install is like this—whether I install it fresh or am installing a site I inherit.
No pattern for 504s. Sometimes they resolve with either multiple reloads or a
Just tried it — did not help. Reload time was still slow.
Couple of weeks ago. And again just 5 minutes ago. Does not help. |
@circa42 Could you try loading a site with just a straight HTML file? Then one with a single PHP file that doesn't do anything? <?php
echo "Hey there!"; Then, if it's easy enough, one that just connects to your database? <?php
$host = '127.0.0.1';
$username = 'root';
$password = '';
$database = 'testing_valet';
$table = 'users';
$mysqli = new mysqli($host, $username, $password, $database);
if ($mysqli->connect_errno) {
echo "Error: Failed to make a MySQL connection:<br>";
echo "Errno: " . $mysqli->connect_errno . "<br>";
echo "Error: " . $mysqli->connect_error . "<br>";
exit;
}
$sql = "SELECT * FROM {$table}";
if (! $result = $mysqli->query($sql)) {
echo "Error: Failed querying<br>";
echo "Errno: " . $mysqli->errno . "<br>";
echo "Error: " . $mysqli->error . "<br>";
exit;
}
var_rump($result->fetch_assoc()); |
@mattstauffer |
I do get this error when trying to connect to an existing local DB: |
(the |
I'll try TTFB is speedy — 93.8ms. So if TTFB is fast on these little test files—is there something weird with my Craft install? |
Maybe. cd Sites
composer create-project laravel/laravel speedtest
cd speedtest
valet open |
If the fresh Laravel app also exhibits the problem, then what are the results of I think there are 2 areas of interest with this situation:
|
LOLOL |
@drbyte — a fresh Laravel install yields anywhere between a sub 150ms to a +5s TTFB. |
I wonder how that compares with a fresh Craft site? Again, looking for patterns here, or even better: looking to isolate what produces the symptoms. |
Interesting. A fresh Craft install gave me a 504 time out right off the bat. Then a few more refreshes and it showed up with a TTFB of 795ms. |
Did you ever get to the bottom of this? I am having the exact same problem, wondering if it has something to do with a past Homestead install |
Honestly, I think the problem (for me, at least) is that I needed upgrade my macOS. (I’ve heard it something’s doesn’t play nice the High Seirra) My computer was old enough that I had to buy a new machine. Whether it was the macOS, or not having some random crapware on my machine slowing things down, either way I’m back in business. |
Had a related issue with a 2011 mac and high sierra: Basically dnsmasq didnt start up. I just installed valet. So I did this: That fixed it |
@circa42 - did you manage to solve this? I am seeing the same issues. I am also building Craft sites. |
My solution isn't an overly viable one, but yes I did solve it by buying a new iMac. 🙄 |
my iMac is new and super specced so wasn't the issue. |
I have been suffering with a slow Valet setup, thinking the problem was that WordPress was slow all along. I just tried a different set up (not Valet), and now I get response within 0.1s instead of 2s with Valet. I know that I'm not giving enough information to be helpful to Valet developers, but I did want to help lurkers and encourage them to investigate not just your PHP application, but also your setup. |
What setup did you use @Flimm ? |
@Flimm ... and was the slowness only with Wordpress? |
@Flimm I have the same issues. It's basically ruining my workday. Which other setup did you choose? 😊 |
To respond to @terryupton , @drbyte , @simplenotezy , I'm afraid that I didn't have time to investigate properly the causes, so I can't be 100% sure that the problem was with Valet. It wasn't an issues of slowness just with WordPress, other PHP applications were also slow. I eventually tried Local by Flywheel, and MAMP. I only wanted to encourage lurkers to investigate other options. |
I bought a new iMac a few months ago and it's been painfully slow, to the point where it would take several seconds just for an Alfred prompt to show, then another 5-10 seconds just to type something in. Photoshop and email took minutes to launch... I finally decided to get to the bottom of it today and started uninstalling apps, but nothing helped. I then decided to do So something in the Valet install is killing my Mac... |
Then when you identify which service is related to the slowdown, you can go explore its config files and/or any other services that might be conflicting with that service (or any added extensions/etc that you've added that could be contributing). |
@drbyte Here's what's weird. When I run |
So it must be something with your PHP install then? |
Mac is running slow...
Mac is now running fast. Let's check...
So, it looks like Valet didn't actually stop nginx or PHP, as they're still running, and my Mac is no longer slow until I run |
Line 252 in 12f75fc
OK, so Curiously, my nginx and php processes run as I'm showing So let's dig into what Valet telling nginx to stop does: Line 159 in 12f75fc
runs And what it telling PHP to stop does: Line 125 in 12f75fc
brew -> stopService ->all running services which start with
... which doesn't seem to have any impact on your computer. I just noticed something. If I try to run that same command: So if my services are started as I can't imagine how that would solve this mysterious problem, but hey, at least it might get your computer into a more predictable state? |
Thanks Matt; apologies for the delay. This is a very strange issue, because PHP and nginx keep bouncing back and forth between starting as root, and when I stop and restart it doesn't seem to have any effect one way or the other. Sometimes everything slows down, other times it doesn't, and I haven't been able to find a pattern as to why. It's currently running well, so I'm just going to leave it alone in fear it'll start crawling again. Someday when I find the time I'll probably just uninstall everything and start over. Thanks! I appreciate your help! |
So I had this problem all last night super random - 40-400s page loads, certain projects just flat out 504 Turns out that after I upgraded to php 7.4.1 the mysql (v8.0.18) user id made with mysql_native_password no longer works - setting this back to caching_sha2_password it worked instantly. Something to definitely check as there was nothing obvious that pointed to this being an issue at all |
@Trashpants can you expand a bit on what you did to reset back to |
@tyssen honestly the easiest way to check if the DB user is an issue is to comment them out in your .env file. If things go back to what you’d expect then check the return of:
Gives your user a plugin value of caching_sha2_password. If you make a brand new user on the DB and you don’t alter the plugin value you will automatically get caching_sha2_password |
I created a new user which was assigned the |
I've added a Statamic site to valet now and it's running a lot more quickly than the ones using a database. Although when I do a test on a static PHP file v the db connect example Matt gave above, I'm not seeing much variation. Certainly not as much as doing the same TTFB test on a page being served by the CMS.
|
I've been having this exact same problem. Everything is up to date, including Craft CMS, and I have a beefy 2019 MBP. Out of interest, is anyone also experiencing this problem using CloudFlare's 1.1.1.1 DNS in macOS? You set it in Sys Prefs > Network > Advanced > DNS: DNS Servers. Since removing CloudFlare's servers all my Craft sites on Valet have gone from 20-30 second load times to less than a second or two (depending on the site). This may be a coincidence so I'll keep an eye on what happens. |
Last night I found Cloudflare's DNS was causing delays in everything using it. Seems to be moderately better this morning. My preferred way of controlling external DNS when Valet is installed is to create custom dnsmasq configs for the various providers I might use is documented here: I have separate configs I enable/disable for Cloudflare, OpenDNS, Google, etc. I normally prefer cloudflare's 1.1.1.1 ... until last night's incident. EDIT: Update: The CloudFlare issue was very temporary. |
I got a new mac, reinstalled brew and valet, and Craft ended up working flawlessly. After several months, the same problem returned. I have not I have yet to get any timeout errors, but every request takes over 10 seconds. I installed the latest update for my mac yesterday, but the problem started occurring today after a restart. I have tried everything in thread. I don't have any CloudFlare servers in my DNS server list. Could this have anything to do with my VPN service? |
@havardlj it would be preferable for you to open a new ticket for this. You can mention that you reviewed this Issue. When you make that post, answer the questions posed in the New Issue template, and expand on the following as well:
Do you mean a MacOS update? Or homebrew updates?
In the absence of any explanation of said VPN service I'll say: yes. Until you rule it out. Posting the output from |
I have a brand new Big Sur set up on 2019 Macbook Pro and the TTFBs with Laravel are just dreadful. Usually close to a second. When I just load an index.php w/ Laravel and connected to a database, and exit out before booting the framework, it's basically instant. Not sure why it's so darn slow. |
@erikwestlund please open a new Issue, including the output of |
Problems:
The whole thing is crazy slow. I have no idea where to start on how to fix this.
What I've done:
» reinstalled valet
» changed
memory_limit
to= 256M
» updated valet
» updated brew
» restarted valet
» restarted machine
» swore loudly
I'm running 7.1.25
Any help pointing me in the right direction would be awesome.
The text was updated successfully, but these errors were encountered: