

Les traductions sont fournies par des outils de traduction automatique. En cas de conflit entre le contenu d'une traduction et celui de la version originale en anglais, la version anglaise prévaudra.

# Présentation du débit chaud DynamoDB
<a name="warm-throughput"></a>

Le *débit chaud* fait référence au nombre d’opérations de lecture et d’écriture que votre table DynamoDB peut prendre en charge instantanément. Ces valeurs sont disponibles par défaut pour toutes les tables et tous les index secondaires globaux (GSI) et indiquent dans quelle mesure ils ont été mis à l’échelle en fonction de leur utilisation historique. Si vous utilisez le mode à la demande ou si vous mettez à jour votre débit provisionné en fonction de ces valeurs, votre application sera en mesure d’émettre des demandes allant jusqu’à ces valeurs instantanément.

DynamoDB ajuste automatiquement les valeurs de débit chaud à mesure que votre utilisation augmente. Vous pouvez également augmenter ces valeurs de manière proactive en cas de besoin, ce qui est particulièrement utile pour les événements de pointe à venir, tels que les lancements de produits ou les ventes. Pour les pics planifiés, au cours desquels le taux de demandes adressées à votre table DynamoDB peut augmenter de 10, 100 fois ou plus, vous pouvez désormais évaluer si le débit chaud actuel est suffisant pour gérer le trafic attendu. Si ce n’est pas le cas, vous pouvez augmenter la valeur du débit chaud sans modifier vos paramètres de débit ni votre [mode de facturation](capacity-mode.md). Ce processus est appelé *préchauffage* d’une table, ce qui vous permet de définir une base de référence que vos tables peuvent prendre en charge instantanément. Cela permet à vos applications de gérer des taux de demandes supérieurs dès leur apparition. Une fois augmentées, les valeurs de débit à chaud ne peuvent pas être diminuées.

Vous pouvez augmenter la valeur du débit chaud pour les opérations de lecture, d’écriture ou les deux. Vous pouvez augmenter cette valeur pour les tables mono-régionales nouvelles et existantes, les tables globales et GSIs. Pour les tables globales, cette fonctionnalité est disponible pour la [version 2019.11.21 (actuelle)](GlobalTables.md). Les paramètres de débit chaud que vous définissez s’appliquent automatiquement à toutes les tables répliquées de la table globale. Il n’existe pas de limite au nombre de tables DynamoDB que vous pouvez préchauffer à tout moment. Le temps nécessaire pour terminer le préchauffage dépend des valeurs que vous définissez et de la taille de la table ou de l’index. Vous pouvez envoyer des demandes de préchauffage simultanées, qui n’interféreront pas avec les opérations de table. Vous pouvez préchauffer votre table jusqu’à la limite du quota de table ou d’index de votre compte dans cette région. Utilisez la [console Service Quotas](https://console.aws.amazon.com/servicequotas) pour vérifier vos limites actuelles et les augmenter si nécessaire. 

Les valeurs de débit chaud sont disponibles gratuitement par défaut, pour toutes les tables et tous les index secondaires. Toutefois, si vous augmentez de manière proactive ces valeurs de débit chaud par défaut pour préchauffer les tables, ces demandes vous seront facturées. Pour plus d’informations, consultez [Tarification Amazon DynamoDB](https://aws.amazon.com/dynamodb/pricing/).

Pour plus d’informations sur le débit chaud, consultez les rubriques ci-dessous :

**Topics**
+ [Vérification du débit chaud actuel de votre table DynamoDB](check-warm-throughput.md)
+ [Augmentation du débit chaud de votre table DynamoDB existante](update-warm-throughput.md)
+ [Création d’une table DynamoDB avec un débit chaud supérieur](create-table-warm-throughput.md)
+ [Compréhension du débit chaud DynamoDB dans différents scénarios](warm-throughput-scenarios.md)

# Vérification du débit chaud actuel de votre table DynamoDB
<a name="check-warm-throughput"></a>

Utilisez les instructions suivantes AWS CLI et celles de AWS la console pour vérifier la valeur actuelle du débit à chaud de votre table ou de votre index.

## AWS Management Console
<a name="warm-throughput-check-console"></a>

Pour vérifier le débit chaud de votre table DynamoDB à l’aide de la console DynamoDB :

1. Connectez-vous à la console DynamoDB AWS Management Console et ouvrez-la à l'adresse. [https://console.aws.amazon.com/dynamodb/](https://console.aws.amazon.com/dynamodb/)

1. Dans le volet de navigation de gauche, choisissez Tables.

1. Sur la page **Tables**, choisissez la table de votre choix.

1. Sélectionnez **Paramètres supplémentaires** pour afficher votre valeur de débit chaud actuelle. Cette valeur est affichée en unités de lecture et d’écriture par seconde.

## AWS CLI
<a name="warm-throughput-check-CLI"></a>

L' AWS CLI exemple suivant montre comment vérifier le débit chaud de votre table DynamoDB.

1. Exécutez l’opération `describe-table` sur votre table DynamoDB.

   ```
   aws dynamodb describe-table --table-name GameScores
   ```

1. Vous recevrez une réponse similaire à la suivante. Vos paramètres `WarmThroughput` seront affichés sous la forme `ReadUnitsPerSecond` et `WriteUnitsPerSecond`. Le paramètre `Status` sera défini sur `UPDATING` lorsque la valeur du débit chaud sera mise à jour, et sur `ACTIVE` lorsque la nouvelle valeur du débit chaud sera définie.

   ```
   {
       "Table": {
           "AttributeDefinitions": [
               {
                   "AttributeName": "GameTitle",
                   "AttributeType": "S"
               },
               {
                   "AttributeName": "TopScore",
                   "AttributeType": "N"
               },
               {
                   "AttributeName": "UserId",
                   "AttributeType": "S"
               }
           ],
           "TableName": "GameScores",
           "KeySchema": [
               {
                   "AttributeName": "UserId",
                   "KeyType": "HASH"
               },
               {
                   "AttributeName": "GameTitle",
                   "KeyType": "RANGE"
               }
           ],
           "TableStatus": "ACTIVE",
           "CreationDateTime": 1726128388.729,
           "ProvisionedThroughput": {
               "NumberOfDecreasesToday": 0,
               "ReadCapacityUnits": 0,
               "WriteCapacityUnits": 0
           },
           "TableSizeBytes": 0,
           "ItemCount": 0,
           "TableArn": "arn:aws:dynamodb:us-east-1:XXXXXXXXXXXX:table/GameScores",
           "TableId": "XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
           "BillingModeSummary": {
               "BillingMode": "PAY_PER_REQUEST",
               "LastUpdateToPayPerRequestDateTime": 1726128388.729
           },
           "GlobalSecondaryIndexes": [
               {
                   "IndexName": "GameTitleIndex",
                   "KeySchema": [
                       {
                           "AttributeName": "GameTitle",
                           "KeyType": "HASH"
                       },
                       {
                           "AttributeName": "TopScore",
                           "KeyType": "RANGE"
                       }
                   ],
                   "Projection": {
                       "ProjectionType": "INCLUDE",
                       "NonKeyAttributes": [
                           "UserId"
                       ]
                   },
                   "IndexStatus": "ACTIVE",
                   "ProvisionedThroughput": {
                       "NumberOfDecreasesToday": 0,
                       "ReadCapacityUnits": 0,
                       "WriteCapacityUnits": 0
                   },
                   "IndexSizeBytes": 0,
                   "ItemCount": 0,
                   "IndexArn": "arn:aws:dynamodb:us-east-1:XXXXXXXXXXXX:table/GameScores/index/GameTitleIndex",
                   "WarmThroughput": {
                       "ReadUnitsPerSecond": 12000,
                       "WriteUnitsPerSecond": 4000,
                       "Status": "ACTIVE"
                   }
               }
           ],
           "DeletionProtectionEnabled": false,
           "WarmThroughput": {
               "ReadUnitsPerSecond": 12000,
               "WriteUnitsPerSecond": 4000,
               "Status": "ACTIVE"
           }
       }
   }
   ```

# Augmentation du débit chaud de votre table DynamoDB existante
<a name="update-warm-throughput"></a>

Une fois que vous avez vérifié la valeur actuelle du débit chaud de votre table DynamoDB, vous pouvez la mettre à jour en procédant comme suit :

## AWS Management Console
<a name="warm-throughput-update-console"></a>

Pour vérifier la valeur de débit chaud de votre table DynamoDB à l’aide de la console DynamoDB :

1. Connectez-vous à la console DynamoDB AWS Management Console et ouvrez-la à l'adresse. [https://console.aws.amazon.com/dynamodb/](https://console.aws.amazon.com/dynamodb/)

1. Dans le volet de navigation de gauche, choisissez Tables.

1. Sur la page **Tables**, choisissez la table de votre choix.

1. Dans le champ **Débit chaud**, sélectionnez **Modifier**.

1. Sur la page **Modifier le débit chaud**, choisissez **Augmenter le débit chaud**.

1. Ajustez les **unités de lecture** et **d’écriture par seconde**. Ces deux paramètres définissent le débit que votre table peut gérer instantanément.

1. Cliquez sur **Enregistrer**.

1. Vos **unités de lecture par seconde** et d’**écriture par seconde** seront mises à jour dans le champ **Débit chaud** lorsque le traitement de la demande sera terminé.
**Note**  
La mise à jour de la valeur de votre débit chaud est une tâche asynchrone. La valeur de `Status` passera de `UPDATING` à `ACTIVE` lorsque la mise à jour sera terminée.

## AWS CLI
<a name="warm-throughput-update-CLI"></a>

L' AWS CLI exemple suivant montre comment mettre à jour la valeur de débit chaud de votre table DynamoDB.

1. Exécutez l’opération `update-table` sur votre table DynamoDB.

   ```
   aws dynamodb update-table \
       --table-name GameScores \
       --warm-throughput ReadUnitsPerSecond=12345,WriteUnitsPerSecond=4567 \
       --global-secondary-index-updates \
           "[
               {
                   \"Update\": {
                       \"IndexName\": \"GameTitleIndex\",
                       \"WarmThroughput\": {
                           \"ReadUnitsPerSecond\": 88,
                           \"WriteUnitsPerSecond\": 77
                       }
                   }
               }
           ]" \
       --region us-east-1
   ```

1. Vous recevrez une réponse similaire à la suivante. Vos paramètres `WarmThroughput` seront affichés sous la forme `ReadUnitsPerSecond` et `WriteUnitsPerSecond`. Le paramètre `Status` sera défini sur `UPDATING` lorsque la valeur du débit chaud sera mise à jour, et sur `ACTIVE` lorsque la nouvelle valeur du débit chaud sera définie.

   ```
   {
       "TableDescription": {
           "AttributeDefinitions": [
               {
                   "AttributeName": "GameTitle",
                   "AttributeType": "S"
               },
               {
                   "AttributeName": "TopScore",
                   "AttributeType": "N"
               },
               {
                   "AttributeName": "UserId",
                   "AttributeType": "S"
               }
           ],
           "TableName": "GameScores",
           "KeySchema": [
               {
                   "AttributeName": "UserId",
                   "KeyType": "HASH"
               },
               {
                   "AttributeName": "GameTitle",
                   "KeyType": "RANGE"
               }
           ],
           "TableStatus": "ACTIVE",
           "CreationDateTime": 1730242189.965,
           "ProvisionedThroughput": {
               "NumberOfDecreasesToday": 0,
               "ReadCapacityUnits": 20,
               "WriteCapacityUnits": 10
           },
           "TableSizeBytes": 0,
           "ItemCount": 0,
           "TableArn": "arn:aws:dynamodb:us-east-1:XXXXXXXXXXXX:table/GameScores",
           "TableId": "XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
           "GlobalSecondaryIndexes": [
               {
                   "IndexName": "GameTitleIndex",
                   "KeySchema": [
                       {
                           "AttributeName": "GameTitle",
                           "KeyType": "HASH"
                       },
                       {
                           "AttributeName": "TopScore",
                           "KeyType": "RANGE"
                       }
                   ],
                   "Projection": {
                       "ProjectionType": "INCLUDE",
                       "NonKeyAttributes": [
                           "UserId"
                       ]
                   },
                   "IndexStatus": "ACTIVE",
                   "ProvisionedThroughput": {
                       "NumberOfDecreasesToday": 0,
                       "ReadCapacityUnits": 50,
                       "WriteCapacityUnits": 25
                   },
                   "IndexSizeBytes": 0,
                   "ItemCount": 0,
                   "IndexArn": "arn:aws:dynamodb:us-east-1:XXXXXXXXXXXX:table/GameScores/index/GameTitleIndex",
                   "WarmThroughput": {
                       "ReadUnitsPerSecond": 50,
                       "WriteUnitsPerSecond": 25,
                       "Status": "UPDATING"
                   }
               }
           ],
           "DeletionProtectionEnabled": false,
           "WarmThroughput": {
               "ReadUnitsPerSecond": 12300,
               "WriteUnitsPerSecond": 4500,
               "Status": "UPDATING"
           }
       }
   }
   ```

## AWS SDK
<a name="warm-throughput-update-SDK"></a>

Les exemples de SDK suivants vous montrent comment mettre à jour la valeur de débit chaud de votre table DynamoDB.

------
#### [ Java ]

```
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
import software.amazon.awssdk.services.dynamodb.model.DynamoDbException;
import software.amazon.awssdk.services.dynamodb.model.GlobalSecondaryIndexUpdate;
import software.amazon.awssdk.services.dynamodb.model.UpdateGlobalSecondaryIndexAction;
import software.amazon.awssdk.services.dynamodb.model.UpdateTableRequest;
import software.amazon.awssdk.services.dynamodb.model.WarmThroughput;

...
public static WarmThroughput buildWarmThroughput(final Long readUnitsPerSecond,
                                                 final Long writeUnitsPerSecond) {
    return WarmThroughput.builder()
            .readUnitsPerSecond(readUnitsPerSecond)
            .writeUnitsPerSecond(writeUnitsPerSecond)
            .build();
}

public static void updateDynamoDBTable(DynamoDbClient ddb,
                                       String tableName,
                                       Long tableReadUnitsPerSecond,
                                       Long tableWriteUnitsPerSecond,
                                       String globalSecondaryIndexName,
                                       Long globalSecondaryIndexReadUnitsPerSecond,
                                       Long globalSecondaryIndexWriteUnitsPerSecond) {

    final WarmThroughput tableWarmThroughput = buildWarmThroughput(tableReadUnitsPerSecond, tableWriteUnitsPerSecond);
    final WarmThroughput gsiWarmThroughput = buildWarmThroughput(globalSecondaryIndexReadUnitsPerSecond, globalSecondaryIndexWriteUnitsPerSecond);

    final GlobalSecondaryIndexUpdate globalSecondaryIndexUpdate = GlobalSecondaryIndexUpdate.builder()
            .update(UpdateGlobalSecondaryIndexAction.builder()
                    .indexName(globalSecondaryIndexName)
                    .warmThroughput(gsiWarmThroughput)
                    .build()
            ).build();

    final UpdateTableRequest request = UpdateTableRequest.builder()
            .tableName(tableName)
            .globalSecondaryIndexUpdates(globalSecondaryIndexUpdate)
            .warmThroughput(tableWarmThroughput)
            .build();

    try {
        ddb.updateTable(request);
    } catch (DynamoDbException e) {
        System.err.println(e.getMessage());
        System.exit(1);
    }

    System.out.println("Done!");
}
```

------
#### [ Python ]

```
from boto3 import resource
from botocore.exceptions import ClientError

def update_dynamodb_table_warm_throughput(table_name, table_read_units, table_write_units, gsi_name, gsi_read_units, gsi_write_units, region_name="us-east-1"):
    """
    Updates the warm throughput of a DynamoDB table and a global secondary index.

    :param table_name: The name of the table to update.
    :param table_read_units: The new read units per second for the table's warm throughput.
    :param table_write_units: The new write units per second for the table's warm throughput.
    :param gsi_name: The name of the global secondary index to update.
    :param gsi_read_units: The new read units per second for the GSI's warm throughput.
    :param gsi_write_units: The new write units per second for the GSI's warm throughput.
    :param region_name: The AWS Region name to target. defaults to us-east-1
    """
    try:
        ddb = resource('dynamodb', region_name)
        
        # Update the table's warm throughput
        table_warm_throughput = {
            "ReadUnitsPerSecond": table_read_units,
            "WriteUnitsPerSecond": table_write_units
        }

        # Update the global secondary index's warm throughput
        gsi_warm_throughput = {
            "ReadUnitsPerSecond": gsi_read_units,
            "WriteUnitsPerSecond": gsi_write_units
        }

        # Construct the global secondary index update
        global_secondary_index_update = [
            {
                "Update": {
                    "IndexName": gsi_name,
                    "WarmThroughput": gsi_warm_throughput
                }
            }
        ]

        # Construct the update table request
        update_table_request = {
            "TableName": table_name,
            "GlobalSecondaryIndexUpdates": global_secondary_index_update,
            "WarmThroughput": table_warm_throughput
        }

        # Update the table
        ddb.update_table(**update_table_request)
        print("Table updated successfully!")
    except ClientError as e:
        print(f"Error updating table: {e}")
        raise e
```

------
#### [ Javascript ]

```
import { DynamoDBClient, UpdateTableCommand } from "@aws-sdk/client-dynamodb";

async function updateDynamoDBTableWarmThroughput(
  tableName,
  tableReadUnits,
  tableWriteUnits,
  gsiName,
  gsiReadUnits,
  gsiWriteUnits,
  region = "us-east-1"
) {
  try {
    const ddbClient = new DynamoDBClient({ region: region });

    // Construct the update table request
    const updateTableRequest = {
      TableName: tableName,
      GlobalSecondaryIndexUpdates: [
        {
            Update: {
                IndexName: gsiName,
                WarmThroughput: {
                    ReadUnitsPerSecond: gsiReadUnits,
                    WriteUnitsPerSecond: gsiWriteUnits,
                },
            },
        },
      ],
      WarmThroughput: {
          ReadUnitsPerSecond: tableReadUnits,
          WriteUnitsPerSecond: tableWriteUnits,
      },
    };

    const command = new UpdateTableCommand(updateTableRequest);
    const response = await ddbClient.send(command);
    console.log(`Table updated successfully! Response: ${response}`);
  } catch (error) {
    console.error(`Error updating table: ${error}`);
    throw error;
  }
}
```

------

# Création d’une table DynamoDB avec un débit chaud supérieur
<a name="create-table-warm-throughput"></a>

Vous pouvez ajuster les valeurs de débit chaud lorsque vous créez votre table DynamoDB en suivant les étapes ci-dessous. Ces étapes s’appliquent également lors de la création d’une [table globale](GlobalTables.md) ou d’un [index secondaire](SecondaryIndexes.md).

## AWS Management Console
<a name="warm-throughput-create-console"></a>

Pour créer une table DynamoDB et ajuster les valeurs de débit chaud via la console :

1. Connectez-vous à la console DynamoDB AWS Management Console et ouvrez-la à l'adresse. [https://console.aws.amazon.com/dynamodb/](https://console.aws.amazon.com/dynamodb/)

1. Sélectionnez **Créer une table**.

1. Choisissez le **Nom de la table**, une **Clé de partition** et une **Clé de tri (facultatif)**.

1. Pour les **Paramètres de la table**, choisissez **Personnaliser les paramètres**.

1. Dans le champ **Débit chaud**, sélectionnez **Augmenter le débit chaud**.

1. Ajustez les **unités de lecture** et **d’écriture par seconde**. Ces deux paramètres définissent le débit maximal que votre table peut gérer instantanément.

1. Continuez à renseigner les autres détails de la table, puis sélectionnez **Créer une table**.

## AWS CLI
<a name="warm-throughput-create-CLI"></a>

L' AWS CLI exemple suivant montre comment créer une table DynamoDB avec des valeurs de débit de chaleur personnalisées.

1. Exécutez l’opération `create-table` pour créer la table DynamoDB suivante.

   ```
   aws dynamodb create-table \
       --table-name GameScores \
       --attribute-definitions AttributeName=UserId,AttributeType=S \
                               AttributeName=GameTitle,AttributeType=S \
                               AttributeName=TopScore,AttributeType=N  \
       --key-schema AttributeName=UserId,KeyType=HASH \
                    AttributeName=GameTitle,KeyType=RANGE \
       --provisioned-throughput ReadCapacityUnits=20,WriteCapacityUnits=10 \
       --global-secondary-indexes \
           "[
               {
                   \"IndexName\": \"GameTitleIndex\",
                   \"KeySchema\": [{\"AttributeName\":\"GameTitle\",\"KeyType\":\"HASH\"},
                                   {\"AttributeName\":\"TopScore\",\"KeyType\":\"RANGE\"}],
                   \"Projection\":{
                       \"ProjectionType\":\"INCLUDE\",
                       \"NonKeyAttributes\":[\"UserId\"]
                   },
                   \"ProvisionedThroughput\": {
                       \"ReadCapacityUnits\": 50,
                       \"WriteCapacityUnits\": 25
                   },\"WarmThroughput\": {
                       \"ReadUnitsPerSecond\": 1987,
                       \"WriteUnitsPerSecond\": 543
                   }
               }
           ]" \
       --warm-throughput ReadUnitsPerSecond=12345,WriteUnitsPerSecond=4567 \
       --region us-east-1
   ```

1. Vous recevrez une réponse similaire à la suivante. Vos paramètres `WarmThroughput` seront affichés sous la forme `ReadUnitsPerSecond` et `WriteUnitsPerSecond`. Le paramètre `Status` sera défini sur `UPDATING` lorsque la valeur du débit chaud sera mise à jour, et sur `ACTIVE` lorsque la nouvelle valeur du débit chaud sera définie.

   ```
   {
       "TableDescription": {
           "AttributeDefinitions": [
               {
                   "AttributeName": "GameTitle",
                   "AttributeType": "S"
               },
               {
                   "AttributeName": "TopScore",
                   "AttributeType": "N"
               },
               {
                   "AttributeName": "UserId",
                   "AttributeType": "S"
               }
           ],
           "TableName": "GameScores",
           "KeySchema": [
               {
                   "AttributeName": "UserId",
                   "KeyType": "HASH"
               },
               {
                   "AttributeName": "GameTitle",
                   "KeyType": "RANGE"
               }
           ],
           "TableStatus": "CREATING",
           "CreationDateTime": 1730241788.779,
           "ProvisionedThroughput": {
               "NumberOfDecreasesToday": 0,
               "ReadCapacityUnits": 20,
               "WriteCapacityUnits": 10
           },
           "TableSizeBytes": 0,
           "ItemCount": 0,
           "TableArn": "arn:aws:dynamodb:us-east-1:XXXXXXXXXXXX:table/GameScores",
           "TableId": "XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
           "GlobalSecondaryIndexes": [
               {
                   "IndexName": "GameTitleIndex",
                   "KeySchema": [
                       {
                           "AttributeName": "GameTitle",
                           "KeyType": "HASH"
                       },
                       {
                           "AttributeName": "TopScore",
                           "KeyType": "RANGE"
                       }
                   ],
                   "Projection": {
                       "ProjectionType": "INCLUDE",
                       "NonKeyAttributes": [
                           "UserId"
                       ]
                   },
                   "IndexStatus": "CREATING",
                   "ProvisionedThroughput": {
                       "NumberOfDecreasesToday": 0,
                       "ReadCapacityUnits": 50,
                       "WriteCapacityUnits": 25
                   },
                   "IndexSizeBytes": 0,
                   "ItemCount": 0,
                   "IndexArn": "arn:aws:dynamodb:us-east-1:XXXXXXXXXXXX:table/GameScores/index/GameTitleIndex",
                   "WarmThroughput": {
                       "ReadUnitsPerSecond": 1987,
                       "WriteUnitsPerSecond": 543,
                       "Status": "UPDATING"
                   }
               }
           ],
           "DeletionProtectionEnabled": false,
           "WarmThroughput": {
               "ReadUnitsPerSecond": 12345,
               "WriteUnitsPerSecond": 4567,
               "Status": "UPDATING"
           }
       }
   }
   ```

## AWS SDK
<a name="warm-throughput-create-SDK"></a>

L’exemple de kit SDK suivant montre comment créer une table DynamoDB avec des valeurs de débit chaud personnalisées.

------
#### [ Java ]

```
import software.amazon.awscdk.services.dynamodb.ProjectionType;
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
import software.amazon.awssdk.services.dynamodb.model.CreateTableResponse;
import software.amazon.awssdk.services.dynamodb.model.CreateTableRequest;
import software.amazon.awssdk.services.dynamodb.model.KeySchemaElement;
import software.amazon.awssdk.services.dynamodb.model.KeyType;
import software.amazon.awssdk.services.dynamodb.model.ProvisionedThroughput;
import software.amazon.awssdk.services.dynamodb.model.Projection;
import software.amazon.awssdk.services.dynamodb.model.GlobalSecondaryIndex;
import software.amazon.awssdk.services.dynamodb.model.AttributeDefinition;
import software.amazon.awssdk.services.dynamodb.model.ScalarAttributeType;
import software.amazon.awssdk.services.dynamodb.model.WarmThroughput;
...

public static WarmThroughput buildWarmThroughput(final Long readUnitsPerSecond,
                                                 final Long writeUnitsPerSecond) {
    return WarmThroughput.builder()
            .readUnitsPerSecond(readUnitsPerSecond)
            .writeUnitsPerSecond(writeUnitsPerSecond)
            .build();
}
private static AttributeDefinition buildAttributeDefinition(final String attributeName, 
                                                            final ScalarAttributeType scalarAttributeType) {
    return AttributeDefinition.builder()
            .attributeName(attributeName)
            .attributeType(scalarAttributeType)
            .build();
}
private static KeySchemaElement buildKeySchemaElement(final String attributeName, 
                                                      final KeyType keyType) {
    return KeySchemaElement.builder()
            .attributeName(attributeName)
            .keyType(keyType)
            .build();
}
public static void createDynamoDBTable(DynamoDbClient ddb,
                                       String tableName,
                                       String partitionKey,
                                       String sortKey,
                                       String miscellaneousKeyAttribute,
                                       String nonKeyAttribute,
                                       Long tableReadCapacityUnits,
                                       Long tableWriteCapacityUnits,
                                       Long tableWarmReadUnitsPerSecond,
                                       Long tableWarmWriteUnitsPerSecond,
                                       String globalSecondaryIndexName,
                                       Long globalSecondaryIndexReadCapacityUnits,
                                       Long globalSecondaryIndexWriteCapacityUnits,
                                       Long globalSecondaryIndexWarmReadUnitsPerSecond,
                                       Long globalSecondaryIndexWarmWriteUnitsPerSecond) {

    // Define the table attributes
    final AttributeDefinition partitionKeyAttribute = buildAttributeDefinition(partitionKey, ScalarAttributeType.S);
    final AttributeDefinition sortKeyAttribute = buildAttributeDefinition(sortKey, ScalarAttributeType.S);
    final AttributeDefinition miscellaneousKeyAttributeDefinition = buildAttributeDefinition(miscellaneousKeyAttribute, ScalarAttributeType.N);
    final AttributeDefinition[] attributeDefinitions = {partitionKeyAttribute, sortKeyAttribute, miscellaneousKeyAttributeDefinition};

    // Define the table key schema
    final KeySchemaElement partitionKeyElement = buildKeySchemaElement(partitionKey, KeyType.HASH);
    final KeySchemaElement sortKeyElement = buildKeySchemaElement(sortKey, KeyType.RANGE);
    final KeySchemaElement[] keySchema = {partitionKeyElement, sortKeyElement};

    // Define the provisioned throughput for the table
    final ProvisionedThroughput provisionedThroughput = ProvisionedThroughput.builder()
            .readCapacityUnits(tableReadCapacityUnits)
            .writeCapacityUnits(tableWriteCapacityUnits)
            .build();

    // Define the Global Secondary Index (GSI)
    final KeySchemaElement globalSecondaryIndexPartitionKeyElement = buildKeySchemaElement(sortKey, KeyType.HASH);
    final KeySchemaElement globalSecondaryIndexSortKeyElement = buildKeySchemaElement(miscellaneousKeyAttribute, KeyType.RANGE);
    final KeySchemaElement[] gsiKeySchema = {globalSecondaryIndexPartitionKeyElement, globalSecondaryIndexSortKeyElement};

    final Projection gsiProjection = Projection.builder()
            .projectionType(String.valueOf(ProjectionType.INCLUDE))
            .nonKeyAttributes(nonKeyAttribute)
            .build();
    final ProvisionedThroughput gsiProvisionedThroughput = ProvisionedThroughput.builder()
            .readCapacityUnits(globalSecondaryIndexReadCapacityUnits)
            .writeCapacityUnits(globalSecondaryIndexWriteCapacityUnits)
            .build();
    // Define the warm throughput for the Global Secondary Index (GSI)
    final WarmThroughput gsiWarmThroughput = buildWarmThroughput(globalSecondaryIndexWarmReadUnitsPerSecond, globalSecondaryIndexWarmWriteUnitsPerSecond);
    final GlobalSecondaryIndex globalSecondaryIndex = GlobalSecondaryIndex.builder()
            .indexName(globalSecondaryIndexName)
            .keySchema(gsiKeySchema)
            .projection(gsiProjection)
            .provisionedThroughput(gsiProvisionedThroughput)
            .warmThroughput(gsiWarmThroughput)
            .build();

    // Define the warm throughput for the table
    final WarmThroughput tableWarmThroughput = buildWarmThroughput(tableWarmReadUnitsPerSecond, tableWarmWriteUnitsPerSecond);

    final CreateTableRequest request = CreateTableRequest.builder()
            .tableName(tableName)
            .attributeDefinitions(attributeDefinitions)
            .keySchema(keySchema)
            .provisionedThroughput(provisionedThroughput)
            .globalSecondaryIndexes(globalSecondaryIndex)
            .warmThroughput(tableWarmThroughput)
            .build();

    CreateTableResponse response = ddb.createTable(request);
    System.out.println(response);
}
```

------
#### [ Python ]

```
from boto3 import resource
from botocore.exceptions import ClientError

def create_dynamodb_table_warm_throughput(table_name, partition_key, sort_key, misc_key_attr, non_key_attr, table_provisioned_read_units, table_provisioned_write_units, table_warm_reads, table_warm_writes, gsi_name, gsi_provisioned_read_units, gsi_provisioned_write_units, gsi_warm_reads, gsi_warm_writes, region_name="us-east-1"):
    """
    Creates a DynamoDB table with a warm throughput setting configured.

    :param table_name: The name of the table to be created.
    :param partition_key: The partition key for the table being created.
    :param sort_key: The sort key for the table being created.
    :param misc_key_attr: A miscellaneous key attribute for the table being created.
    :param non_key_attr: A non-key attribute for the table being created.
    :param table_provisioned_read_units: The newly created table's provisioned read capacity units.
    :param table_provisioned_write_units: The newly created table's provisioned write capacity units.
    :param table_warm_reads: The read units per second setting for the table's warm throughput.
    :param table_warm_writes: The write units per second setting for the table's warm throughput.
    :param gsi_name: The name of the Global Secondary Index (GSI) to be created on the table.
    :param gsi_provisioned_read_units: The configured Global Secondary Index (GSI) provisioned read capacity units.
    :param gsi_provisioned_write_units: The configured Global Secondary Index (GSI) provisioned write capacity units.
    :param gsi_warm_reads: The read units per second setting for the Global Secondary Index (GSI)'s warm throughput.
    :param gsi_warm_writes: The write units per second setting for the Global Secondary Index (GSI)'s warm throughput.
    :param region_name: The AWS Region name to target. defaults to us-east-1
    """
    try:
        ddb = resource('dynamodb', region_name)
        
        # Define the table attributes
        attribute_definitions = [
            { "AttributeName": partition_key, "AttributeType": "S" },
            { "AttributeName": sort_key, "AttributeType": "S" },
            { "AttributeName": misc_key_attr, "AttributeType": "N" }
        ]
        
        # Define the table key schema
        key_schema = [
            { "AttributeName": partition_key, "KeyType": "HASH" },
            { "AttributeName": sort_key, "KeyType": "RANGE" }
        ]
        
        # Define the provisioned throughput for the table
        provisioned_throughput = {
            "ReadCapacityUnits": table_provisioned_read_units,
            "WriteCapacityUnits": table_provisioned_write_units
        }
        
        # Define the global secondary index
        gsi_key_schema = [
            { "AttributeName": sort_key, "KeyType": "HASH" },
            { "AttributeName": misc_key_attr, "KeyType": "RANGE" }
        ]
        gsi_projection = {
            "ProjectionType": "INCLUDE",
            "NonKeyAttributes": [non_key_attr]
        }
        gsi_provisioned_throughput = {
            "ReadCapacityUnits": gsi_provisioned_read_units,
            "WriteCapacityUnits": gsi_provisioned_write_units
        }
        gsi_warm_throughput = {
            "ReadUnitsPerSecond": gsi_warm_reads,
            "WriteUnitsPerSecond": gsi_warm_writes
        }
        global_secondary_indexes = [
            {
                "IndexName": gsi_name,
                "KeySchema": gsi_key_schema,
                "Projection": gsi_projection,
                "ProvisionedThroughput": gsi_provisioned_throughput,
                "WarmThroughput": gsi_warm_throughput
            }
        ]
        
        # Define the warm throughput for the table
        warm_throughput = {
            "ReadUnitsPerSecond": table_warm_reads,
            "WriteUnitsPerSecond": table_warm_writes
        }
        
        # Create the DynamoDB client and create the table
        response = ddb.create_table(
            TableName=table_name,
            AttributeDefinitions=attribute_definitions,
            KeySchema=key_schema,
            ProvisionedThroughput=provisioned_throughput,
            GlobalSecondaryIndexes=global_secondary_indexes,
            WarmThroughput=warm_throughput
        )
        
        print(response)
    except ClientError as e:
        print(f"Error creating table: {e}")
        raise e
```

------
#### [ Javascript ]

```
import { DynamoDBClient, CreateTableCommand } from "@aws-sdk/client-dynamodb";

async function createDynamoDBTableWithWarmThroughput(
  tableName,
  partitionKey,
  sortKey,
  miscKeyAttr,
  nonKeyAttr,
  tableProvisionedReadUnits,
  tableProvisionedWriteUnits,
  tableWarmReads,
  tableWarmWrites,
  indexName,
  indexProvisionedReadUnits,
  indexProvisionedWriteUnits,
  indexWarmReads,
  indexWarmWrites,
  region = "us-east-1"
) {
  try {
    const ddbClient = new DynamoDBClient({ region: region });
    const command = new CreateTableCommand({
      TableName: tableName,
      AttributeDefinitions: [
          { AttributeName: partitionKey, AttributeType: "S" },
          { AttributeName: sortKey, AttributeType: "S" },
          { AttributeName: miscKeyAttr, AttributeType: "N" },
      ],
      KeySchema: [
          { AttributeName: partitionKey, KeyType: "HASH" },
          { AttributeName: sortKey, KeyType: "RANGE" },
      ],
      ProvisionedThroughput: {
          ReadCapacityUnits: tableProvisionedReadUnits,
          WriteCapacityUnits: tableProvisionedWriteUnits,
      },
      WarmThroughput: {
          ReadUnitsPerSecond: tableWarmReads,
          WriteUnitsPerSecond: tableWarmWrites,
      },
      GlobalSecondaryIndexes: [
          {
            IndexName: indexName,
            KeySchema: [
                { AttributeName: sortKey, KeyType: "HASH" },
                { AttributeName: miscKeyAttr, KeyType: "RANGE" },
            ],
            Projection: {
                ProjectionType: "INCLUDE",
                NonKeyAttributes: [nonKeyAttr],
            },
            ProvisionedThroughput: {
                ReadCapacityUnits: indexProvisionedReadUnits,
                WriteCapacityUnits: indexProvisionedWriteUnits,
            },
            WarmThroughput: {
                ReadUnitsPerSecond: indexWarmReads,
                WriteUnitsPerSecond: indexWarmWrites,
            },
          },
      ],
    });
    const response = await ddbClient.send(command);
    console.log(response);
  } catch (error) {
    console.error(`Error creating table: ${error}`);
    throw error;
  }
}
```

------

# Compréhension du débit chaud DynamoDB dans différents scénarios
<a name="warm-throughput-scenarios"></a>

Voici quelques scénarios que vous êtes susceptible de rencontrer lors de l’utilisation du débit chaud DynamoDB.

**Topics**
+ [Débit chaud et modèles d’accès inégaux](#warm-throughput-scenarios-uneven)
+ [Débit chaud pour une table provisionnée](#warm-throughput-scenarios-provisioned)
+ [Débit chaud pour une table à la demande](#warm-throughput-scenarios-ondemand)
+ [Débit chaud pour une table à la demande avec un débit maximal configuré](#warm-throughput-scenarios-max)

## Débit chaud et modèles d’accès inégaux
<a name="warm-throughput-scenarios-uneven"></a>

Une table peut avoir un débit chaud de 30 000 unités de lecture par seconde et de 10 000 unités d’écriture par seconde, mais vous pouvez tout de même ressentir une limitation des lectures ou des écritures avant d’atteindre ces valeurs. Cela est probablement dû à une partition chaude. Bien que DynamoDB puisse continuer à évoluer pour prendre en charge un débit pratiquement illimité, chaque partition individuelle est limitée à 1 000 unités d’écriture par seconde et à 3 000 unités de lecture par seconde. Si votre application génère trop de trafic vers une petite partie des partitions de la table, la limitation peut avoir lieu avant même que vous n’atteigniez les valeurs de débit chaud de la table. Nous vous recommandons de suivre les [Bonnes pratiques DynamoDB](bp-partition-key-design.md) afin de garantir une capacité de mise à l’échelle sans faille et d’éviter les partitions critiques.

## Débit chaud pour une table provisionnée
<a name="warm-throughput-scenarios-provisioned"></a>

Imaginons une table provisionnée dont le débit chaud est de 30 000 unités de lecture par seconde et de 10 000 unités d’écriture par seconde, mais dont le débit provisionné est actuellement de 4 000 RCU et 8 000 WCU. Vous pouvez mettre à l’échelle instantanément le débit provisionné de la table jusqu’à 30 000 RCU ou 10 000 WCU en mettant à jour vos paramètres de débit provisionné. Lorsque vous augmentez le débit provisionné au-delà de ces valeurs, le débit chaud s’ajuste automatiquement aux nouvelles valeurs supérieures, car vous avez établi un nouveau débit de pointe. Par exemple, si vous définissez le débit provisionné sur 50 000 RCU, le débit chaud augmentera pour atteindre 50 000 unités de lecture par seconde.

```
"ProvisionedThroughput": 
    {
        "ReadCapacityUnits": 4000,
        "WriteCapacityUnits": 8000 
    }
"WarmThroughput": 
    { 
        "ReadUnitsPerSecond": 30000,
        "WriteUnitsPerSecond": 10000
    }
```

## Débit chaud pour une table à la demande
<a name="warm-throughput-scenarios-ondemand"></a>

Une nouvelle table à la demande utilise au début un débit chaud de 12 000 unités de lecture par seconde et de 4 000 unités d’écriture par seconde. Votre table peut instantanément accueillir un trafic soutenu jusqu’à ces niveaux. Lorsque vos demandes dépassent 12 000 unités de lecture par seconde ou 4 000 unités d’écriture par seconde, le débit chaud s’ajuste automatiquement aux valeurs les plus élevées.

```
"WarmThroughput": 
    { 
        "ReadUnitsPerSecond": 12000,
        "WriteUnitsPerSecond": 4000
    }
```

## Débit chaud pour une table à la demande avec un débit maximal configuré
<a name="warm-throughput-scenarios-max"></a>

Imaginons une table à la demande avec un débit moyen de 30 000 unités de lecture par seconde, mais avec un [débit maximal](on-demand-capacity-mode-max-throughput.md) configuré à 5 000 unités de demande de lecture (RRU). Dans ce scénario, le débit de la table sera limité au maximum de 5000 RRU que vous avez défini. Toute demande de débit dépassant ce maximum sera limitée. Cependant, vous pouvez modifier le débit maximal spécifique à la table à tout moment, en fonction des besoins de votre application.

```
"OnDemandThroughput": 
    {
        "MaxReadRequestUnits": 5000,
        "MaxWriteRequestUnits": 4000
    }
"WarmThroughput": 
    { 
        "ReadUnitsPerSecond": 30000,
        "WriteUnitsPerSecond": 10000
    }
```