Raremile Technologies

Outsourced IT services for complex software development

  • Offerings
    • Technology Research
    • Text Mining & Analytics
    • Algorithms & Machine Learning
    • Retail Innovation
  • About Us
  • Clients
  • Thinking
    • Blog
    • Whitepapers
  • Careers
  • Contact
You are here: Home / Consulting / Best practices to follow on e-Commerce sites to avoid deadlock and other challenges

Best practices to follow on e-Commerce sites to avoid deadlock and other challenges

22 April 2023 by site-admin

Best practices to follow on e-Commerce sites to avoid deadlock and other challenges
Recently some of our developer colleagues were having sleepless nights – a week before Black Friday fixing issues for a couple of our clients’ sites which run a high volume of promotions and discounts.  The site’s performance testing had revealed that something was not right in the code as the performance times had shot up big time and there were inconsistent responses.  So, the developers were asked to own the issue and fix it. And on review of code by a senior developer, it was clear that the code was not written in accordance to the best practices to run a higher load e-commerce websites.This issue typically goes unnoticed during non-peak times as most often not enough performance testing happens just before the peak season.  There are enough pressure to take the site live and project managers normally tend to give peak performance testing a low priority unless the go live is close to peak season.

Why do sites perform poorly at peak season? During peak hours, lot of people would be placing orders and most often (due to discounts, promotions etc.), people would be buying the same product at the same time. So, what is the issue if people try to place an order on same product at the same time? In IT terms, if two threads are trying to access and concurrently update the same object at the same time, one can get into locking and transaction related issues. Impact of this would be that an attribute of an object may wrongly get update or may not get updated leaving it in an inconsistent state. In extreme cases, it can lead to deadlock and potentially bring down the servers and hence the site.

If we are using a sophisticated product such as ATG, handling concurrent updates is absolute necessary. Specifically, in ATG, there are few things we should keep in mind and force in the code while developing/implementation. Lets look at them:

–          Use Simple cache modes for user, order etc. item descriptors, as these will not be generally accessed and changed from multiple servers. Avoid using locked caching modes for custom item descriptors. Also, use distributed modes for item descriptors, which are constantly accessed and changed through multiple servers.

–          ClientLock Managers and ServerLock Manager are to be configured correctly (address and port). If their configurations are incorrect then the sites can behave in a crazy manner and also will be really difficult to debug.

–          Scheduled Jobs running at a shorter interval or jobs, which are needed to run on a single instance at a time, should be using SingletonSchedulableService. This will make use of the ClientLockManager of a cluster to take and release local locks before and after the scheduled task. It will also release the lock even if the job fails, thus making sure that anything in not stuck at any place. This helps in two ways

  • It will take care for not starting a job on the same instance if the first job is not completed.
  • It will also not start the job on any other instance on the cluster if it is running on any one of the instance in the cluster
  • Some of the jobs, which should be developed using this are: sending messages for order fulfillment or shipment, periodic report generation etc.

–          Always use a Transaction Demarcation whenever doing a database operation. If items are updated without the demarcation it will also be costly on the performance of the system, as for every update system will automatically create a demarcation, begin a new transaction, update the database and finally commit the transaction and if an update fails the code will not be able to rollback the earlier updates. Avoid using TransactionDemarcation.RequiresNew at the begin of the transaction and always ends the TransactionDemarcation in the finally block.

–          Always use correct steps to update an order. This is mandatory for any ATG application but sometime developers miss these for a particular scenario. PurchaseProcessFromHandler’s beforeSet and afterSet methods handles few steps out of the box, but if order update is done outside the scope of PurchaseProcessFormHandler all the steps need to be built and followed accordingly.

Consulting, Ecommerce, Performance Engineering

Search Form

Recent Posts

  • What is sort by relevance anyway? 8 October 2023
  • Machine Learning: Supervised or Unsupervised 7 October 2023
  • SQL vs. NoSQL: Which is better? 11 September 2023

Tag Cloud

Android API Architecture Big Data Consulting Database Ecommerce Gestures iOS Machine Learning Mobile NoSql Performance Engineering Programming Raremile Search Startups Unstructured Data Analytics User Experience

Offerings

  • Technology Research
  • Text Mining & Analytics
  • Algorithms & Machine Learning
  • Retail Innovation

Recent Posts

  • What is sort by relevance anyway? 8 October 2023
  • Machine Learning: Supervised or Unsupervised 7 October 2023
  • SQL vs. NoSQL: Which is better? 11 September 2023

Global Locations

Canada
2601 Matheson Blvd E,
Unit 43 Mississauga
ON L4W 5A8
P: +1 647-607-5474
E: canada@raremile.ca
Canada
1275 Finch Ave WNorth York,
Unit 202
ON M3J 2G5
P: +1 647-607-5474
E: canada@raremile.ca
India
L-29 1st Floor, 2nd A Main,
14th Cross, 6th Sector,
HSR Layout, Bangalore, India 560102
P: +91 80 25724590
E: india@raremile.ca

Copyright © 2025. Rare Mile Technologies. Canada. All Rights Reserved.