AWS Kinesis KMSThrottlingException

The request was throttled by AWS KMS.

Understanding AWS Kinesis

AWS Kinesis is a platform on AWS to collect, process, and analyze real-time, streaming data. It allows developers to build applications that can continuously ingest and process large streams of data records in real-time. Kinesis is often used for real-time analytics, log and event data collection, and real-time data processing.

Identifying the Symptom: KMSThrottlingException

When working with AWS Kinesis, you might encounter the KMSThrottlingException. This error typically manifests when your application attempts to perform operations that require AWS Key Management Service (KMS) and the requests are throttled.

What You Observe

In your application logs or AWS CloudWatch, you may see error messages indicating a KMSThrottlingException. This suggests that the requests to AWS KMS are being throttled due to exceeding the allowed request rate.

Exploring the Issue: KMSThrottlingException

The KMSThrottlingException occurs when the number of requests made to AWS KMS exceeds the rate limits set by AWS. KMS is used in Kinesis for encrypting data streams, and if your application makes too many requests in a short period, AWS KMS will throttle these requests to maintain service stability.

Why It Happens

This issue often arises in high-throughput applications where multiple requests are made to encrypt or decrypt data using AWS KMS. If these requests exceed the KMS rate limits, throttling occurs.

Steps to Resolve KMSThrottlingException

To resolve the KMSThrottlingException, you can implement the following strategies:

Implement Exponential Backoff

Exponential backoff is a standard error-handling strategy for network applications in which the client increases the wait time between retries exponentially. This approach helps to reduce the load on AWS KMS and allows your requests to be processed successfully.

import boto3
import time

client = boto3.client('kinesis')

# Example of exponential backoff
for attempt in range(1, 6):
try:
# Your Kinesis operation here
response = client.put_record(
StreamName='your-stream-name',
Data=b'your-data',
PartitionKey='your-partition-key'
)
break
except client.exceptions.KMSThrottlingException as e:
print(f"Attempt {attempt}: Throttled, retrying...")
time.sleep(2 ** attempt)

Monitor and Optimize Request Rates

Use AWS CloudWatch to monitor your Kinesis and KMS request rates. Identify patterns or spikes in usage that may lead to throttling. Consider optimizing your application to reduce unnecessary requests.

Consider Increasing Limits

If your application consistently requires higher request rates, consider contacting AWS Support to discuss increasing your KMS limits. Ensure you have a valid use case and provide details about your application's requirements.

Additional Resources

For more information on handling AWS KMS throttling, refer to the AWS KMS Limits documentation. Additionally, explore the AWS Kinesis Developer Guide for best practices in managing data streams.

Never debug

AWS Kinesis

manually again

Let Dr. Droid create custom investigation plans for your infrastructure.

Book Demo
Automate Debugging for
AWS Kinesis
See how Dr. Droid creates investigation plans for your infrastructure.

MORE ISSUES

Made with ❤️ in Bangalore & San Francisco 🏢

Doctor Droid