Parallel Execution of JavaScript remoting calls

I was hoping to be able to fire off multiple JavaScript Visualforce remoting calls in parallel and have the execute simultaneously, and for me to deal with the responses asynchronously.

Whilst in practice I can fire these off and get the reponses back (in a random order, as expected) I notice that the execution time of the responses increases for each request that is returned. So much so, in fact, that it is not much quicker to force sequential running of the individual calls.

This graphic shows 3 tests;

  1. Running 3 calls in parallel with the “buffer” param set to true
    (so VF remote calls are batched in one HTTP request)
  2. Running 3 calls in parallel with the “buffer” param set to false (so VF remote calls are sent in parallel as separate requests)
  3. Running 3 calls
    in sequence using JavaScript promises.

Vf remote tests

As you can see with (2) the second call that returns takes 2x as long as the 1st, and the 3rd call takes 3x as much… which leads me to think that although I’m firing the calls in at the same time they are actually being queued and run in sequence.

Does anyone know if this behaviour (in (2)) is to be expected or if there’s a way to make the calls run more simultaneously?


Actually, I had the same issue in one of my implementation and I found out it was sequential but asynchronous (crazy though). But managing the sequence can be handled by us setting some cookies which I did.

Creating a cookie on init and setting it back to some final value after callback helps us to poll and perform the action only when required.

On other side, I have seen during this polling resources do become available but we force the system not to make any call out by forcing it to be on wait mode till required value is set. The above is true for both buffer=false and buffer = true. If you watch the consolidated time for buffer= true its (26.xx s) and when buffer = false (total time for the third request is 24.xx s) which is including the Pending wait state.

Source : Link , Question Author : Todd Halfpenny , Answer Author : Adrian Larson

Leave a Comment