AWS Certified Machine Learning - Specialty: Valid put_record request parameters

Valid put_record request parameters for Kinesis Data Streams

Question

You work as a machine learning specialist at a hedge fund.

You are working on a time-series price prediction model for the firm, and you have set up a data delivery stream using Amazon Kinesis Data Streams.

You are creating the data producer application code to take trade data from your trade system and send the trade records to your Kinesis Data Stream.

Your python code is structured as follows: import boto3 import requests import json client =boto3.client(‘kinesis', region_name='us-east1') while True: r = requests.get(‘https://trading-applicatio-url') data = json.dumps(r.json()) client.put_record( parameters needed for put_record api call ) ... Which of the following options are valid put_record request parameters? Select 3.

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D. E. F.

Answers: A, C, and E.

Options A, C and E are correct.

As documented in the Amazon Kinesis Data Streams API reference guide titled PutRecord, “The request accepts the following data in JSON format: Data, ExplicitHashKey, PartitionKey, SequenceNumberForOrdering, and StreamName”.

Option B is incorrect.

There is no ImplicitHashKey request parameter.

(See the Amazon Kinesis Data Streams API reference guide titled PutRecord)

Option D is incorrect.

There is no PartitionKeys request parameter.

However, there is a PartitionKey request parameter.

(See the Amazon Kinesis Data Streams API reference guide titled PutRecord)

Option F is incorrect.

There is no ShardId request parameter.

However, there is a ShardId response element.

(See the Amazon Kinesis Data Streams API reference guide titled PutRecord)

Reference:

Please see the Amazon Kinesis Data Streams developers guide titled Kinesis Data Stream Producers and the Amazon Kinesis Data Streams API reference guide titled PutRecord.

Sure, I'll be happy to explain the parameters that can be used in a put_record request to Kinesis Data Streams.

  1. Data: This parameter is mandatory and refers to the data that needs to be sent to the Kinesis Data Stream. The data must be in bytes, and the maximum size of data that can be sent in a single put_record request is 1 MB.

  2. PartitionKey: This parameter is mandatory and is used to determine the partition in which the record will be stored. Each partition key maps to a specific shard in the stream. The partition key is also used to group records that need to be processed together.

  3. ExplicitHashKey: This parameter is optional and can be used to explicitly specify the shard in which the record should be stored. This parameter is useful when you need to override the default hash key calculation that is used to determine the shard in which the record should be stored.

  4. ImplicitHashKey: This parameter is optional and is used when you want to enable Kinesis Data Streams to automatically determine the shard in which the record should be stored based on the partition key. This parameter is useful when you don't want to explicitly specify the shard in which the record should be stored.

  5. SequenceNumberForOrdering: This parameter is optional and is used when you want to enforce strict ordering of records within a shard. Each record that is sent to a shard is assigned a unique sequence number that is used to order the records within the shard.

  6. ShardId: This parameter is optional and is used to specify the shard ID to which the record should be sent. This parameter is useful when you want to explicitly send the record to a specific shard.

So, in the given code snippet, the valid put_record request parameters are Data, PartitionKeys, and ExplicitHashKey. These parameters are mandatory, and they are used to send data to a specific shard in a Kinesis Data Stream. The other parameters, ImplicitHashKey, SequenceNumberForOrdering, and ShardId are optional and are used to fine-tune the record placement and ordering within the shard.