> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stackshift.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Batching, retries and delays

> How batch size and wait, retries, retry delays, concurrency and delivery guarantees work.

> [!TIP]
>
> **Live.** This area is documented as current, user-reliable behavior.

## Goal

Tune delivery for your consumer and make it safe for repeats.

## Prerequisites

* A queue with a consumer

## Workflow

**Step 1**

Start with the defaults: batch size 10, batch wait 5 seconds, 3 retries, auto concurrency.

**Step 2**

Raise batch size when each message is cheap; lower it when each is slow.

**Step 3**

Set a retry delay that gives a failing dependency time to recover.

**Step 4**

Cap concurrency if your consumer or a downstream service cannot take more parallel batches.

## Batches

* A batch is sent when it reaches batch size (1 to 100) or when batch wait runs out, whichever comes first.
* Function and HTTPS push consumers get batches as they fill. Pull consumers set their own batch size per pull.

## Retries

* attempts counts deliveries, including the current one: the first delivery shows 1, and a message never delivered shows 0 in the message list.
* Retry one message with a delay in the reply (push and Function) or in the ack call (pull). Without a delay, the consumer's retry delay applies.
* A failed batch (throw, non-2xx, timeout) retries every message in it.
* max\_retries counts retries after the first delivery, so max\_retries 3 means up to 4 deliveries. After that (up to 100 retries) the message goes to the dead-letter queue, or is deleted when there is none.

## Delays

* A message sent with delay\_seconds, or under a queue default delay, stays delayed until then. Delayed messages count in the backlog but are not delivered.
* The longest delay is 86,400 seconds (24 hours).

## Concurrency

* Auto (0) adds batches in flight as the backlog grows and removes them as it drains.
* A cap from 1 to 250 limits batches in flight. Use 1 when messages must be handled one batch at a time.
* The queue page shows how many batches are running now.

## Guarantees

* At least once: a message can be delivered more than once, for example after a timeout. Use the message id, or your own business key, to skip repeats.
* Ordering is best effort. Do not rely on messages arriving in the order they were sent.

## Expected result

> [!TIP]
>
> Messages flow at the pace your consumer can handle, and failures back off instead of hammering it.

## Related guides

> [card] [Dead letters, redrive, pause and purge](https://docs.stackshift.cloud/queues/dead-letters-pause-and-purge.md)
>
> Find messages that ran out of retries, group them by error, send them back once fixed, pause delivery, or purge a queue.

> [card] [Consumers and Function consumers](https://docs.stackshift.cloud/queues/consumers.md)
>
> Each queue has one consumer: a Function, an HTTPS endpoint, or pull. Function consumers are chosen in the dashboard or API, not in code.

> [card] [Limits and error codes](https://docs.stackshift.cloud/queues/limits-and-errors.md)
>
> Sizes, rates, retention and the error codes the Queues API returns when a limit is reached.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.