How achive serving multiple concurrent Ajax / Rest calls in plugin?


I am developing a plugin that does at some point gather a bunch of data from a bunch of other servers.

So for each of these servers, there will be one ajax call in the frontend that expects xhr fields beeing returned as status updates on the progress like this:

Starting phase 1
Phase 1 done
Starting Phase 2

In the backend, the same function is loading the data via another rest but this is working fine. Simple Version here:

public function loader($args){
  $this->mysql($pdoinfo);      //excpects pdo connection information
  $this->connector($onninfo);  //then get all the data from the other database
  $this->migrateToDb($data);   //migrate the processed data into wordpress database

  //prints out progress via ob_flush() looks like above

The problem I found is that either with admin-ajax or WordPress rest API I can only serve 1 concurrent call at the same time.

Before I implemented these WordPress internal functions I had a simple connector.php in the plugin folder that did the same but outside the WordPress functionality. This one could do 6(I guess this is only my browser limit) at the same time. But it was outside of the WordPress scope so I could not use the WordPress functions.

Is there any way with WordPress API I can achieve the same performance?
Or did I already fail when it comes to approaching this problem?

, , Carlos Wedding 3 years 2019-10-29T08:18:32-05:00 0 Answers 69 views 0

Leave an answer