title: Best practice to handle batch of long api calls
body: <p>I'm designing a user interface to upload a list of users (email, name, etc...) in which at the end of the process, each of these users are inserted my database and also received an email.</p>
  
  <p>The backend api that handles this task is built in ruby on rails.</p>
  
  <p>There is currently no limit to the size of the input, therefore I want to provide a way for the UI user to cancel the remaining jobs throughout the uploading process without cancel the jobs that is already sent. </p>
  
  <p>I also want to provide on the GUI real time status on which jobs are being worked on, already finished.</p>
  
  <p>In addition, I want to make sure the number of jobs spawned to simultaneously handle the jobs is limited so that other users on the server will not be affected.</p>
  
  <p>With that said... and with my limited backend / javascript knowledge, what I am thinking I would do is to spawn individual ajax calls for each user (or possibly a grouping of several users), using java to limit at any time only X ajax calls can be run simultaneously (I'm  hoping this is possible) and when each call returns I will update the UI to reflect the status of the job and then spawn another one for the next set of job until the whole thing is finished. If the UI user wish to cancel they can with the completed job remain complete.</p>
  
  <p>Would this be advisable or is there a better way to do this.</p>
  
  <p>Thanks in advance</p>