Hoping that someone might be able to give me a pointer in the right direction in solving an issue I have.
Currently the production environment consists of two load balanced webservers which house the umbraco instance with the store.
The store operates on a shopping basket principle, and the customer details are entered only when purchasing.
Currently there are instances where the basket contents change e.g. has three items, and you add another one and might return only 2 items or toggle between some items and no items.
I have a believe that it might have something to do with the load balancing. Has anyone run across this, and what did you do to resolve this?
I admit to being a merchello novice (first site constructed), here is the code that I have for adding an item to the basket, and returning the current basket.
public JObject AddItemToBasket(Dictionary<string, string> ProductInformation) {
string ProductKey = ProductInformation["ProductKey"];
int Quantity = int.Parse(ProductInformation["Quantity"]);
var merchello = new MerchelloHelper(false);
var product = ProductsService.GetByKey(Guid.Parse(ProductKey));
Basket.AddItem(product, product.Name, Quantity, SetItemExtendedData(product));
Basket.Save();
return GetBasketContents();
}
public JObject GetBasketContents() {
string ProductSku = string.Empty;
OrderResponse response = new OrderResponse();
response.Status = OrderResponse.OTLOrderStatus.Success;
response.BasketItems = Basket.Items;
//Loop through each Item in the basket and add the detached data to the response
foreach (var item in response.BasketItems) {
ProductSku = item.Sku.ToString();
if (!response.DetachedContents.ContainsKey(ProductSku)) {
response.DetachedContents.Add(ProductSku, GetProductDetachedContents(ProductSku));
}
}
return JObject.FromObject(response);
}
Sorry to hijack this thread and appreciate it's a bit old but my web searches have got me here... has anyone got Merchello working with Azure in a load balanced environment? i.e. using Redis cache and getting product changes to appear on the slave server (after making the changes in the master server).
I made it for an online shop for an international insurance company. You may take my mechanism as a reference.
To make it work, it may needs a change to Merchello's source code. Basically the key is to trigger Examine Indexes update on slaves. Merchello's source code have private/protected/internal handlers to update the index whenever there is product update, but they changes the CMS instance only, but not the slaves. You need to make use of these handlers, think of some mechanism to trigger them in salve instances as well when there's product update.
What I did is to change private/internal methods/models of Merchello to public, then write a Merchello Plugin to the modified Merchello make it support cloud multiple instance environment. You can try in the same way, but it certainly take timeeeeeeeeeeee.....
p.s. Changing private/internal methods to public aims to expose these useful methods to my plugins, so I don't need to pollute merchello's source code too much, but putting my code as plugin.
Load balanced environment and using basket
Hi,
Hoping that someone might be able to give me a pointer in the right direction in solving an issue I have.
Currently the production environment consists of two load balanced webservers which house the umbraco instance with the store.
The store operates on a shopping basket principle, and the customer details are entered only when purchasing.
Currently there are instances where the basket contents change e.g. has three items, and you add another one and might return only 2 items or toggle between some items and no items.
I have a believe that it might have something to do with the load balancing. Has anyone run across this, and what did you do to resolve this?
I admit to being a merchello novice (first site constructed), here is the code that I have for adding an item to the basket, and returning the current basket.
Thanks.
Every chance you're right. How are you managing the the session?
On a load balanced server setup you most likely want to use a session state server (SQL DB) to manage the session.
lol.. didn't even think to check that, but when I did it was fine.
Turns out the the "Cross-Zone" load balancing was enabled. When this was switched off, everything just started working as expected.
Something to keep in mind for the future :)
Thanks.
Hi Brad,
I can see you are using AWS here. Have you tried with Azure? I am having the exact same problem but my cloud provider is MS Azure.
Best, Daniel
It means you're using Azure App Service. Did you try enabling "ARR affinity" in Application settings?
Sorry to hijack this thread and appreciate it's a bit old but my web searches have got me here... has anyone got Merchello working with Azure in a load balanced environment? i.e. using Redis cache and getting product changes to appear on the slave server (after making the changes in the master server).
Thanks
I made it for an online shop for an international insurance company. You may take my mechanism as a reference.
To make it work, it may needs a change to Merchello's source code. Basically the key is to trigger Examine Indexes update on slaves. Merchello's source code have private/protected/internal handlers to update the index whenever there is product update, but they changes the CMS instance only, but not the slaves. You need to make use of these handlers, think of some mechanism to trigger them in salve instances as well when there's product update.
What I did is to change private/internal methods/models of Merchello to public, then write a Merchello Plugin to the modified Merchello make it support cloud multiple instance environment. You can try in the same way, but it certainly take timeeeeeeeeeeee.....
p.s. Changing private/internal methods to public aims to expose these useful methods to my plugins, so I don't need to pollute merchello's source code too much, but putting my code as plugin.
is working on a reply...