Page 1 of 1

Performance Problem when cart > 20 items

Posted: Thu May 16, 2019 4:03 pm
by foobarac
***** SOLVED SEE MY POST BELOW ******

OC 3.0.2.0
PHP 7.1 (was 5.6)
Theme: Basel
62 Products (including options)
20 Categories
system setting to count products for categories - turned off
Gzip and Apache caching turned on.
Database has been refreshed, all session and cart tables have little in it.

My webshop (still under UAT) performs extremely fast. Page loads and adds to carts are extremely quick (like 1-2 second load times).

However, the more you add to the cart, the slower it gets. By the time you get to 20 items its like 15-20 second page loads. Likewise if you make a change to the cart (delete an item) it takes around 15-20 seconds but starts to speed up the more you delete.

There are no errors coming up in the error.log and I have tried to research here and on the web but nothing comes up.

This purely looks like a problem just with the cart processing.

Any ideas or help on how solve this ?

Thanks,

Anthony

Re: Performance Problem when cart > 20 items

Posted: Thu May 16, 2019 5:32 pm
by paulfeakins
foobarac wrote:
Thu May 16, 2019 4:03 pm
However, the more you add to the cart, the slower it gets. By the time you get to 20 items its like 15-20 second page loads. Likewise if you make a change to the cart (delete an item) it takes around 15-20 seconds but starts to speed up the more you delete.
And does this happen if you switch back to the default theme? If so the problem is with your theme and you should contact the theme developer.

Re: Performance Problem when cart > 20 items

Posted: Thu May 16, 2019 6:25 pm
by thekrotek
There're definitely no issues with cart database queries in OpenCart. 20 items is a very, very small number, it can not slow down the queries.

Re: Performance Problem when cart > 20 items

Posted: Thu May 16, 2019 7:56 pm
by foobarac
Hi Paul,

Was in the process of building a copy on a test site. Disabled the theme and yes it's faster.

What I should really ask if there are any ideas (besides pinging the theme developer which I have done) on how to get an AJAX based theme performing quicker ?

Any changes in the config.php or .htaccess files or any other suggestions ?

Re: Performance Problem when cart > 20 items

Posted: Thu May 16, 2019 10:28 pm
by thekrotek
foobarac wrote:
Thu May 16, 2019 7:56 pm
What I should really ask if there are any ideas (besides pinging the theme developer which I have done) on how to get an AJAX based theme performing quicker ?
Depends on which AJAX requests are made. Sometimes database indexing/caching helps.

Re: Performance Problem when cart > 20 items

Posted: Fri May 17, 2019 5:56 pm
by paulfeakins
foobarac wrote:
Thu May 16, 2019 7:56 pm
What I should really ask?
You should ask them to reconsider their career as a developer if they can't make an AJAX request that returns 20 database rows run quickly.

Re: Performance Problem when cart > 20 items

Posted: Sat May 18, 2019 1:42 am
by straightlight
This commit can also be useful to know as an information: https://github.com/opencart/opencart/is ... -487515608

Re: Performance Problem when cart > 20 items

Posted: Sun May 19, 2019 1:11 pm
by foobarac
paulfeakins wrote:
Fri May 17, 2019 5:56 pm
foobarac wrote:
Thu May 16, 2019 7:56 pm
What I should really ask?
You should ask them to reconsider their career as a developer if they can't make an AJAX request that returns 20 database rows run quickly.
LOL - I will tell him !

Re: Performance Problem when cart > 20 items

Posted: Sun May 19, 2019 1:32 pm
by foobarac
straightlight wrote:
Sat May 18, 2019 1:42 am
This commit can also be useful to know as an information: https://github.com/opencart/opencart/is ... -487515608
Thanks Straightlight, although a different problem being reported, it is centered around the cart and how and when it is updated by OC. It appears some work may need to be done around this to improve the performance especially when you have a loaded cart:

viewtopic.php?t=211273

Re: Performance Problem when cart > 20 items

Posted: Sun May 19, 2019 3:46 pm
by JazzBlueRT
PHP 5.6 is no longer supported by the PHP team . OC 3 runs fine on PHP 7.2. You will get a substantial performance boost with PHP 7+.

Re: Performance Problem when cart > 20 items

Posted: Mon May 20, 2019 5:38 am
by foobarac
Yes I have moved to PHP 7.1 and it has improved the situation.

But with a loaded cart you can still get a performance hit when you change pages or try anything processing the cart.

Re: Performance Problem when cart > 20 items

Posted: Mon May 20, 2019 6:19 am
by thekrotek
I'm afraid, the issue is on your side. Probably happens on a certain server configuration. I've added 30+ items to cart and it loaded just fine, didn't notice any drop in performance. Tested it on OC 3, PHP 7.2.

Re: Performance Problem when cart > 20 items

Posted: Fri Jun 14, 2019 8:05 am
by foobarac
**** SOLVED ****

