nopCommerce 1.7 cache not working?! Possible solution to 1.7 slowness?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 years ago
[email protected] wrote:

I had the same issue, and I spent a lot of time testing and figuting out what was wrong.

I finnally came to that solution:
I modified every Get method with a ById name to Detach the selected object


public static Product GetProductById(int productId)
{
...
  var context = ObjectContextHelper.CurrentObjectContext;
  var query = from p in context.Products
                    where p.ProductId == productId
                    select p;
  var product = query.SingleOrDefault();

  if (product != null)
       context.Products.Detach(product); // Possible as long as we use Attach() before performing updates

   return product;
}


In my Context it solves the problem and I then Cached the objects into the static cache.

Let me know if that solve the issue for you.


interesting work around! will give it a go and see.
13 years ago
did 1.9 address this adequately?
13 years ago
No, sadly.

We had to gut the particular pages that we cared that ranked on Google properly.  Our tire shops still get punished for slow page load times.  We were using the intrinsic SKU/Attribute mappings the way they should be done but now we are rolling each tire size out as their own products because we can't map product variants to categories specifically and because of the load times required to cache (and re-cache) the enter product catalog over and over again recursively.  Converting many of the temp tables procs to CTEs and other optimizations helped but not completely.

I just get the feeling that speed needs to be the #1 issue that gets tackled in 2.0
12 years ago
Hi,

I don't know if any of you guys managed to sort this cache problem out. I had the same problem last week. I made a template for nopcommerce which I am selling here.

Now the problem is that I have only added banners to the system and everything else is same except I am using ajax/jquery a lot using the same methods so that shouldn't matter on the speed. By the way I am using nop 1.9. Every thing was working fine until one of the customer upload around 1000 products which is not a lot in fact nothing and it shouldn't matter but the system was taking around 8/10 seconds to load each page. I started looking into it and implemented NopStaticCache then I got that duplicate error that entity already exist so you can't attach it in all the update methods.

The work around to that problem is to declare a the entity in the update and get from cache, such as this is category update method;


public void UpdateCategory(Category categoryRequested)
        {
            if (categoryRequested == null)
                throw new ArgumentNullException("category");

            Category category = _context.Categories.SingleOrDefault(x => x.CategoryId == categoryRequested.CategoryId);
            if (category == null)
                throw new ArgumentNullException("category");

            category.Name = categoryRequested.Name;
            category.Description = categoryRequested.Description;
            category.TemplateId = categoryRequested.TemplateId;
            category.MetaKeywords = categoryRequested.MetaKeywords;
            category.MetaDescription = categoryRequested.MetaDescription;
            category.MetaTitle = categoryRequested.MetaTitle;
            category.SEName = categoryRequested.SEName;
            category.ParentCategoryId = categoryRequested.ParentCategoryId;
            category.PictureId = categoryRequested.PictureId;
            category.PageSize = categoryRequested.PageSize;
            category.PriceRanges = categoryRequested.PriceRanges;
            category.ShowOnHomePage = categoryRequested.ShowOnHomePage;
            category.Published = categoryRequested.Published;
            category.Deleted = categoryRequested.Deleted;
            category.DisplayOrder = categoryRequested.DisplayOrder;
            category.CreatedOn = categoryRequested.CreatedOn;
            category.UpdatedOn = categoryRequested.UpdatedOn;
            category.ShowOnMenu = categoryRequested.ShowOnMenu;

            category.Name = CommonHelper.EnsureNotNull(category.Name);
            category.Name = CommonHelper.EnsureMaximumLength(category.Name, 400);
            category.Description = CommonHelper.EnsureNotNull(category.Description);
            category.MetaKeywords = CommonHelper.EnsureNotNull(category.MetaKeywords);
            category.MetaKeywords = CommonHelper.EnsureMaximumLength(category.MetaKeywords, 400);
            category.MetaDescription = CommonHelper.EnsureNotNull(category.MetaDescription);
            category.MetaDescription = CommonHelper.EnsureMaximumLength(category.MetaDescription, 4000);
            category.MetaTitle = CommonHelper.EnsureNotNull(category.MetaTitle);
            category.MetaTitle = CommonHelper.EnsureMaximumLength(category.MetaTitle, 400);
            category.SEName = CommonHelper.EnsureNotNull(category.SEName);
            category.SEName = CommonHelper.EnsureMaximumLength(category.SEName, 100);
            category.PriceRanges = CommonHelper.EnsureNotNull(category.PriceRanges);
            category.PriceRanges = CommonHelper.EnsureMaximumLength(category.PriceRanges, 400);

            //validate category hierarchy
            var parentCategory = GetCategoryById(category.ParentCategoryId);
            while (parentCategory != null)
            {
                if (category.CategoryId == parentCategory.CategoryId)
                {
                    category.ParentCategoryId = 0;
                    break;
                }
                parentCategory = GetCategoryById(parentCategory.ParentCategoryId);
            }

            
            if (!_context.IsAttached(category))
                _context.Categories.Attach(category);

            _context.SaveChanges();
            
            if (this.CategoriesCacheEnabled || this.MappingsCacheEnabled)
            {
                NopStaticCache.RemoveByPattern(CATEGORIES_PATTERN_KEY);
                NopStaticCache.RemoveByPattern(PRODUCTCATEGORIES_PATTERN_KEY);
            }
        }


Update all update routines and this solves the problem of using NopStaticCache. Then there was another problem of w3wp process going up to 600mb and website throwing out of memory exception. The work around is to restrict w3wp to whatever you want, I restricted it to use 200mb and the website was working fine. Now if the process goes over 200mb IIS recycles it and doesn't make any difference on the website as It doesn't recycle the process completely, only so it don't go over 200mb or whatever limit you have.

Please have a look at http://www.wholesalecontractfurniture.com/manufacturer/6-woodardfurniture.aspx, this page is loading 578 records using the famous loadallpagedproducts procedure and it works like a charm.

Regards,
Atiq
12 years ago
I have bought your theme already and get a bonus speed upgrade too. great :)

Where did you set this limit?
12 years ago
ajhvdb wrote:
I have bought your theme already and get a bonus speed upgrade too. great :)

Where did you set this limit?


you set this in application pools, select pool, advance settings, Private Memory limit in kb and virtual memory limit in kb. I am not really expert in IIS but this worked.

Regards,
Atiq

I have also noticed that since I have set the recycle pool, it doesn't really use much memory so may be before it was some other problem but I don't care since the problem is fixed and website is much more speedy, in fact it's instant.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.