How Batch Works Around the PHP Timeout The Drupal 7 documentation introduces the Batch API as:


  Functions allowing forms processing to be spread out over several page
  requests, thus ensuring that the processing does not get interrupted
  because of a PHP timeout...


I took this to mean that Batch handles the timeout-related issues for the developer.  

However, other posts (ie. How does the batch API work internally?)
imply that it is the developer's responsibility to tell Batch how much work to do before waiting for another user to arrive and Batch to be invoked again --- thereby avoiding the timeout.  

If the latter is true then I assume Batch does not guarantee that jobs won't be timed out. Does Batch provide any guarantees? Is it up to the developer to guess how much Batch can process before timing out?

Thank you!
Batch simply says "I will do N number of things (at most) and then do a page refresh ... and do more."

If you say do 5 items per job chunk that take 5 seconds each you would be fine with the default php timeout value of 30 seconds.

If you say do 20 items per job chunk that take 5 seconds each, your workload per request is too high and will likely timeout.

Remember when your in PHP the lifecycle of a page is request in -&gt; response out. And that your webserver keeps each thread alive for a finite amount of time. You have to work around that timeout -- which the Batch API helps you do.

Running stuff from say Drush, server side using community modules such as Migrate can help you completely avoid timeouts if need be.

EDIT

Also bear in mind that every page request is a full drupal bootstrap and Batch API picks off where it left off. That is one of the most expensive operations when using the Batch API, reloading drupal every N items. That's why people have been working on server side techniques to create nodes, import content, etc. Batch API is great for simple, repetitive tasks. But it tends to fall apart in either complex, or very very large datasets.