I have an Apex REST webservice that creates a contact and a community user when being called with some input data (username, email etc.).

I need to import about 20k users. I want to save processing time and execute the code in parallel, so instead of calling the service serially, I would call it multiple times in parallel. Is this possible in Apex?

I read that these parallel imports are possible only using Bulk API, otherwise any code (even Queueable, Batch or @future annotated) will always run serially. Can you give me some advice?

  • No, Queueable, Batch and @future do not always run serially. Advice: read the docs and do a search here, this subject has been well covered. For example: salesforce.stackexchange.com/questions/395123/…
    – identigral
    Feb 7, 2023 at 16:40
  • @identigral The link you posted is related to this topic, however it does not answer it directly. Advice: please read the question carefully before answering next time.
    – DevelBase2
    Feb 7, 2023 at 17:54

1 Answer 1


A single Apex transaction runs serially, but multiple asynchronous transactions (e.g. many Queueables and future calls) can run concurrently as long as resources permit. However, it would probably be better to use the Bulk API for bulk transactions, as you'll probably get the best performance that way. However, you can also write custom components, Visualforce pages, etc to call the code in parallel, which may be even better in performance. See the Hyperbatch as an example of how leaving the UI open can actually provide a better experience than anything Apex alone could hope to deliver.

  • Thanks a lot fox! I imagine we could run a Batch job to enqueue Queueable jobs to call this apex webservice. I will also check the link you provided.
    – DevelBase2
    Feb 7, 2023 at 16:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .