NopCommerce 4.10 - High memory usage and how we've handled it

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 years ago
Nop-Templates.com wrote:
...

We found out that the changes to the Garbage Collection don't require rebuilding the Nop.Web project. It is possible to edit the Nop.Web.runtimeconfig.json file in the root folder of nopCommerce and change the "System.GC.Server" property to false. The file should look like this:

{
  "runtimeOptions": {
    "tfm": "netcoreapp2.1",
    "framework": {
      "name": "Microsoft.NETCore.App",
      "version": "2.1.0"
    },
    "configProperties": {
      "System.GC.Server": false
    }
  }
}


...

Regards,
Anton


Confirmed this made a huge difference on a 4.1 site on A2 Hosting. No re-compile required, just edit the .json file and restart the IIS application pool. The 4.1 site is much closer to our 3.9 site (also on A2, for comparison).

FYI, don't forget that first-time page loads will still be "slow" since they are being compiled. Even with that, these first-time loads are much faster than they were before the .json file edit. Going back to pages already compiled are almost instant now. Will have to see ow this change performs/degrades over time.

Also FYI to those somewhat-new to nopCommerce, don't be afraid to turn off any features, plugins, and options you don't need, as disabling each one should give back a fraction of load on the system. Many can be turned off through the admin screens (e.g. auto-complete on search bar), but as you are more comfortable, can also look at disabling certain elements in the HTML (and thus possibly javscript as well). As example, removing the Search bar made a difference on our home page load (even before this .json file edit).



Edit: So sorry, really didn't mean to double-post :-(
5 years ago
Andrei's fix for ef core has transformed the performance of my site, which was very poor beforehand.

J
5 years ago
Hi,

I have implemented the NopLazyLoader and can verify that the performance increased a lot. But the add to cart functionality throws an error.

If I comment out 'optionsBuilder.ReplaceService<ILazyLoader, NopLazyLoader>();' the add to cart functionality works again.

When NopLazyLoader is active I get the following exception (when adding a product to the cart):

System.ArgumentNullException
  HResult=0x80004003
  Message=Value cannot be null.
