A multiplayer gaming application streams real-time player action events to an Amazon Kinesis Data Stream. An AWS Lambda function processes these events to update a live leaderboards database. During peak tournaments, the game server logs show ProvisionedThroughputExceededException errors when writing to the stream, and the Lambda consumer experiences frequent timeouts while processing the event batches. Which TWO actions should the developer take to resolve these issues?
- Modify the producer to use a high-entropy partition key, such as a combination of player ID and session ID, instead of a static game room ID.Answer
- Increase the Lambda function's timeout configuration to accommodate the batch processing time and reduce the batch size or maximum batching window if necessary.Answer
- CModify the producer to use a static partition key for all records to guarantee that events are ordered and processed in a single shard.
- DDecrease the Lambda function's timeout to force rapid function retries and rely on execution context reuse to speed up database writes.
- EDeploy the Lambda function in a private VPC subnet without configuring a NAT Gateway or a VPC endpoint to minimize network latency.
Answer
The developer should modify the producer to use a high-entropy partition key (such as a combination of player ID and session ID) and increase the Lambda function's timeout configuration while reducing the batch size or maximum batching window if necessary.
Using a high-entropy partition key like a combination of player ID and session ID distributes the write throughput evenly across all shards, avoiding hotspots. Additionally, increasing the Lambda timeout ensures the function has sufficient time to process event batches before AWS Lambda terminates the execution context.
Step-by-Step Solution
Key Concept
Handling throttling and timeouts when processing Amazon Kinesis streams with AWS Lambda