Page 1 of 2

Website is too slow

Posted: Wed Nov 24, 2010 3:29 pm
by zaidkhan
Hi Everyone,
I'm working on a website for my client which is almost complete.
currently I have around 300+ categories/subcategories and around 700 products
I have to add around 5000 more products in coming weeks.

I chose opencart because I found it very nice and user friendly, however the biggest issue I'm having is that the website is loading too slow.

I followed the instruction in this post and removed the categories drop down from the list.
http://forum.opencart.com/viewtopic.php ... 811#p61811

Before applying this method Website loading time was 27 seconds (http://www.webpagetest.org/result/101124_5YM/)
After Aplying the above method the time reduced to 19 seconds (http://www.webpagetest.org/result/101124_618/)
but this is still very slow.

Can any one tell me what is the actual issue which is causing the website to load slow.
here is the link of website
http://client.euwebdesignuk.co.uk/malo_products/final/

Re: Website is too slow

Posted: Wed Nov 24, 2010 9:35 pm
by Xsecrets
you could follow the directions at this page to see if mysql is slowing things down and if so what queries are causing the problem.
http://forum.opencart.com/viewtopic.php?f=121&t=22048

Re: Website is too slow

Posted: Thu Nov 25, 2010 9:22 am
by Qphoria
The issue is likely the excessive amount of categories. Because of the recursive lookup that is done on the categories it takes a lot of time to build a tree of that many

Re: Website is too slow

Posted: Thu Nov 25, 2010 12:39 pm
by Xsecrets
I thought you cached the category lookup.

Re: Website is too slow

Posted: Thu Nov 25, 2010 2:36 pm
by zaidkhan
Thanks for your replies,
Can you please suggest what do I have to do in order to resolve this issue.
Do I need to reduce the number of categories?
I used import/export module and created all the categories myself in the excel sheet. it was hard to manage so many categories and I had to give them long integer id's in order to make each id unique.

Re: Website is too slow

Posted: Thu Nov 25, 2010 11:42 pm
by zaidkhan
Do you think web hosting could be one of the reasons?
My host is M6.net and it is on shared hosting.

Re: Website is too slow

Posted: Fri Nov 26, 2010 3:03 am
by cartpro
First thing I would do is to disable the category module and comment out the following line in common/header.php (around line 118) to check if it is really category issue.

Code: Select all

$this->data['categories'] = $this->getCategories(0);
I have loaded my site with 200+ categories and 11,300+ product and it takes 10-15seconds. Check out at http://www.sansdirect.com and see if you see the same response.

Also, check your error log for any script errors and warnings. This will reduce the response time too.

Re: Website is too slow

Posted: Fri Nov 26, 2010 4:48 am
by Qphoria
Xsecrets wrote:I thought you cached the category lookup.
The search bar categories are cached, but not the side module

Re: Website is too slow

Posted: Fri Nov 26, 2010 8:02 am
by Xsecrets
ahh didn't realize that maybe we should cache that too.

Re: Website is too slow

Posted: Fri Nov 26, 2010 3:10 pm
by zaidkhan
Thanks for your replies and help.
Would you please guide me how do I cache the sidebarmenu module.
It is quite similar to category module.

Re: Website is too slow

Posted: Fri Nov 26, 2010 3:56 pm
by Qphoria
Actually I'm wrong. The caching IS on all categories. But I think there might be an issue with empty categories. Since the cache returns an empty array for categories with no subs, it requeries the database as it reads "empty array" and "false variable" the same.

So try this

1. EDIT: catalog/model/catalog/category.php

2. FIND:

Code: Select all

if (!$category_data) { 
3. REPLACE WITH:

Code: Select all

if (!$category_data && !is_array($category_data)) { 

Re: Website is too slow

Posted: Wed Dec 01, 2010 11:06 pm
by zeroevil
Qphoria wrote:Actually I'm wrong. The caching IS on all categories. But I think there might be an issue with empty categories. Since the cache returns an empty array for categories with no subs, it requeries the database as it reads "empty array" and "false variable" the same.

So try this

1. EDIT: catalog/model/catalog/category.php

2. FIND:

Code: Select all

if (!$category_data) { 
3. REPLACE WITH:

Code: Select all

if (!$category_data && !is_array($category_data)) { 

I did it on my site Q and did the test below hope it helps out. but you may have something there I have a few empty categories as I am still stocking my store I'm keeping the inventory lite just to make sure.

now I am doing some testing right now as I am writing this
Test #
#1.) popup category mod disabled no side category option running.
Results : site running lighting fast

#2.) enabling popup category mod in cached mode
Results : large slow down 30sec page load times

#3.) enabling popup category mode non cached mode
Results : much faster 5sec page load times

seems if you disable the cache mode in the popup category mod it works much better. I'll do further testing on my half to make sure of the results. but right now the results look promising.

Re: Website is too slow

Posted: Wed Dec 01, 2010 11:15 pm
by Qphoria
not sure what the popup category mod is but I assume they are using the same category lookup in the model. Did my change above improve anything?

Re: Website is too slow

Posted: Wed Dec 01, 2010 11:43 pm
by zeroevil
Qphoria wrote:not sure what the popup category mod is but I assume they are using the same category lookup in the model. Did my change above improve anything?
popup category module is the mod I referred to, the author has a cache mode for it. But it seems the cache mode does more harm then good. http://www.opencart.com/index.php?route ... order=DESC


As of right now I think this is the solution Q. My site is running much faster and very efficient. So I'm gonna finishing loading my stock onto my site to make sure the slow down bug has been squashed.

Re: Website is too slow

Posted: Thu Dec 02, 2010 1:12 am
by zeroevil
Well been running it for a couple of hours and its been running well. Thanks Q I think this is the solution!!

but I still haven't tested it on a standard site installation yet, since I have made some modifications to my base site installation. I have added a few modules, updated to 1.4.9.2 and added some code to my site from others in the forums that was trying to help on this issue. I know your fix had the greatest impact on resolving the issue but not sure if it was just part of the puzzle. So I guess the next step is to test this on a standard install of 1.4.9 with 300 categories and see what happens. Then move to add it to 1.5 and to a patch for 1.4.9 for others that are experiencing the same issue.

Again thanks Q !!!

Re: Website is too slow

Posted: Thu Dec 02, 2010 5:00 am
by Xsecrets
just out of curiosity could someone who is having the slowness problems try adding an index on the parent_id field of the category table and see if that helps?

Re: Website is too slow

Posted: Sat Dec 04, 2010 3:34 pm
by alex1
cartpro wrote:First thing I would do is to disable the category module and comment out the following line in common/header.php (around line 118) to check if it is really category issue.

Code: Select all

$this->data['categories'] = $this->getCategories(0);
Wow! I tried this, and my site loaded almost instantly on every click. Incredible.

The site seems to work fine and nothing is broken that I can tell... what does this line actually do? Can I just leave it commented out?

Re: Website is too slow

Posted: Sat Dec 04, 2010 7:11 pm
by SapporoGuy
Q,
Nice fix!

Re: Website is too slow

Posted: Sat Dec 04, 2010 8:57 pm
by cartpro
Glad you found the issue.

What I would do is, cache the rendered category menu instead of caching individual category queries. That means, you will disaply all the categories in a multi-level menu. Check out menu on the header bar on my site http://www.sansdirect.com

Re: Website is too slow

Posted: Mon Dec 06, 2010 2:21 am
by alex1
cartpro wrote:Check out menu on the header bar on my site http://www.sansdirect.com
Your site is painfully slow.

Why don't you use the removal of:

Code: Select all

$this->data['categories'] = $this->getCategories(0);


yourself?