Soru

Zorluk: OrtaStream Processing and Event Routing with Amazon Kinesis and EventBridge

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?

  1. 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.Cevap
  2. Increase the Lambda function's timeout configuration to accommodate the batch processing time and reduce the batch size or maximum batching window if necessary.Cevap
  3. C
    Modify the producer to use a static partition key for all records to guarantee that events are ordered and processed in a single shard.
  4. D
    Decrease the Lambda function's timeout to force rapid function retries and rely on execution context reuse to speed up database writes.
  5. E
    Deploy the Lambda function in a private VPC subnet without configuring a NAT Gateway or a VPC endpoint to minimize network latency.

Cevap

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.

Adım Adım Çözüm

1
Analyze the Kinesis throughput exception.
Identify that the ProvisionedThroughputExceededException is occurring due to uneven distribution of data across shards (hot shards) caused by using low-entropy keys like a game room ID.
Choosing a high-entropy partition key like player ID and session ID ensures even hash distribution across all shards.
2
Analyze the Lambda timeout failures.
Determine that the processing time for the batch is exceeding the configured Lambda timeout.
Increasing the Lambda timeout allows the function to complete processing, and tuning batch size limits the number of events processed at once to prevent timeouts.

Anahtar Kavram

Handling throttling and timeouts when processing Amazon Kinesis streams with AWS Lambda
Bu soruyu puanla