AWS Builder Center

SQS-triggered Lambda: cap queues without starving the function

A practical guide to choosing event-source maximum concurrency, coordinating it with reserved concurrency, and accounting for FIFO message groups.

Put the cap at the queue boundary

For an SQS event source mapping,  MaximumConcurrency  limits how many concurrent invocations that queue can create. It helps protect a downstream database or API when messages arrive in a burst. Choose the cap from the downstream service’s safe parallel capacity, not from Lambda’s account quota alone.

Budget for the whole function

 MaximumConcurrency  is set per event source mapping; reserved concurrency is a function-level limit. When several SQS mappings share one function, add their configured caps and make reserved concurrency at least that total. Otherwise, Lambda can throttle messages. If other triggers use the same function, include their expected load in the budget too.

FIFO has another ceiling

For a FIFO queue, the number of active  MessageGroupId  values also limits parallelism. Effective concurrency cannot exceed the lower of the mapping cap and the available message groups. Raising the cap will not speed up a queue with only a few active groups. Split work across groups only when those operations can run independently.
Before changing production, test with representative traffic and watch queue backlog, Lambda throttles, and downstream saturation. Maximum concurrency cannot be combined with provisioned mode, so choose one scaling approach.

Quick check

  1. Estimate the downstream service’s safe parallel capacity.
  1. Set a cap on each SQS mapping.
  1. Make reserved concurrency cover the sum of those caps and other expected function traffic.
  1. Validate FIFO group count and load-test the result.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article