Skill 4.3.3
Optimize application messaging (for example, by using Amazon SQS queues, Amazon SNS fan-out patterns).
Key Concepts
For Amazon SQS, long polling (a WaitTimeSeconds of up to 20 seconds) removes empty responses, and SendMessageBatch, ReceiveMessage with up to 10 messages and DeleteMessageBatch cut the number of API calls. Messages larger than the 1 MiB limit are stored in S3 with only a pointer in the queue, and a Lambda event source mapping's batch size and batching window trade latency for fewer invocations.
The SNS fan-out pattern publishes once to a topic that delivers to several SQS queues, so each consumer scales and fails independently. Subscription filter policies then deliver only the messages each subscriber cares about, reducing unnecessary processing and cost.
A filter policy is a JSON document on a subscription that matches message attributes (the default) or, with the filter policy scope set to MessageBody, fields in the message body. It supports exact values, prefixes, numeric ranges, anything-but and exists checks. Messages that do not match are not delivered to that subscriber.
Filtering at SNS means consumers no longer receive and discard irrelevant messages, which saves Lambda invocations and SQS requests and simplifies consumer code. EventBridge rules and Lambda event source mapping filters apply the same idea.