Batch API times out when running a single operation I'm trying to print ~100 nodes worth of content (Performance Plans) out to the private file system using the batch API. My process works perfectly up until about 10 of them and then times out. The timeout page happens before it even gets to the batch page with the progress bar. It appears to me like it might be running all 100 as a single batch vs breaking them up. I'm not sure exactly what I'm missing... Any help would be greatly appreciate.

BulkPrintForm.php 

&lt;?php
 namespace Drupal\bulk_print_to_files\Form;
 use Drupal\Core\Form\FormBase;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\node\Entity\Node;
 use Drupal\Core\Url;
/**
 * Class BulkAddForm.
 *
 * @package Drupal\create_perf_plan_for_new_year\Form
 */
class BulkPrintForm extends FormBase {
  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'bulk_print_form';
  }
  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $form['bulk_add'] = array(
      '#type' =&gt; 'submit',
      '#value' =&gt; $this-&gt;t('Print Performance Plans'),
    );
    return $form;
  }
  /**
   * {@inheritdoc}
   */
  public function submitForm(array &amp;$form, FormStateInterface $form_state) {
    $nids = \Drupal::entityQuery('node')
      -&gt;condition('type','perf_plan')
      -&gt;condition('field_performance_plan_year', 18)
      -&gt;range(0, 100)
      -&gt;sort('created' , 'DESC')
      //-&gt;condition('nid', 6273)
      -&gt;execute();
    //$year = "1920"; //$year being left here as an example of passing a variable to the bulk process. Not currently in use.

    $operations = [];

    foreach ($nids as $nid) {
      $operations[] = [
        [
          $this-&gt;batchFunction($nid),
          [$nid]
        ],
      ];
    }

    $batch = array(
      'title' =&gt; t('Bulk Print happening within the Bulk Print Form file...'),
      'operations' =&gt; $operations,
      'progress_message' =&gt; t('Processed @current out of @total. Estimated time: @estimate.'),
      'init_message'=&gt; t('Performance Plans are being printed to the private directory!'),
      'finished' =&gt; '\Drupal\bulk_print_to_files\BulkPrintNode::bulkPrintFinishedCallback',
      'error_message' =&gt; t('The migration process has encountered an error. (Make sure the folder you are placing these in exists!)'),
    );
    batch_set($batch);
  }
  function batchFunction($nid) {
    $print_engine = \Drupal::service('plugin.manager.entity_print.print_engine')-&gt;createSelectedInstance('pdf');
    $print_builder = \Drupal::service('entity_print.print_builder');
    $path = 'private';
    $filename = "perfplans/{$nid}.pdf";
    $nodes = \Drupal::entityTypeManager()-&gt;getStorage('node')-&gt;load($nid);
    $uri = $print_builder-&gt;savePrintable([$nodes], $print_engine, $path, $filename);
  }
}


BulkPrintNode.php

&lt;?php
namespace Drupal\bulk_print_to_files;
use Drupal\node\Entity\Node;
use Drupal\Core\Url;

function bulkPrintFinishedCallback($success, $operations) {
    if ($success) {
      $message = 'Performance plan printed.';
      $type = 'status';
    }
    else {
      $message = t('Encountered an error during bulk performance plan creation.');
      $type = 'error';
    }
    drupal_set_message($message, $type);
  }
}


Is there a way to limit these to say doing 5 at a time and then moving on to another set? Im under the impression I just have the batching process setup incorrectly.
In BulkPrintForm::submitForm() you invoke batchFunction method by calling it directly via $this-&gt;batchFunction($nid) line. This will effectively skip the batch API and run it for all nodes. You should pass the callback instead, check http://cgit.drupalcode.org/examples/tree/batch_example/src/Form/BatchExampleForm.php#n93