Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To trigger an AWS Lambda function from Amazon SQS, create an event source mapping between the queue and function. Lambda polls the queue, groups messages into batches, and invokes the function with those records; your function does not need to poll SQS itself. The main design decisions are how long messages stay invisible while processing, how large batches should be, what happens when only some records fail, and how much concurrency your downstream systems can handle.

How the SQS-to-Lambda integration works

An event source mapping is Lambda’s managed polling and invocation layer for SQS. Lambda pollers receive messages from the queue, assemble a batch, and invoke the function. When the invocation succeeds, successfully processed messages are removed from the queue. If processing fails, messages can become visible again after the queue’s visibility timeout and be delivered again.

The queue and function must be in the same AWS Region, though they may belong to different AWS accounts. The function’s execution role needs the AWSLambdaSQSQueueExecutionRole managed policy. For an encrypted queue, the role also needs kms:Decrypt.

Prepare the queue and function

  • Choose a standard or FIFO queue based on ordering and throughput requirements.
  • Give the function’s execution role the required SQS permissions, and add kms:Decrypt if the queue is encrypted.
  • Create a redrive policy that sends repeatedly failing messages to a dead-letter queue. AWS recommends setting maxReceiveCount to at least 5.
  • Create an event source mapping for the queue and function, then configure its batch and concurrency behavior to suit the workload.

Set the visibility timeout to allow for processing and retries

The function timeout must be less than or equal to the queue’s visibility timeout. AWS recommends a queue visibility timeout of at least six times the function timeout. If the mapping uses a batching window greater than zero, the recommended minimum is six times the function timeout plus the batching-window value.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The visibility timeout is the period during which a received message is hidden from other consumers. The longer recommendation gives Lambda room to process a batch and retry after throttling. A timeout that is too short can allow a message to reappear while processing or retry handling is still underway; a longer timeout also means a failed message may take longer to become available again.

Choose a batch size and batching window

Batch size controls the maximum number of records Lambda can receive for one invocation. A larger batch can reduce per-invocation overhead when each record is quick to process. A smaller batch can limit the amount of work that must be replayed after an invocation-level failure, and may be more appropriate when records take longer or are large.

Setting Standard queue FIFO queue
Maximum configured batch size 10,000 records 10 records
Batching window Supported Not supported

These are configured limits, not a guarantee that every invocation will contain that many records. Lambda’s synchronous invocation payload quota also applies, so message size and per-record metadata can make the actual batch smaller than the configured maximum.

Handle failed records without replaying successful work

By default, if an invocation fails, Lambda retries the whole batch. That can include records the function already processed successfully, so handlers should be idempotent: processing the same message more than once should not create duplicate side effects.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Enable partial batch responses

To report failures record by record, enable ReportBatchItemFailures on the event source mapping. The function then returns a batchItemFailures list containing the identifiers of records that failed. Lambda can retry those records without requiring successful records from the same batch to be processed again.

This only works when the handler returns a valid partial response. If it throws an exception instead, Lambda treats the entire batch as failed. A durable record of completed message IDs, or another suitable deduplication key, can help prevent repeated deliveries from repeating side effects.

Preserve FIFO ordering when a record fails

FIFO queues preserve order within each MessageGroupId, not across different groups. When processing a FIFO batch, stop at the first failure and report that record along with all unprocessed records as failures. Continuing past the failure could allow later records in the same group to be processed out of order. Separate message groups can be processed concurrently.

Control concurrency to protect downstream services

For standard queues, Lambda starts with five concurrent batches and can add up to 300 concurrent invokes per minute, up to a documented maximum of 1,250 concurrent invokes, according to AWS’s 2026 documentation. The number of active invocations affects how quickly a backlog drains, but it also determines the pressure the function can place on databases, APIs, and other downstream systems.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use maximum concurrency for a mapping

A maximum-concurrency setting caps how many functions that event source mapping can invoke at once. Use it to limit load on a downstream dependency, and ensure that the function has enough available concurrency to avoid being throttled. Batch size and concurrency should be tuned together: a larger batch changes how much work each invocation attempts, while concurrency controls how many batches can be in flight.

Consider provisioned mode for dedicated pollers

Provisioned mode allocates dedicated pollers, with configurable minimum and maximum poller counts and per-poller throughput limits. It cannot be combined with maximum concurrency. Choose between the two approaches based on whether the mapping needs a cap on concurrent function invocations or dedicated polling capacity; do not configure both together.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose standard or FIFO based on ordering needs

Decision area Standard queue FIFO queue
Ordering Best-effort ordering Ordered within each MessageGroupId
Maximum batch size 10,000 records 10 records
Batching window Supported Not supported
Concurrency Scales broadly with backlog, subject to configured limits Bounded by the number of available message groups
Duplicate handling At-least-once delivery; make processing idempotent Ordering is preserved per group, but duplicate delivery still requires idempotency
Typical fit High-throughput asynchronous work without a strict ordering requirement Workflows that need ordered processing per entity or group

Choose FIFO when order within a group is a correctness requirement. Choose standard when strict ordering is unnecessary and broad scaling with backlog is more important. Neither queue type removes the need to make message processing safe to repeat.

Use event filtering when only some messages should invoke the function

Event filtering can prevent records that do not match business rules from invoking Lambda. Write filters for Lambda’s SQS event syntax and check that the actual message body and attributes have the shape the filter expects. More complex conditions may require multi-level filtering. Filtering is most useful when the queue contains messages for multiple cases but this function should handle only a subset.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Practical tuning checklist

  • Set the visibility timeout to at least six times the function timeout, adding the batching window when one is configured.
  • Start with a batch size suited to record duration and size; account for the invocation payload quota rather than assuming the configured maximum will always be reached.
  • Enable partial batch responses if the handler can identify failed records and return their identifiers.
  • Make side effects idempotent and configure a dead-letter queue with a redrive policy.
  • Set mapping concurrency with downstream capacity and available Lambda concurrency in mind.
  • For FIFO processing, use message groups to define the boundaries of ordering and concurrency, and stop a batch at its first failure.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.