Closed timkelty closed 1 year ago
Is it also slow locally?
@lukeholder Will test today! Anything else I can log/test while i'm in there?
@timkelty I just tried adding this to the cart on your site, and got to 10+ but it didn't feel any slower?
@lukeholder were you testing on Commerce 3? We've since upgraded from 2 to 3 and haven't noticed it again yet, so perhaps its fixed.
I was using your website link. Let us know if it re-appears.
@lukeholder we prob upgraded by the time you checked :) I'll reopen if it happens again.
@lukeholder With the lastest Commerce, we are seeing this again.
It seems to happen when there are multiple promos enabled.
@timkelty What type of promotions? discounts or sales? I used the site and was able to add to cart from clicking the button to getting the confirmation it took about 1 second.
@lukeholder did you try adding several different items to the cart?
From my tests, it seems to be specifically line item based. That is, I click add to cart 15 times on the same line item, and it adds it in a second or two. But as soon as I start adding different line items, the time increases with the number of line items.
It seems to consistently add ~4 seconds for each line item.
discounts or sales?
There are several of both active, but I suspect discounts. There are current ~24 active discounts.
@lukeholder still experiencing this whenever discounts are active. Can you reopen?
Anything else you need from me to debug?
@timkelty Can you make this change to your project manually:
https://github.com/craftcms/commerce/commit/50d203af6c4fb73fc2d3787e053c05452cc7ac00
That change is currently on the develop branch and will be in the next release as a config option. Not sure it is the cause, but worth a try. Not sure how else you would be getting a delay when adding to cart.
@lukeholder That didn't do it…I deployed dev-develop to https://paddling-dev.fusionary.io/ and tested.
Here's videos of it clearly happening:
First, with the "Buy 2, Get 1 Free" discounts enabled: https://drive.google.com/file/d/1_yqFxcSHw3dpDlfJ5Q5EBBUTEQ5MYkXy/view
And then with those discounts disabled, everything is fine: https://drive.google.com/file/d/11Lg_cHP41DZc3GR4eEEBCt5Hr9uAvGP2/view
…so it seems pretty clear the discounts are causing it.
The specific discounts I'm toggling are "Buy 2, Get 1 Free - Clothing - n Shirts". There is a discount for n=3 through 15. They are configured exactly as shown here: https://github.com/craftcms/commerce/issues/1389
Can you send your DB dump/backup to support@craftcms.com so we can try and reproduce.
@lukeholder sent.
@lukeholder With this most recent fix (https://github.com/craftcms/commerce/issues/1389) it increased the time it takes to add to cart even more (to the point of being unusable).
I presume this is because more discounts conditions are being met.
It seems clear that the problem is in the calculation of the discounts when you add to cart.
Will test your DB today and see what we can do.
@timkelty We believe we have fixed this issue with https://github.com/craftcms/commerce/pull/1543
After more testing we will look to merge into the next release.
@lukeholder This did not address our issue at all (tried 3.1.11).
Calls to add to cart are still exponentially slow/unusable the more is in your cart, with the type of discounts mentioned.
@timkelty Can you update to the latest release and let us know if this is persisting? Will then re-open.
@lukeholder
I own the site where @timkelty was having issues and the issues still remain.
Currently running Craft 3.5.8 and Commerce 3.2.3
Hoping the the discounts being reworked (that were mentioned in #1725) offer a solution.
@lukeholder can you reopen this issue?
We are still seeing the exact same issue as before.
I also tested it with a much simpler discount (where a customer can purchase at a wholesale rate once the total quantity is above 20 or 50 items. The same, exponentially slower issues occur. If that discount is disabled, then the speed is as expected. Note I see the same speed issues if editing an order in the CP (works fine if a particular discount is disabled, if the discount is enabled, the process slows dramatically (or times out)).
FYI - @timkelty is no longer involved in this project but I can loop in the current dev for further investigation.
@paddling Happy to reopen. Can you please send us:
1) The database dump/backup to support@craftcms.com 2) your composer.json and composer.lock files used in your project 3) Steps to reproduce the slow cart (which products to add to cart, which discounts do you expect to see in the cart etc)
@paddling This has been fixed in 3.4.1 that was released on 2021-07-26
We have seen order recalculation go form 30 seconds to 2 seconds.
@lukeholder we are seeing this popping up again i think.
It seems to be restricted to the conditional field, if we add '@some-email.com' in order.email
it takes a long time.
It also applies to the shipping conditional field, that gets the same result in long add-time to cart.
It is both on frontend and when we save an order/cart in the backend, so adding a product to the cart in the backend goes fast.
There is a lot of custom modules stuff in this site, but i have tried to deactivate everything to be as clean as possible when testing this.
We are running: Craft CMS 3.7.17.1 Commerce 3.4.6
Hi @espensgr - thanks for reporting this. We did have to revert some of the caching on the discount matching in a recent release, and we kept caching limited to the heaviest condition (related categories) within the discount.
Having said that we can go further with individual caching of heavy conditions like the condition formula. Will add that back in the next release and report back here when it is out. Thanks.
@espensgr out of interest, how many discounts do you have set up?
Only one was enough, and with only one product in the cart. On shipping this is even worse as we can't segment on user groups like we can on discounts, so it affects all users.
We have about 2700 variants, so it is a pretty sized store, that may also have an impact on the discounts, but don't know the logistics behind the conditionals setup so it may not have any impact.
@espensgr do you have category conditions in your discount? Could you send me a screenshot of you discount conditions etc as set up in the control panel. Also, how many items in the cart?
No, it just made a default discount with '@some-email.com' in order.email
in the conditional field and one random variant to apply the discount.
On my local computer it goes from 2 sec to 6,5 sec for 1 item to be added to the cart when i activate the discount. And it grows for every discount activated. If i activate the discounts that the costumer has setup (7 discounts) the update cart gets 500 internal error, so it just times out.
Closing this issue. If you are experiencing performance issues still, please create a new issue with steps to reproduce along with an email to support@craftcms.com with a DB dump.
Adding a product to cart (via commerce/cart/update-cart controller) seems to get slower and slower the more is in the cart.
For example, with an empty cart, I get a response in under 1s. With 15+ items, it takes more like 8s: https://paddling.com/store
There are active discounts/sales going on, so that could also be a factor.
Any reason to think this would be fixed in v3?