Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Paul Dermody 29 posts 106 karma points
    May 23, 2017 @ 16:35
    Paul Dermody

    How to get Merchello to read updates to products in a load balanced environment

    Hi all.

    I have my website running on two machines (A and B) and both are using the same database which resides on third machine (C). My problem is that when I update a product from the store in the back office of A, it does not update on B.

    I checked the front-end on B and it still shows the old product data. Surprisingly, if I open the back office on B, it shows the old value too! (Merchello back office is caching data?)

    I tried rebuilding the Merchello indexes on B, but to no avail. However, if I restart IIS on B then it will finally show the up-to-date product.

    I know that Merchello does not support load balancing 100% but the basket and purchasing seems to work. Also, I know that the best practice is to use only one Back Office machine separate from the front end web servers - we do in production. I am just trying to find a way to get both front end servers up-to-date when I update product information in the back office.

    What I am hoping to do is put some listener on the front end web servers that can perform some "magic" to get the product show up-to-date info. I thought that clearing caches and rebuilding indexes would do the trick, but I have not had any luck.

    Thanks! Paul Dermody.

  • Paul Dermody 29 posts 106 karma points
    May 26, 2017 @ 21:14
    Paul Dermody

    So, I think I found the solution on my own. It turns out that the ProductRepository class used by Merchello to manage the product information from the database has it's own internal and private cache. It is NOT using the Umbraco cache from the Application context so clearing these does nothing.

    This cache is used by the back office code so I will always see old data in the back office on Server B until I restart that server. That is fine, because I don't plan to use that server for back office functionality anyway.

    However, this cache is also by the code that rebuilds the Merchello index in Examine. Consequently, rebuilding the index on server B has basically no effect. (Though it will pick up new products.)

    To change this behaviour I need to provide my own ProductRepository, which means I need to provide my own WebBootManager. Once I do this, I can expose the cache used by the ProductRepository and clear products out of it as I please.

    Finally, if I add a listener to the back office on Server A that reacts to changes in products, and, I then piggy back on Umbracos distributed cache/flexible load balancing functionality, I can notify Server B of these product changes, update the product cache and Merchello index and away we go!

    It may seem like overkill but my client is keen to have the product updates propagated correctly to the FE servers. This is certainly simpler than moving from Merchello to some other store component.

    Regards, Paul.

  • Paul Dermody 29 posts 106 karma points
    May 27, 2017 @ 21:09
    Paul Dermody

    Well, it turns out that this is not so simple. I misread.

    Merchello has no mechanism for injecting a custom implementation of any of these core classes (WebBootManager and ProductRepository) which means the only way to modify the behaviour is to pull the Merchello source code into my source code.

    I would really rather not include Merchello code in my project. Does anyone know if there is any chance of making the cache used by the RepositoryFactory public, maybe via an accessor method in the ServiceContext where the RepositoryFactory is stored? Would this be breaking some important design pattern?

    All I want to do is let Merchello know when changes have occurred in the products that it is not yet aware of. Obviously, it would be better if Merchello supported Load Balancing fully on its own, but in the meantime, getting access to this cache will make some simple workarounds easier.

    Thanks, Paul.

  • Rhys Browning 2 posts 71 karma points
    Mar 22, 2018 @ 09:52
    Rhys Browning

    Hi Paul,

    Did you ever find a way to make the Merchello product cache refresh? I have an event listening on ProductService.Saved but can't figure out what the event needs to do to update the cache.

    Thanks, Rhys

  • suzyb 446 posts 820 karma points
    May 14, 2018 @ 10:30

    Hey, has anyone managed to figure our what needs done to get the product changes to propagate. We've just found the same issue with a site we're building.

  • suzyb 446 posts 820 karma points
    May 17, 2018 @ 11:03

    Quick update on what we eventually ended up doing.

    As our store was part of a larger site and didn't itself need to be load balanced we set up an alias for the store and had the load balancer direct that alias to the same server the CMS alias was directing to.

    With both front end and back end pointing to the same place it seems to have removed the issues we were finding with out of sync information.

  • Anatoliy 2 posts 72 karma points
    Jun 13, 2018 @ 15:01

    We need solution too.

Please Sign in or register to post replies

Write your reply to: