超出 DynamoDB ProvisionedReadCapacity

DynamoDB ProvisionedReadCapacity exceeded

我正在对每秒 3000 个请求的服务进行负载测试。每个请求都从 DynamoDB table 中获取数据。 table 的预配置读取容量为每秒 10,000 次读取。但是,我收到以下异常:

com.amazonaws.services.dynamodbv2.model.ProvisionedThroughputExceededException: The level of configured provisioned throughput for the table was exceede d. Consider increasing your provisioning level with the UpdateTable API (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ProvisionedThroughputE xceededException; Request ID: KHOG5L1S83VU05CAOEJCCPAUFVVV4KQNSO5AEMVJF66Q9ASUAAJG)

我的table描述如下

$ aws dynamodb describe-table --table-name my_table
{
"Table": {
    "TableArn": "arn:aws:dynamodb:us-east-1:188456577:table/my_table", 
    "AttributeDefinitions": [
        {
            "AttributeName": "username", 
            "AttributeType": "S"
        }
    ], 
    "ProvisionedThroughput": {
        "NumberOfDecreasesToday": 0, 
        "WriteCapacityUnits": 10000, 
        "LastIncreaseDateTime": 1462386432.633, 
        "ReadCapacityUnits": 10000
    }, 
    "TableSizeBytes": 289776, 
    "TableName": "my_table", 
    "TableStatus": "ACTIVE", 
    "KeySchema": [
        {
            "KeyType": "HASH", 
            "AttributeName": "username"
        }
    ], 
    "ItemCount": 81, 
    "CreationDateTime": 1458249331.208
    }
}

可以看到,table的读写容量单位都设置为10000

我正在监控 beantalk 服务的 health,同时进行负载测试,请求数确实平均每秒 3K 左右。我不明白为什么会超出吞吐量。 table 也应该每秒收到 3,000 个请求。

DynamoDB 不会限制整个 table 容量。来自文档:

The provisioned throughput associated with a table is also divided evenly among the partitions, with no sharing of provisioned throughput across partitions.

因此,如果您的读取容量为每秒 10,000 次,并且您的 table 有 10 个分区,则每个分区分配的读取容量为每秒 1000 次读取。如果在您的负载测试中,您正在点击同一分区中的键(工作负载分布不均),那么您将看到 ProvisionedThroughputExceededExceptions。您应该尝试均匀分布您的分区键 space 以便您可以获得最大的预配吞吐量。

阅读有关此主题的更多信息here