`
sillycat
  • 浏览: 2551083 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

AMAZON DynamoDB(6)Autoscaling Configuration

 
阅读更多
AMAZON DynamoDB(6)Autoscaling Configuration

We use Serverless framework to deploy our Lambda, so we can try to configuration the auto scaling for DynamoDB there.

I firstly want to do that on serverless.yml. I do the follow changes in serverless.yml
ddbCapaciies:
    read:
        int:
          min: 1
          max: 5
        stage:
          min: 5
          max: 10
        prod:
          min: 10
          max: 500
    write:
        int:
          min: 1
          max: 5
        stage:
          min: 5
          max: 10
        prod:
          min: 10
          max: 500
  capacities:
    - table: DevicePairingInfoTable  # DynamoDB Resource
      read:
        minimum: ${self:custom.ddbCapaciies.read.${self:custom.stage}.min}        # Minimum read capacity
        maximum: ${self:custom.ddbCapaciies.read.${self:custom.stage}.max}     # Maximum read capacity
        usage: 0.80       # Targeted usage percentage
      write:
        minimum: ${self:custom.ddbCapaciies.write.${self:custom.stage}.min}       # Minimum write capacity
        maximum: ${self:custom.ddbCapaciies.write.${self:custom.stage}.min}      # Maximum write capacity
        usage: 0.80        # Targeted usage percentage
    PairingCodeTable:
      Type: AWS::DynamoDB::Table
      DeletionPolicy: Retain
      Properties:
        TableName: ${self:custom.dbPairingCodeName}
        AttributeDefinitions:
          - AttributeName: pairingCode
            AttributeType: S
          - AttributeName: serialNumber
            AttributeType: S
          - AttributeName: platform
            AttributeType: S
        KeySchema:
          - AttributeName: pairingCode
            KeyType: HASH
        ProvisionedThroughput:
          ReadCapacityUnits: ${self:custom.ddbCapaciies.read.${self:custom.stage}.min}
          WriteCapacityUnits: ${self:custom.ddbCapaciies.write.${self:custom.stage}.max}
        GlobalSecondaryIndexes:
          - IndexName: ${self:custom.dbPairingCodeSerialIndex}
            KeySchema:
              - AttributeName: serialNumber
                KeyType: HASH
            Projection:
              ProjectionType: ALL
            ProvisionedThroughput:
              ReadCapacityUnits: ${self:custom.ddbCapaciies.read.${self:custom.stage}.min}
              WriteCapacityUnits: ${self:custom.ddbCapaciies.write.${self:custom.stage}.max}
          - IndexName: ${self:custom.dbPairingCodePlatformIndex}
            KeySchema:
              - AttributeName: platform
                KeyType: HASH
            Projection:
              ProjectionType: ALL
            ProvisionedThroughput:
              ReadCapacityUnits: ${self:custom.ddbCapaciies.read.${self:custom.stage}.min}
              WriteCapacityUnits: ${self:custom.ddbCapaciies.write.${self:custom.stage}.max}

But when I deploy that I get an error with table already exists. That should be because of I create the table by script, not from servless yaml.
An error occurred: xxxxxTable - xxxxxxx-int-devicePairingCode already exists.

We can only do that if the tables are created by serverless yaml at the beginning. But my table is created by my dump script. I need to check how to do that in shell script.

Follow the link
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/AutoScaling.CLI.html

Alter the AutoScaling on DynamoDB
No finished, we will currently do that from the console.


References:
https://github.com/sbstjn/serverless-dynamodb-autoscaling
https://sbstjn.com/serverless-dynamodb-auto-scaling-with-cloudformation.html
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/AutoScaling.CLI.html






分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics