We are routing high-volume interaction events from CXone to an AWS Lambda function via EventBridge. The goal is to process conversation-update events in batches to reduce cold starts. We configured the Lambda event source mapping with MaximumBatchingWindowInSeconds set to 60 and MaximumBatchingWindowInSeconds to 1000. The Lambda function signature expects an array of event records.
The issue is that during peak hours, we are hitting the Lambda concurrency limits. The function returns THROTTLED errors, and EventBridge retries the batch. Since the batch size is large, a single retry causes a massive spike in memory and execution time, leading to timeouts. We tried increasing the reserved concurrency, but the cost is prohibitive, and it’s not scaling efficiently.
Here is the current Lambda handler structure:
def lambda_handler(event, context):
records = event['Records']
processed_ids = []
for record in records:
# Process each interaction event
interaction_id = record['body']['interactionId']
# ... logic ...
processed_ids.append(interaction_id)
return {'statusCode': 200, 'body': json.dumps({'processed': processed_ids})}
The question is about the best practice for handling this load. Should we reduce the batch size to avoid hitting concurrency limits, or is there a way to configure EventBridge to split large batches into smaller chunks before sending to Lambda? We are looking for a code or configuration change to stabilize the processing pipeline without over-provisioning Lambda instances. The current setup works for low volume but fails under stress. We need a reliable way to handle the burst without losing events or incurring excessive costs. Any specific EventBridge or Lambda configuration tweaks that help with this pattern?