[{"data":1,"prerenderedAt":89},["ShallowReactive",2],{"pattern-sqs-lmi-standard-lambda-overflow-python-sam":3,"pattern-group-sqs-lmi-standard-lambda-overflow-python-sam":6},{"id":4,"title":5,"architectureURL":6,"cleanup":7,"contributors":10,"deploy":13,"description":18,"extension":19,"framework":20,"gitHub":21,"highlight":6,"introBox":25,"language":32,"level":33,"meta":34,"patternArch":35,"patternGroup":6,"patternGroupLabel":6,"resources":70,"stem":84,"testing":85,"videoId":6,"__hash__":88},"patterns\u002Fpatterns\u002Fsqs-lmi-standard-lambda-overflow-python-sam.json","Amazon SQS overflow from AWS Lambda Managed Instances to Standard AWS Lambda",null,{"text":8},[9],"Delete the stack: \u003Ccode>aws cloudformation delete-stack --stack-name STACK_NAME\u003C\u002Fcode>. Deleting the stack terminates the Lambda Managed Instances.",[11,12],"content\u002Fcontributors\u002Fmitesh-purohit.json","content\u002Fcontributors\u002Fbrian-krygsman.json",{"text":14},[15,16,17],"\u003Ccode>sam validate --lint\u003C\u002Fcode>","\u003Ccode>sam build\u003C\u002Fcode>","\u003Ccode>sam deploy --guided\u003C\u002Fcode>","Run a steady SQS workload on Lambda Managed Instances and open a Standard Lambda burst tier on the same queue when a temporary traffic burst outpaces it.","json","AWS SAM",{"template":22},{"patternPath":23,"templateFile":24},"sqs-lmi-standard-lambda-overflow\u002Fpython\u002Fsam","template.yaml",{"headline":26,"text":27},"How it works",[28,29,30,31],"A single SQS queue is polled by two event source mappings: one always-on mapping to a worker running on Lambda Managed Instances (LMI), which provides a cost-optimized and reservable compute baseline, and one mapping to a Standard Lambda worker that is disabled at deploy time and therefore costs nothing at steady state.","LMI does not scale on queue depth; its managed scaler reacts to the CPU utilization and multi-concurrency saturation of its own execution environments. Keeping both tiers on one queue is what preserves that signal. A router that rate-limited LMI's input would cap its CPU, silence its scaler, and leave the burst tier carrying the load indefinitely.","A controller invoked once a minute polls the queue's live depth with `GetQueueAttributes` every 10 seconds, and toggles the burst mapping with `UpdateEventSourceMapping`. Two thresholds form a dead band: above the open threshold the burst tier opens immediately, and it closes only once depth is below the close threshold, flat or falling over a 30-second window, and a minimum dwell time has elapsed. Polling replaces the CloudWatch depth alarms this pattern originally used, because a load test measured 2m 15s of metric-publish and alarm-evaluation lag, more than half the total time to engage the burst tier, and irreducible on a metric SQS publishes once a minute. The controller is on the control plane and never touches a workload message.","Both tiers run the same handler and share a DynamoDB idempotency table that records a claim before processing and a completion after it, so a retryable failure is redelivered rather than mistaken for a duplicate. A CloudWatch dashboard charts work completed per tier, so you can see the burst tier absorb a spike and then hand the workload back as LMI scales up.","Python","300",{},{"icon1":36,"icon2":41,"icon3":45,"icon4":50,"icon5":53,"line1":57,"line2":61,"line3":64,"line4":67,"line5":69},{"x":37,"y":38,"service":39,"label":40},10,45,"icon-internet","Client",{"x":42,"y":38,"service":43,"label":44},35,"sqs","Amazon SQS\nQueue",{"x":46,"y":47,"service":48,"label":49},63,20,"lambda-event-functions","AWS Lambda\nManaged Instances",{"x":46,"y":51,"service":48,"label":52},68,"AWS Lambda\nBurst tier",{"x":54,"y":38,"service":55,"label":56},88,"dynamodb","Amazon DynamoDB\nIdempotency",{"from":58,"to":59,"label":60},"icon1","icon2","Messages",{"from":59,"to":62,"label":63},"icon3","Always on",{"from":59,"to":65,"label":66},"icon4","On burst",{"from":62,"to":68},"icon5",{"from":65,"to":68},{"bullets":71},[72,75,78,81],{"text":73,"link":74},"Lambda Managed Instances","https:\u002F\u002Fdocs.aws.amazon.com\u002Flambda\u002Flatest\u002Fdg\u002Flambda-managed-instances.html",{"text":76,"link":77},"Scaling Lambda Managed Instances","https:\u002F\u002Fdocs.aws.amazon.com\u002Flambda\u002Flatest\u002Fdg\u002Flambda-managed-instances-scaling.html",{"text":79,"link":80},"CloudWatch metrics for Lambda Managed Instances","https:\u002F\u002Fdocs.aws.amazon.com\u002Flambda\u002Flatest\u002Fdg\u002Flambda-managed-instances-monitoring-metrics.html",{"text":82,"link":83},"Using Lambda with Amazon SQS","https:\u002F\u002Fdocs.aws.amazon.com\u002Flambda\u002Flatest\u002Fdg\u002Fwith-sqs.html","patterns\u002Fsqs-lmi-standard-lambda-overflow-python-sam",{"text":86},[87],"See the README for the two load-test scenarios. A handful of messages will not demonstrate this pattern: the backlog must reach the open threshold before the burst tier can engage, and LMI needs roughly 17 minutes to scale through a 10x burst.","6gBKCQn7Hnf7v6XxLV8QrpfGIZFu0koXIacwijBtBhw",1795189156001]