Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Manage data shards using the Kinesis Data Streams API and the AWS SDK for PHP Version 3 - AWS SDK for PHP

Manage data shards using the Kinesis Data Streams API and the AWS SDK for PHP Version 3

Amazon Kinesis Data Streams enables you to send real-time data to an endpoint. The rate of data flow depends on the number of shards in your stream.

You can write 1,000 records per second to a single shard. Each shard also has an upload limit of 1 MiB per second. Usage is calculated and charged on a per-shard basis, so use these examples to manage the data capacity and cost of your stream.

The following examples show how to:

All the example code for the AWS SDK for PHP is available here on GitHub.

Credentials

Before running the example code, configure your AWS credentials, as described in Credentials. Then import the AWS SDK for PHP, as described in Basic usage.

For more information about using Amazon Kinesis Data Streams, see the Amazon Kinesis Data Streams Developer Guide.

List data stream shards

List the details of up to 100 shards in a specific stream.

To list the shards in a Kinesis data stream, use the ListShards operation.

Imports

require 'vendor/autoload.php'; use Aws\Exception\AwsException;

Sample Code

$kinesisClient = new Aws\Kinesis\KinesisClient([ 'profile' => 'default', 'version' => '2013-12-02', 'region' => 'us-east-2' ]); $name = "my_stream_name"; try { $result = $kinesisClient->ListShards([ 'StreamName' => $name, ]); var_dump($result); } catch (AwsException $e) { // output error message if fails echo $e->getMessage(); echo "\n"; }

Add more data stream shards

If you need more data stream shards, you can increase your current number of shards. We recommend that you double your shard count when increasing. This makes a copy of each shard currently available to increase your capacity. You can double the number of your shards only twice in one 24-hour period.

Remember that billing for Kinesis Data Streams usage is calculated per shard, so when demand decreases, we recommend that you reduce your shard count by half. When you remove shards, you can only scale down the amount of shards to half of your current shard count.

To update the shard count of a Kinesis data stream, use the UpdateShardCount operation.

Imports

require 'vendor/autoload.php'; use Aws\Exception\AwsException;

Sample Code

$kinesisClient = new Aws\Kinesis\KinesisClient([ 'profile' => 'default', 'version' => '2013-12-02', 'region' => 'us-east-2' ]); $name = "my_stream_name"; $totalshards = 4; try { $result = $kinesisClient->UpdateShardCount([ 'ScalingType' => 'UNIFORM_SCALING', 'StreamName' => $name, 'TargetShardCount' => $totalshards ]); var_dump($result); } catch (AwsException $e) { // output error message if fails echo $e->getMessage(); echo "\n"; }
PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.