Arg_ParamName_Name
  Source=Nop.Services
  StackTrace:
   at Nop.Services.Catalog.PriceCalculationService.GetUnitPrice(Product product, Customer customer, ShoppingCartType shoppingCartType, Int32 quantity, String attributesXml, Decimal customerEnteredPrice, Nullable`1 rentalStartDate, Nullable`1 rentalEndDate, Boolean includeDiscounts, Decimal& discountAmount, List`1& appliedDiscounts) in C:\V\4.1\Libraries\Nop.Services\Catalog\PriceCalculationService.cs:line 535
   at Nop.Services.Catalog.PriceCalculationService.GetUnitPrice(ShoppingCartItem shoppingCartItem, Boolean includeDiscounts, Decimal& discountAmount, List`1& appliedDiscounts) in C:\V\4.1\Libraries\Nop.Services\Catalog\PriceCalculationService.cs:line 490
   at Nop.Services.Catalog.PriceCalculationService.GetSubTotal(ShoppingCartItem shoppingCartItem, Boolean includeDiscounts, Decimal& discountAmount, List`1& appliedDiscounts, Nullable`1& maximumDiscountQty) in C:\V\4.1\Libraries\Nop.Services\Catalog\PriceCalculationService.cs:line 644
   at Nop.Services.Catalog.PriceCalculationService.GetSubTotal(ShoppingCartItem shoppingCartItem, Boolean includeDiscounts) in C:\V\4.1\Libraries\Nop.Services\Catalog\PriceCalculationService.cs:line 619
   at Nop.Services.Orders.OrderTotalCalculationService.GetShoppingCartSubTotal(IList`1 cart, Boolean includingTax, Decimal& discountAmount, List`1& appliedDiscounts, Decimal& subTotalWithoutDiscount, Decimal& subTotalWithDiscount, SortedDictionary`2& taxRates) in C:\V\4.1\Libraries\Nop.Services\Orders\OrderTotalCalculationService.cs:line 750
   at Nop.Services.Orders.OrderTotalCalculationService.GetShoppingCartSubTotal(IList`1 cart, Boolean includingTax, Decimal& discountAmount, List`1& appliedDiscounts, Decimal& subTotalWithoutDiscount, Decimal& subTotalWithDiscount) in C:\V\4.1\Libraries\Nop.Services\Orders\OrderTotalCalculationService.cs:line 712
   at Nop.Web.Factories.ShoppingCartModelFactory.PrepareMiniShoppingCartModel() in C:\V\4.1\Presentation\Nop.Web\Factories\ShoppingCartModelFactory.cs:line 971
   at Nop.Web.Components.FlyoutShoppingCartViewComponent.Invoke() in C:\V\4.1\Presentation\Nop.Web\Components\FlyoutShoppingCart.cs:line 32
   at Microsoft.AspNetCore.Mvc.ViewComponents.DefaultViewComponentInvoker.InvokeSyncCore(ObjectMethodExecutor executor, ViewComponentContext context)
   at Microsoft.AspNetCore.Mvc.ViewComponents.DefaultViewComponentInvoker.<InvokeAsync>d__5.MoveNext()

At least I know that it is caused by shoppingCartItem.Customer being Null. The property does not get populated. But I dont know why it is working with the original LazyLoader and not NopLazyLoader. Everything else seem to work.

Regards
Patrik
5 years ago
Another customers doesn't have such problem.
5 years ago
foxnetsoft wrote:

Thank you foxnetsoft!

this dll fixed the problem for me.
5 years ago
pillbug22 wrote:
...

We found out that the changes to the Garbage Collection don't require rebuilding the Nop.Web project. It is possible to edit the Nop.Web.runtimeconfig.json file in the root folder of nopCommerce and change the "System.GC.Server" property to false. The file should look like this:

{
  "runtimeOptions": {
    "tfm": "netcoreapp2.1",
    "framework": {
      "name": "Microsoft.NETCore.App",
      "version": "2.1.0"
    },
    "configProperties": {
      "System.GC.Server": false
    }
  }
}


...

Regards,
Anton

Confirmed this made a huge difference on a 4.1 site on A2 Hosting. No re-compile required, just edit the .json file and restart the IIS application pool. The 4.1 site is much closer to our 3.9 site (also on A2, for comparison).

FYI, don't forget that first-time page loads will still be "slow" since they are being compiled. Even with that, these first-time loads are much faster than they were before the .json file edit. Going back to pages already compiled are almost instant now. Will have to see ow this change performs/degrades over time.

Also FYI to those somewhat-new to nopCommerce, don't be afraid to turn off any features, plugins, and options you don't need, as disabling each one should give back a fraction of load on the system. Many can be turned off through the admin screens (e.g. auto-complete on search bar), but as you are more comfortable, can also look at disabling certain elements in the HTML (and thus possibly javscript as well). As example, removing the Search bar made a difference on our home page load (even before this .json file edit).



Edit: So sorry, really didn't mean to double-post :-(


Thank you for sharing this information with other users on the forum. Very helpful!
5 years ago
a.m. wrote:
Maybe the problem in EF Core 2.10 bug.
https://github.com/aspnet/EntityFrameworkCore/issues/12451
Thanks. We've also made a new branch fixing this issue. Please find the commit here. It could be helpful for developers who can apply it manually


Has this fix been applied to the 4.1 no-source download files?
5 years ago
Yes.
Replace DLL file and restart your store.
4 years ago
I found the new EF Core 2.1 with memory leak

https://github.com/dotnet/efcore/issues/13513

EF Core 2.20 has the same issue.
4 years ago
Hello all, whilst still on 4.10, the tweak to "false" has made the front end of our site much faster, and has removed 2/3s of the memory usage almost instantly.

However, the admin of the site is now running much slower. Is there anybody else who has come across this? Or are there some generic tweaks that can be made to speed up the admin side?

The slowdown in admin speed has been since this tweak.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.