I have investigated this problem and have discovered that CORE OpenCart makes a heap re-iterative calls, reloading product items many times during a page load.

For example, Cart\Cart >getProducts() gets called numerous times just to load the home page.

There is no cache so every call to Cart\Cart >getProducts() reloads the entire cart from scratch. The more cart items you have, the more the load time starts to compound.

This is quite amazing considering the maturity and claimed scalability of OpenCart and a lot of opencart experts claiming nothing is wrong with the core code.

Also, Cart\Cart >getProducts() gets called by other simple sub-routines:

Cart\Cart->getTaxes()
Cart\Cart->countProducts()
Cart\Cart->hasShipping()
Cart\Cart->getSubTotal()

Thanks to Mikhail at liveopencart, he has produced a ocmod that basically brings down page load times with carts loaded with many products from 10's of seconds (in my case +25 seconds for +130 cart items) down to seconds (3 seconds for me).

Anyone wanting the fix please contact him at "support at liveopencart.com".

Re: Performance Problem when cart > 20 items

Posted: Fri Jun 14, 2019 1:36 pm
by thekrotek
foobarac wrote:
Fri Jun 14, 2019 8:05 am
There is no cache so every call to Cart\Cart >getProducts() reloads the entire cart from scratch. The more cart items you have, the more the load time starts to compound.

This is quite amazing considering the maturity and claimed scalability of OpenCart and a lot of opencart experts claiming nothing is wrong with the core code.
Nobody says anything about OC 3 stability, everybody says quite the opposite actually. And yes, there's nothing bad in the code, basic cart data is saved in database, which is more than enough. 130 products in the cart is a VERY specific situation, which should be addressed personally. If you have 500K+ products in your store, you will have more slowdowns in different situations and all of them you will have to address personally. OpenCart is NOT here to blame, no matter how badly you want it.

Re: Performance Problem when cart > 20 items

Posted: Sat Jun 15, 2019 4:15 am
by foobarac
thekrotek wrote:
Fri Jun 14, 2019 1:36 pm
foobarac wrote:
Fri Jun 14, 2019 8:05 am
There is no cache so every call to Cart\Cart >getProducts() reloads the entire cart from scratch. The more cart items you have, the more the load time starts to compound.

This is quite amazing considering the maturity and claimed scalability of OpenCart and a lot of opencart experts claiming nothing is wrong with the core code.
Nobody says anything about OC 3 stability, everybody says quite the opposite actually. And yes, there's nothing bad in the code, basic cart data is saved in database, which is more than enough. 130 products in the cart is a VERY specific situation, which should be addressed personally. If you have 500K+ products in your store, you will have more slowdowns in different situations and all of them you will have to address personally. OpenCart is NOT here to blame, no matter how badly you want it.
130 items was used as a bench mark, but definitely the performance starts to suffer from about 20 items in the cart.

And I was referring to the comments made above including yours pointing it to be my problem. Now you are saying the opposite.

There is no expectation of warranty on my side I have made about 100 code fixes already. However, if you bothered to understand what I am saying, basic cart data doesn't have to be rebuilt 6 times (standard OC 3 code and theme) because you are changing a screen.

The process and code around the cart processing should be refactored but that's up to the keepers.

At least now the problem is documented on the forum and a fix is available.

Re: Performance Problem when cart > 20 items

Posted: Sat Jun 15, 2019 4:21 am
by thekrotek
foobarac wrote:
Sat Jun 15, 2019 4:15 am
130 items was used as a bench mark, but definitely the performance starts to suffer from about 20 items in the cart.
Definitely NOT. Works perfectly with 20-40 items for me. Didn't try to add more.
foobarac wrote:
Sat Jun 15, 2019 4:15 am
And I was referring to the comments made above including yours pointing it to be my problem. Now you are saying the opposite.
Never said the opposite.
foobarac wrote:
Sat Jun 15, 2019 4:15 am
The process and code around the cart processing should be refactored but that's up to the keepers.
Considering that it fits 99.9% of store owners, I doubt it requires any fixing.
foobarac wrote:
Sat Jun 15, 2019 4:15 am
At least now the problem is documented on the forum and a fix is available.
Don't see any fix, only see a reference about some guy, who supposedly have a fix.

Re: Performance Problem when cart > 20 items

Posted: Sat Jun 15, 2019 5:03 am
by foobarac
thekrotek wrote:
Mon May 20, 2019 6:19 am
I'm afraid, the issue is on your side. Probably happens on a certain server configuration. I've added 30+ items to cart and it loaded just fine, didn't notice any drop in performance. Tested it on OC 3, PHP 7.2.
oh :choke:

It's up to the developer to release the code, he owns it.

Re: Performance Problem when cart > 20 items

Posted: Sat Jun 15, 2019 5:06 am
by thekrotek
I'm glad you learned the quoting on this forum, congratulations. Yet unfortunately I don't see any contradictions in this quote.