How to Run Batch Processing with a Custom Drush 9 Command in Drupal 8
Batch processing is usually an important aspect of any Drupal project and even more when we need to process huge amounts of data.
The main advantage of using batch is that it allows large amounts of data to be processed into small chunks or page requests that run without any manual intervention. Rather than use a single page load to process lots of data, the batch API allows the data to be processed as number of small page requests.
Using batch processing, we divide a large process into small pieces, each one of them executed as a separate page request, thereby avoiding stress on the server. This means that we can easily process 10,000 items without using up all of the server resources in a single page load.