Scenario: We have a custom catalog import scenario that we have already in place which uses commerce minion to import. We have observed that as the number of catalogs increase (roughly more than 5000 records), the process slows down even though it's an async update and takes hours together which brings down CM and CD server frequently.

Anyone who faced this before can throw some light on where to start debugging from?

1 Answer 1


I am working on a project where we have around 15k products. Earlier I was also facing performance issue in import process. I found the performance issue was due to using same context in every command. So I had revised the code to use a new context every time and disposing it after. For ex. below one is the common function which I am using to create a new context.

private CommerceContext GetContext()
        return new CommerceContext(this.GlobalContext.Logger, this.GlobalContext.TelemetryClient)
            GlobalEnvironment = this.GlobalContext.GlobalEnvironment,
            Environment = this.GlobalContext.Environment,
            Headers = this.GlobalContext.Headers

Below code example to call this function;

var currentContext = this.GetContext();

Below code example to dispose this context;


Please try if it helps!

  • Thanks, Khushant, I dispose of the commerce context already in my current code. Seems like its lagging when code tries to create catalogs using various pipelines.
    – Madhav
    Commented Aug 13, 2021 at 14:59
  • Even for the pipeline please use new context every time. Overall please create a new context every time inside your custom function, commands and blocks to call any custom or OOTB command or pipeline. Also, add logs at start and end of every custom function, commands and blocks to track the time taken by each process. It will help to narrow down the scope where exactly you need to focus. Commented Aug 15, 2021 at 3:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.