Closed connoti closed 2 years ago
There are definite room for improvements with those functions. I had intended on better using caching rather than rebuilding the list for each request.
Thanks for the reply! Is there something that you are aware of that could be a quick fix? The load was about 60-80 people but I could see how clicking around the site could really cause a lot of havoc here :)
I can't think of an easy quick fix. I believe most people that use this plugin have pretty small sites selling single items.
It is on my (long) todo list to work on improving performance, but I have limited free time available.
Hej James, have you found time to further improve the performance since then? Only asking because we are planning on using your plugin for high load situations as well and we want avoid bringing our servers down.
It should be slightly better because it only queries the session table when something needs to know the quantity instead of on every request but it's still not at a level I'd be happy with for a high load site.
What do you think would make sense here? Maybe to create a reduced_cart_item table which includes id's and virtual stock (and session id's?) of all products and which is constantly updated? Then you would not need to loop through all sessions but you could pick the right value directly from the database.... I'm currently going through your code, trying to contemplate what could be done...
It needs some major refactoring. The plugin was designed for WooCommerce < 3.0 and then when 3.0 came out I had to do some major hackery to get it to work properly. There are different actions/filters available now that would be better to use than the way it's working now.
I'm not a fan of adding another table for something like this. I'd probably use a transient to "cache" the virtual stock, anytime an item is added/removed/purchased delete the transient and let it be refreshed on the next query.
Really need some proper tests built out to test everything.
Sorry it's taken so long, but I just pushed out a new version that should solve this issue.
Hi James, First Thank You for this plugin! It has helped out my client 100% on his site.
Here is the situation though, he does weekly Flash Sales which brings the server down each week. New Relic is reporting that 2 components in this plugin are causing the issue. Specifically WC_CSR_Sessions::find_items_in_carts and WC_CSR_Sessions::quantity_in_carts
If you see the graphs below you can see the impact that this has on the server. BTW this is a Kinsta Server with 6 PHP workers so it's not a server resource problem. What are your thoughts on this to get this figured out?