Until now there are two ways to handle batch processing in Drupal: Batch API, queue worker and cron tasks(although i count the last as one since they most likely will run due to server operations).
What good about Batch API? It run when you choose to and you can see the progress.
What bad about Batch API? When triggering it the user can go to somewhere else, he must hold still. If something failed, you need to start it all over again.
What good about queue workers? They run when the server go over the queue workers.
What bad about queue worker? Queue worker can be triggered by the server or manually, you can see the progress. If you want to do something very quick, i.e. sending a lot of emails at once, you need to wait for the server to trigger it. You can run the cron every minute.
I thought about another approach: JS script that will trigger a men item. That menu item will run the PHP function of your modules.
In case the JS didn't run all the batch process, maybe there are no active users in the site, there will be a queue worker that will finish all the remains batches.
Is there a place for that kind of module or maybe this approach can serve your site as well?
Comments
HTTPRL
I use httprl for background tasks that are time sensitive & thus the queue wouldn't work; they usually take some time to do 100ms+ and thus doing that work in the users page building thread isn't ideal. https://www.drupal.org/project/httprl
It doesn't have a batch worker; https://www.drupal.org/project/background_process does have one.