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

Notifications

Announcements

No record found.

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
    301,069 Super User 2025 Season 2 on at

    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

    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

    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
    237,953 Most Valuable Professional on at

    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
    301,069 Super User 2025 Season 2 on at

    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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 559 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans