Job Parallelization
Overview
Salesforce allows the parallel execution of jobs. However, the following constraints are applicable:
Any job can be parallelized based on the Thread API Name in the job query. See Jobs Eligible for Parallelization.
The number of instances of a batch job that can be run in parallel is derived from the Instances field that is specified while creating a job. A maximum of five instances can be run in parallel.
For example, if 40,000 records are to be processed, and the number of instances is 4, then, in each instance, 10,000 records can be processed. If the permitted batch size is 1,000, then in each instance, 10 (10,000/1,000) batches are executed.
While parallel execution of jobs results in improved performance, the performance is not linearly scaled. For example, having five parallel instances does not result in a 500% improvement in performance.
Prerequisites
None.
Steps
To run parallelization:
Log in to your Salesforce account.
Click Setup.
Search for
custom settings
, and then click it.Click Org Parameters with Namespace Prefix as loan.
Click Manage.
Click Edit.
Specify the value of the Concurrent Batch Jobs field, and then click Save.
For example, if you want to run five instances of the job in parallel, then the value of this field must be 5.
Note:The value of this field must be greater than 1.
Click the App Launcher, and search for
DAG Schedules
.Click the default DAG of the job that requires parallelization.
For example, click DAG-00002 as highlighted in the following image:
Click the required job in the Related section.
For example, click J-00028 (Start of day Dynamic job) as highlighted in the following image:
Click Edit.
Specify the value of Number Of Instances.
For example, if you want to run five instances of this job, then the value of this field must be 5.
Note:The value of the Number Of Instances field must be equal to the value in the Concurrent Batch Jobs field and must be greater than 1.
The default value of this field is 1. If the value of the Number Of Instances field is 1, then all the contracts run in one instance, and not parallel.
Specify the API name in the Thread API Name field.
For example, if you are using the Default DAGs, the value of this field can be loan__job_thread_count__c.
Note:The value of loan__job_thread_count__c is populated during loan contract creation. Its value can be 1, or 2, or more. For example, if there are 2 instances, then the instance 1 will pick all the loans with thread count as 1, instance 2 will pick all the loans with thread count as 2. This is how parallelization is achieved.
Disable the Abort Multiple Instances flag.
Click Save.
Default Jobs Eligible for Parallelization
The following table lists the jobs (with their corresponding thread API names) that can be parallelized:
Job Name | Thread API Name | Class Name |
---|---|---|
ProtectClaimBillWaiverDynamicJob | loan__CL_Contract__r.loan__job_thread_count__c | |
SuspendACHForProtectClaimDynamicJob | loan__CL_Contract__r.loan__job_thread_count__c | |
BillingAmzDynamicJob | loan__job_thread_count__c | |
BillingIOADynamicJob | loan__job_thread_count__c | |
InterestPostingDynamicJob | loan__job_thread_count__c | |
FloatingRateInterestRevisionDynamicJob | loan__job_thread_count__c | |
DelinquencyProcessingDynamicJob | loan__job_thread_count__c | |
CreditBureauPaymentHistoryDynamicJob | loan__job_thread_count__c | |
AmortizationProcessingDynamicJob | loan__job_thread_count__c | |
LoanDepositPaymentCreationDynamicJob | loan__job_thread_count__c | |
BrokerCommissionDisbDynamicJob | loan__job_thread_count__c | |
ACHProcessingDynamicJob | loan__job_thread_count__c | |
BillingLocDynamicJob | loan__job_thread_count__c | |
BillingDynamicJob | loan__job_thread_count__c | |
PeriodicChargeDynamicJob | loan__job_thread_count__c | |
PayOffGeneratorDynamicJob | loan__job_thread_count__c | |
IoaCreationDynamicJob | loan__job_thread_count__c | |
InterestPostingAmzDynamicJob | loan__job_thread_count__c | |
BrokerPayoutDynamicJob | loan__job_thread_count__c | |
ExcessForAmzBasedLoansDynamicJob | loan__job_thread_count__c | |
LoanPaymentTransactionCreationDynamicJob | loan__job_thread_count__c | |
StartOfDayDynamicJob | loan__job_thread_count__c | |
LoanRescheduleDynamicJob1 | loan__job_thread_count__c | |
ChangeInterestRateDynamicJob | loan__job_thread_count__c | |
LateChargeCreatorDynamicJob | loan__job_thread_count__c | |
LoanPaymentTxnClearingDynamicJob | loan__Loan_Account__r.loan__job_thread_count__c | |
CreditACHProcessingDynamicJob | loan__Loan_Account__r.loan__job_thread_count__c | |
LoanBlockCodeExpiryProcessingDynamicJob | loan__Loan_Account__r.loan__job_thread_count__c | |
Accrual Entry Job | loan__job_thread_count__c | loan.AccrualEntryDynamicJob |
Fee Accrual Entry Job | loan__job_thread_count__c | loan.FeeAccrualDynamicJob |
Frequently Asked Questions (FAQs)
What happens if you change the Number Of Instances?
If you change the value of Number Of Instances from, say, 5 to 4, the records with thread number 5 will not be processed by the job. The number of instances must be in sync with the thread numbers you have on records. However, if number of instances is 1, you need not worry about thread number on contracts.
What happens if the Thread API Name is not given?
If the Thread API Name is not given, DAG will not use the optimized way to divide the records among threads, and you will encounter the system limit exceptions such as "CPU Time Exceeded" and "Heap Limit Exceeded."