Zen Cart Logo
Forums / General Questions / 5 sites suddenly running very slow

5 sites suddenly running very slow

Views: 4,491

Results 1 to 20 of 42
8 Sep 2011, 4:25 PM
#1
stuff4toys avatar

stuff4toys

Totally Zenned

Join Date:
May 2007
Location:
SW Florida
Posts:
1,062
Plugin Contributions:
1

5 sites suddenly running very slow

I have 5 Zen-Cart 1.3.8 sites on one hosting account and they are all running VERY VERY slow. The ones in my tagline.

Parse Time: 127.236 - Number of Queries: 804 - Query Time: 125.874090737

They keep telling me there are just to many queries going on. funnily enough I have 6 other zen-cart sites with another host; running the exact same version and those sites are running fast as ever.

Any idea's what's happening on the server to make it run so slow?

Server Information

       **Server Host:** box606.bluehost.com (70.40.220.106)                **Database Host:** localhost (127.0.0.1)           **Server OS:** Linux 2.6.32-42.1.BHsmp        **Database:** MySQL 5.1.58-community-log           **Server Date:** 09/08/2011 10:24:07       **Database Date:** 09/08/2011 10:24:07            **Server Up Time:**  10:24:07 up 69 days, 10:46,  2 users,  load average: 20.59, 19.17, 18.24     **HTTP Server:** Apache           **PHP Version:** 5.2.17 (Zend: 2.2.0)   **PHP Memory Limit:** 128M     **PHP Safe Mode:** Off           **PHP File Uploads:**       On    **Max Size:** 10M     **POST Max Size:** 8M           **Database Data Size:** 51,621 kB     **Database Index Size:** 3,212 kB
8 Sep 2011, 4:43 PM
#2
stuff4toys avatar

stuff4toys

Totally Zenned

Join Date:
May 2007
Location:
SW Florida
Posts:
1,062
Plugin Contributions:
1

Re: 5 sites suddenly running very slow

Logged into phpMyAdmin and the querry times are better. Yup just logging in the query times dropped to between 60 - 40 seconds.
Parse Time: 42.615 - Number of Queries: 792 - Query Time: 41.3521166272

STILL WAY TOOOOOOO SLOW!

Ran Optimize and Repair and no significant speed change.

8 Sep 2011, 4:46 PM
#3
stuff4toys avatar

stuff4toys

Totally Zenned

Join Date:
May 2007
Location:
SW Florida
Posts:
1,062
Plugin Contributions:
1

Re: 5 sites suddenly running very slow

This is coming from another host and the same version of Zen-Cart and MUCH larger database. This is what it should be.
Parse Time: 0.566 - Number of Queries: 544 - Query Time: 0.305399394226

8 Sep 2011, 4:47 PM
#4
stuff4toys avatar

stuff4toys

Totally Zenned

Join Date:
May 2007
Location:
SW Florida
Posts:
1,062
Plugin Contributions:
1

Re: 5 sites suddenly running very slow

Back up to
Parse Time: 148.660 - Number of Queries: 793 - Query Time: 147.772943237

This is nuts!

8 Sep 2011, 5:07 PM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: 5 sites suddenly running very slow

When your query time is huge and close to the same as the overall parse time, then that means the bottleneck is in the MySQL server.
Ref: https://www.zen-cart.com/tutorials/index.php?article=105

8 Sep 2011, 5:15 PM
#6
stuff4toys avatar

stuff4toys

Totally Zenned

Join Date:
May 2007
Location:
SW Florida
Posts:
1,062
Plugin Contributions:
1

Re: 5 sites suddenly running very slow

DrByte:

When your query time is huge and close to the same as the overall parse time, then that means the bottleneck is in the MySQL server.
Ref: https://www.zen-cart.com/tutorials/index.php?article=105
I figured that, what do I tell the hosts techs to get them to believe it's not zen-carts fault. they keep blaming the scripts and toooo many queries.

I don't have the right vocabulary to convince them it's the servers fault.

Thanks for your reply
JOhn ><>

9 Sep 2011, 1:41 AM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: 5 sites suddenly running very slow

Didn't you already say the same site works great on another server? That should be all they need to hear if they're really looking at the issue. WHEN did the problem suddenly start? Have you verified that all your ZC files have NOT been tampered with and thus couldn't suddenly be the cause?

Next, you'll need to work with the hosting company to identify all the slow-performing queries. THEY already know that they can turn on slow-query-logging. Analyzing those logs is VERY time-consuming, and probably something they're not interested in doing, and since the logging probably can't be isolated to your accounts only, they probably can't just give you the logs since they'll contain other customers' info. But, if the problem is in your database data and you really want to figure out what exactly is causing it, those logs are the best tool.

Next you can export your database 'structure only' and compare all the fields and indexes against the default ZC sql files to see what differences exist, and then reconcile whether each of those differences is legitimate for your unique store, etc.

In short, if the problem "suddenly" started and nothing is corrupt in your database data, then the problem is on their end. Given that you're referring to multiple different databases, that points more broadly to a server-wide problem than just a tiny bit of corrupted data in one database.

9 Sep 2011, 5:07 PM
#8
stuff4toys avatar

stuff4toys

Totally Zenned

Join Date:
May 2007
Location:
SW Florida
Posts:
1,062
Plugin Contributions:
1

Re: 5 sites suddenly running very slow

Thanks for your input. I know about the slow query logs, they are HUGE and intimidating because on this hosting account there are many domains and a ton of info there.

Got a call from the hosts Tech Support, database manager and he took the time to explain the issues and the solutions. To bad they cannot do it for me. They seem to believe that if I parse through the slow query logs, and determine which table and field is causing the issue and ad an index for that individual field, it will help the issue.

He explained database fragmentation and recommended a more regular repair and optimize routine. He also pointed out a few tables that had excessive overhead, like the whos_online and sessions tables.

?? Question: Can these tables be purged from time to time??

Now I start the process of parsing through the slow query logs and see if I can help by adding indexes.

FYI: my primary domain gets 6,000 - 10,000 requests per day. This seems an issue for domains working on a shared hosting server that get some good activity.

Another thing the tech did which seems to be a help temporarily is switch from PHP5 (Single php.ini) to PHP5 (FastCGI)
Currently that domain went from 120 second query times to 1.5 to 12 seconds.

?? Question: can the repair and optimization of the database be performed remotely via browser instead of going to phpMyAdmin to do it?

Thanks for all your help, it's off to slow query log land, wake me in two hours if I don't come back online.

9 Sep 2011, 6:49 PM
#9
stuff4toys avatar

stuff4toys

Totally Zenned

Join Date:
May 2007
Location:
SW Florida
Posts:
1,062
Plugin Contributions:
1

Re: 5 sites suddenly running very slow

So I started the daunting task of reviewing the slow_query_log and found it littered with entries like this:

# Fri Sep  9 05:49:08 2011
# Query_time: 1.300991  Lock_time: 0.000094 Rows_sent: 1  Rows_examined: 3
use database_name;
select banners_id, banners_title, banners_image, banners_html_text, banners_open_new_windows, banners_url
  from banners
  where status = 1  and ( banners_group = 'SideBox-Banners') order by rand()
