Slow WordPress – it drove me crazy!
-
It took me three weeks and I am trying to get it up and running. Yesterday it’s finally running smoothly. Now, I tried to create a custom page template and it threw WordPress into a slow crawl. I now have to face that I have to abandon WordPress for good because no one was able to help me.
Why is it slow? I installed LiteSpeed server and only has one mysql db for that WordPress blog.
-
It’s hard to say exactly why anything is slow, but I doubt that it got slower just because you made a page template.
You could try using WP-Super-Cache. That always gives good speedups.
You can also find out if it’s taking a long time on the database by adding this to your theme’s footer.php file:
<!-- <?php echo get_num_queries(); ?> queries. <?php timer_stop(1); ?> seconds. -->
Then load the page and View Source on it. Look at the bottom to find the number of queries run and how long page generation actually took.
You also have an unclosed
<h1>
tag for Multimedia and a whole whack of unclosed images tags.I’ll check it out. Yesterday and today, it was running fast. It was on LiteSpeed (LSWS), very fast web server.
Then I attempted to create a page template that shows posts by a specific category. Then, it created havoc.
PHP works fine (I tested other non-WP pages and it’s loading fast).
I looked at mysql runtime status and found this line in red:
The number of requests to read a row based on a fixed position. This is high if you are doing a lot of queries that require sorting of the result. You probably have a lot of queries that require MySQL to scan whole tables or you have joins that don’t use keys properly.
it’s now 1774K.
The queries/seconds is
“<!– 13 queries. 40.170 seconds. –>”
Even when I logged in Dashboard, it’s slow.
What version of WordPress do you have? Make sure you upgrade to 2.3.2. There were some bad joins in 2.3 that would cause massive slowdowns in certain circumstances.
it’s 2.3.2
I looked all over for the solution and came across this topic:
https://www.ads-software.com/support/topic/107389?replies=14#post-674586
Since it runs on LiteSpeed server, I have no idea on how to solve it.
I recalled the same problem when I upgraded from 1.5 to 2.1 and it’s the same problem so I have to revert to 2.04 before overhauling the web server to run on CentOS and Litespeed.
Well, the majority of your time is in the page generation. 40 seconds is too long for only 13 queries. Since your database server is giving you messages too, I’d try to find out what queries are taking so much time.
You can see how long each query is taking with a few modifications.
In your wp-config.php file, add this line of code to the top:
define('SAVEQUERIES', true);
Then, in the theme’s footer.php file, you can do this to dump all the queries and how long they took:
if (SAVEQUERIES) { global $wpdb; echo '<!--\n'; print_r($wpdb->queries); echo '\n--!>'; }
Then looking at the source of the page will show all the queries and a number showing how long they took.
After you do this, turn the SAVEQUERIES back off by setting it to false in the wp-config.php file. You don’t want it to spit out the queries all the time.
Looks like we crossposted.
If it’s a wp-cron problem (possible), then you can possibly manually clear it up quickly by doing the following:
Remove or comment out this line from wp-cron.php:
if ( $_GET['check'] != wp_hash('187425') ) exit;
Then call wp-cron.php in your browser:
https://example.com/blog/wp-cron.phpThat will let it run, and clear out any waiting wp-cron jobs. It’s not a fix by any means, but it may eliminate the problem quickly, letting you get the site working and figure out the underlying cause.
if (SAVEQUERIES) {
global $wpdb;
echo ‘<!–\n’;
print_r($wpdb->queries);
echo ‘\n–!>’;
}did not work…it just outputs like the text above. No results. I’m doing your second suggestion, commenting out the line including wp_hash.
I’m still waiting for it to be loading. . .
<!– 13 queries. 0.133 seconds. –>
bingo!
Thank you so much for saving my face at my work! I was the one who fought hard to get WP to run a school’s website instead on IIS MS Server 2003.
Wait a minute…I just made a change in one post then I saved it. Guess what? It’s still slow.
again:
<!– 12 queries. 40.156 seconds. –>
I’ll try loading wp-cron.php again.
What’s causing this?
I run wp-cron.php again and it’s timed out, then I reloaded it again and the website is fast again.
When you make a post or make any sort of change to a post, this creates a job that needs to be processed by wp-cron. The reason the site is slow is because it’s trying to hit wp-cron and cannot for whatever reason.
Manually running wp-cron lets the job process and clears it out. When there’s no jobs, it doesn’t try to hit wp-cron. Thus making the site fast again, until you do something else that triggers a wp-cron job.
So, you need to determine why your site cannot open a connection to itself. This may be DNS incorrectly configured on the server or any of a dozen other things.
Create a new PHP file and put this in it:
<?php $argyle = fsockopen( 'example.com', 80, $errno, $errstr, 0.01 ); if ( $argyle ) { fputs( $argyle, "GET /wp-cron.php HTTP/1.0\r\n" . "Host: example.com\r\n\r\n" ); echo "Success sending the GET.\n"; } else { echo "Error: $errstr ($errno)\n"; } ?>
Run that. If it outputs an error message, then that information might help. Obviously, replace example.com with your own server name.
Hi Otto42,
You’re correct that it’s slow when creating a post. I have to reload wp-cron.php manually. Last night, I attempted to create a post and it was slow. So, I reloaded wp_cron.php manually and it was fast again, but I tried to delete a post and I could not do that. I have to trick it into saving it as a draft. It’ll disappear from the blog, but it won’t be deleted even I deleted it a few times. Later after dinner, it disappeared on its own. Maybe that helps determine the problem.
Now, I have a theory: the school’s blade server cannot get any “outgoing” HTTP requests. From the terminal, I cannot ping google.com, but the webserver is up and running. It appears that for this school, the switcher was set for the server to be opened only for “incoming HTTP requests”, not “outgoing” internet access or “outgoing” http requests.
I assume that when I create a post, it attempts:
1) to send out pings
2) to send out a job to wp-cron.php
3) it could be more???I noticed that the google xml sitemaps plug in cannot reach google and other search engines. (I already disabled it).
I did empty out the ping services (addresses) and disable ping options as I can.
Otto42, I did try to use your php script but I got this:
Parse error: syntax error, unexpected T_VARIABLE in /opt/lsws/DEFAULT/html/test.php on line 2
I do appreciate your big help and efforts!
- The topic ‘Slow WordPress – it drove me crazy!’ is closed to new replies.