+ Start a Discussion
eswar R 1eswar R 1 

What is asynchronous process and why it is needed

Amit Singh 1Amit Singh 1
Hello,
Asynchronous process means that particular code will run when resources will be free. If there are many records in any Salesforce Org for example more than 5 million and you need to process all these records use asynchronous process to precess these records. As Salesforce runs in a Multitenant platform and it reaches to governor limit very easily so to avoid the error we use asynchronous process which increases the governor limit.

Synchronous
In simple terms you can assume Synchronous as Sequential. In Synchronous process the thread waits for the task to be completed and then moves to the next task Sequentially. All the tasks are completed in a single thread.

The common example of a Synchronous apex is Trigger.

Asynchronous
In Asynchronous apex the thread does not waits for the task to be completed to move on to the next task. The tasks are run in different threads all together. These threads run in independent silos whenever the system is free.

Most common example is the Future annotation

Asynchronous process includes .
1) Apex Batch
2) Future MEethod.
3) Quable Batch

Refer below links and you will get the correct answer.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_System_Queueable.htm?search_text=queueable
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_invoking_future_methods.htm?search_text=future
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch_interface.htm
http://salesforce.stackexchange.com/questions/112686/is-it-possible-to-call-batch-from-a-future-call
https://developer.salesforce.com/forums/?id=906F0000000kA7sIAE

Hope this helps :)
Thanks!
Amit Singh
NagendraNagendra (Salesforce Developers) 
Hi Eswar,

An asynchronous process is  job or function that doesn’t have direct interaction with user. Suppose you have implemented SFDC for a mobile company and the company has millions of customers using its services. Company decides to flag those customers as inactive that have not recharged in the last one year. For this you can create a nightly job (usually by a batch job) to do this activities. Here this job runs in the background and doesn’t have direct interaction with user.
Salesforce provides various way of implementing asynchronous processes –
Asynchronous Apex (@future Apex, batch Apex, queueable Apex, scheduled Apex)
Bulk API jobs
Scheduled Reports
Dashboard refreshes 
Out of these @future annotation gives developers an option to run a apex method asynchronously
 
The best part of use of asynchronous process is that you get increased limit on some of the governor limits. e.g. Total number of SOQL queries issued for each apex transaction is 200 for asynchronous processes (while it is 100 for synchronous)
 
You can learn more about asynchronous processes in SFDC at this link –
https://developer.salesforce.com/page/Asynchronous_Processing_in_Force_com
 
Hope this helps.

Regards,
Nagendra.
eswar R 1eswar R 1
Thank you nagendra