```One for each banner group for every request made.  So for one product view, there are 5 entries like this for the banners.

1.3 seconds doesn't sound like a long time, but when I only get every 300th of a clock tick to process, it takes FOREVER.

I get these for every domain on the server.  Do I need to drop the banners table and recreate it?  think this table is corrupt on each domain?
9 Sep 2011, 6:56 PM
#10
stuff4toys avatar

stuff4toys

Totally Zenned

Join Date:
May 2007
Location:
SW Florida
Posts:
1,062
Plugin Contributions:
1

Re: 5 sites suddenly running very slow

This is a 1.3.9h installation
I checked the slow_query_log on another host that only gets a few hits a day and get the same kind of entry:

Fri Sep 9 02:18:05 2011

Query_time: 1.114327 Lock_time: 0.001940 Rows_sent: 0 Rows_examined: 0

use anotherdb_name;
select banners_id, banners_title, banners_image, banners_html_text, banners_open_new_windows, banners_url
from banners
where status = 1 and ( banners_group = 'Wide-Banners') order by rand()This is on a completely different server with the same host.

9 Sep 2011, 7:58 PM
#11
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: 5 sites suddenly running very slow

Stuff4Toys:

They seem to believe that if I parse through the slow query logs, and determine which table and field is causing the issue and ad an index for that individual field, it will help the issue.Well, there's a half-ounce of truth there, but only if you're dealing with tables that weren't indexed in the first place.
That's why I asked you to analyze the structural differences and report back on what you found to be wrong with indexes vs a clean install. That would reveal which default indexes are missing and need to be put back.

What I was intending to suggest AFTER you do that would be to manually delete and recreate all the indexes. But, that's time-consuming and not really useful unless several indexes are indeed damaged and not getting fixed by a database-wide repair operation. And, the slow-query-log output should expose tables that have large numbers of records and maybe failing indexes, and thus those would be the ones to rebuild. There's no point rebuilding indexes on all tables since many are not used anywhere near as much as others.
Recreating all the indexes by hand is a cumbersome process, and very server-intensive on large tables. Automating it could bring a server to a crawl if not done carefully. But doing it by hand manually allows enough time between setting up for the changes, that the server catches up and doesn't slow everybody down badly.

Stuff4Toys:

He explained database fragmentation and recommended a more regular repair and optimize routine.

?? Question: can the repair and optimization of the database be performed remotely via browser instead of going to phpMyAdmin to do it?
In the current version of Zen Cart there's an Optimize Tables option in the Admin->Tools->Store Manager screen, which loops thru all the tables and optimizes them.
Also, various ZC admin screens already do table optimizing whenever records are deleted from products and categories, etc, to minimize fragmentation.
Addons, however, probably don't go that far, so no promises about any of those.
Stuff4Toys:

He also pointed out a few tables that had excessive overhead, like the whos_online and sessions tables.

?? Question: Can these tables be purged from time to time??Sure. You can truncate those tables anytime you wanna kick everyone off your store.
Stuff4Toys:

Now I start the process of parsing through the slow query logs and see if I can help by adding indexes.Be careful there. Don't go adding indexes willy-nilly. There's a science to creating smart indexes. Creating too many needlessly will slow things down too. A clean install of the current version of ZC already has those optimized pretty well.
Stuff4Toys:

So I started the daunting task of reviewing the slow_query_log and found it littered with entries like this:

[code]# Fri Sep 9 05:49:08 2011

Query_time: 1.300991 Lock_time: 0.000094 Rows_sent: 1 Rows_examined: 3

...

1.3 seconds doesn't sound like a long time, but when I only get every 300th of a clock tick to process, it takes FOREVER.Actually, 1.3 seconds is a HUGE amount of time for a table that has only 3 rows to examine, and only 1 row to return. That's telling you the MySQL CPU activity seems to be taking way longer than it should when given the data it's got to work with.

ANY table with only 3 rows in it, even without any indexes, should return its data with lightning speed.

Stuff4Toys:

Do I need to drop the banners table and recreate it? think this table is corrupt on each domain?If it's only got 3 records in it, then that's unlikely to resolve the problem.
However, this is what I'd do. Take it in stages, and test each one:
a) REPAIR the table first. Then test speed.
b) Then delete and recreate the indexes. (write down the indexes on the table now, delete them, then recreate them). You might test after deleting, and then again after recreating.
c) Then if there's still a problem, delete the whole table and recreate it. Then test. Then import the records back into it, and test again.
Of course, do a backup of the table before you do anything.

9 Sep 2011, 8:30 PM
#12
stuff4toys avatar

stuff4toys

Totally Zenned

Join Date:
May 2007
Location:
SW Florida
Posts:
1,062
Plugin Contributions:
1

Re: 5 sites suddenly running very slow

This host creates a new log file each hour. So in one hours time at 5AM this morning there are 3,500+ rows in the log file. each entry takes about 5 to 10 lines. 90% of the entries are like the above, all pointing at the banner tables for each domain on the server. So this host has 5 domains running Zen-Cart 1.3.8a and each is giving the same slow query on the banners table.

Log file on another host only gets 1 or 2 visitors a day running Zen-Cart 1.3.9h , and only has one entry in it and it's the banner table.

How could we be having the same problem in one table spread over so many different databases all having the same issue. The biggest site only has 8 entries in the banner table.

I know it's one of the busiest tables because it is read for EVERY page displayed, but .....

I am frustrated, if it doesn't show. I am doing a fresh install and will compare the tables and field indexes now.

9 Sep 2011, 8:33 PM
#13
stuff4toys avatar

stuff4toys

Totally Zenned

Join Date:
May 2007
Location:
SW Florida
Posts:
1,062
Plugin Contributions:
1

Re: 5 sites suddenly running very slow

I forgot that on this host only 4 domains have 1.3.8a, the first in my tagline is 1.3.9d upgraded to 1.3.9h

9 Sep 2011, 9:40 PM
#14
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: 5 sites suddenly running very slow

You could test another concept: eliminate calls to those banner records by turning off all the banner_boxXXX sideboxes in Admin->Tools->Layout Boxes control, and blanking out the Banner Group names in Admin->Configuration->Layout Settings

10 Sep 2011, 1:00 AM
#15
stuff4toys avatar

stuff4toys

Totally Zenned

Join Date:
May 2007
Location:
SW Florida
Posts:
1,062
Plugin Contributions:
1

Re: 5 sites suddenly running very slow

Tried turning off the banners, didn't think of that.

Compared the structure of the offending databases "banners" table and they are all the same. time to start deleting indexes and re-creating.

Created a fresh install on another server and it's the same too.

10 Sep 2011, 5:54 AM
#16
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: 5 sites suddenly running very slow

So ... when you turned off the banners, those queries would stop altogether.
What happened to page parse times? And query logs?

I'm a little puzzled that banners would be causing any of this slowdown.
It seems that since all your sites on this particular server are having the same problem, and they're running different versions of the code, that the problem is the database engine or the connection to the database, and not the PHP code itself nor the queries it's generating.

12 Sep 2011, 12:41 AM
#17
stuff4toys avatar

stuff4toys

Totally Zenned

Join Date:
May 2007
Location:
SW Florida
Posts:
1,062
Plugin Contributions:
1

Re: 5 sites suddenly running very slow

DrByte:

You could test another concept: eliminate calls to those banner records by turning off all the banner_boxXXX sideboxes in Admin->Tools->Layout Boxes control, and blanking out the Banner Group names in Admin->Configuration->Layout Settings
I did this and the query times dropped to 1 to 12 seconds almost immediately. Now two days later it is amazing, like someone turned on a switch I am seeing

Parse Time: 0.700 - Number of Queries: 794 - Query Time: 0.223894582977

Just like it aught to be. Monday I will start turning on the banners again, one at a time.

12 Sep 2011, 12:47 AM
#18
stuff4toys avatar

stuff4toys

Totally Zenned

Join Date:
May 2007
Location:
SW Florida
Posts:
1,062
Plugin Contributions:
1

Re: 5 sites suddenly running very slow

DrByte:

I'm a little puzzled that banners would be causing any of this slowdown.
It seems that since all your sites on this particular server are having the same problem, and they're running different versions of the code, that the problem is the database engine or the connection to the database, and not the PHP code itself nor the queries it's generating.
That's what I am talking about. I know that the host is monitoring this thread.

I do have a 1.3.9h installation on another server with this same hosting company. this site only gets 5-10 requests per day, pretty slow going, however the slow_query_log still shows the same banner slow query.

I did a clean install on a server at another hosting company, and will work on it some more early next week and get some good data into it, to compare and see if it is just the first host, or if it is on both hosting companies.

12 Sep 2011, 12:50 AM
#19
stuff4toys avatar

stuff4toys

Totally Zenned

Join Date:
May 2007
Location:
SW Florida
Posts:
1,062
Plugin Contributions:
1

Re: 5 sites suddenly running very slow

DrByte:

I'm a little puzzled that banners would be causing any of this slowdown.
It seems that since all your sites on this particular server are having the same problem, and they're running different versions of the code, that the problem is the database engine or the connection to the database, and not the PHP code itself nor the queries it's generating.
Four of the five sites running 1.3.8a were installed over a year ago and then installed over a period of several years. Different templates, but most running the same add-ons.

Busiest Site:
Hit Counter Started: 03/25/2010
Hit Counter: 2817387

Oldest Site:
Hit Counter Started: 10/24/2008
Hit Counter: 1328427

This issue really started about 2 months ago, shortly after server maintenance and a reboot.

:cry:

12 Sep 2011, 1:02 AM
#20
dogtags avatar

dogtags

Totally Zenned

Join Date:
Nov 2003
Posts:
876
Plugin Contributions:
1

Re: 5 sites suddenly running very slow

Stuff4Toys:

This is coming from another host and the same version of Zen-Cart and MUCH larger database. This is what it should be.
Parse Time: 0.566 - Number of Queries: 544 - Query Time: 0.305399394226

What is the other host? (the one that had much better performance)

Thanks :smile: