web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Multithreading

(0) ShareShare
ReportReport
Posted on by 85

Hi Team 

I have implemented multithreading in D365 Finance for one of the process, but looks like the process is running approx for more than 10 thousand records - it means my code is creating 1 Batch job with 10,000+ tasks in it.

Does this sound okay ? Because I see that batch job gets stuck and taking more than 2-3 hours to process the records.

Do you suggest to create multiple batch job header and add task (by dividing number of tasks as per the record count) ??

Please provide your valuable suggestions... 

Thank you!

I have the same question (0)
  • Suggested answer
    André Arnaud de Calavon Profile Picture
    299,327 Super User 2025 Season 2 on at
    RE: Multithreading

    Hi Rahul,

    It depends on the tasks you perform in this batch thread. If you are updating records, ensure there will be no database locks; otherwise you will end up with an even larger execution time. You can indeed create multiple tasks. It would be an idea to make the bundle size or number of tasks configurable. Then you can try out multiple settings to see what would be optimal for your environment.

    For your information the workflow processing batch job is creating tasks in bundles of 100 workflow instances. This is hard-coded. In one situation, we had performance issues with the workflow due to the number of legal entites, workflow configurations, complexity, etc. To solve these issues, I did propose to create workflow groups and made the bundle size configurable per workflow group. It solved the pains at this customer.

  • RahulD365 Profile Picture
    85 on at
    RE: Multithreading

    Thanks for the reply Andre!

    When you say - "You can indeed create multiple tasks.", Does this mean - I need to create bundle size like 1000 tasks per batch(as a an example)

    Suppose I have 10,000 records in my process - so you're suggesting to create 10,000/1000 = 10 batch headers and 1000 tasks in each batch header?? please confirm - because that's what I'm planning as well.

    Do you have any sample scenario (X++) where they are looping bundle size, or create multiple batch headers and tasks underneath ....

  • Suggested answer
    Sumit Loya Profile Picture
    2,230 on at
    RE: Multithreading

    Hi Rahul,

    Ideally you should never create more multi threaded tasks than maximum batch thread otherwise other threads would not execute simultaneously.

    You are correct that you should limit number of tasks per batch header. Look at Project invoice posting in Batch in uses similar multi threaded concept for posting.

    You can refer following blog for better understanding

    Art Of Creation – Dynamics AX Blog » Batch multithreading

  • Suggested answer
    Martin Dráb Profile Picture
    236,320 Most Valuable Professional on at
    RE: Multithreading

    If processing a single record doesn't take much time, the infrastructure to schedule and execute a task will take more time than the actual work, and you'll add this overhead ten thousand times. Therefore your process would consime much more resources and it might even compete later than if you just processed all records sequentially.

    Using multiple batch headers wouldn't make any difference - you would still have ten thousand tasks.

    What you should do is letting a single task process multiple records.

  • Suggested answer
    André Arnaud de Calavon Profile Picture
    299,327 Super User 2025 Season 2 on at
    RE: Multithreading

    Hi Rahul.

    You should not create 10 batch headers and 1000 tasks per header. Have a look at the workflow message processing batch job as an example. There is one batch job with one task. When the processing batch job is executed, it will create additional tasks for workflow messages in bundles of maximum 100. This is the example you can learn from. I suggested to make the bundle size or number of tasks configurable.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,122

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 918 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 646 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans