@@ -221,46 +221,6 @@ Streams and write to DynamoDB) by assuming the role
221221ECSTaskConsumerRole01. This sample deployment uses 2 vCPU and 4 GB
222222memory to run the container.
223223
224- ### Kinesis capacity management
225-
226- When changes in the rate of data flow occur, you may have to increase or
227- decrease the capacity. With Kinesis Data Streams, you can have one or
228- more * hot shards* as a result of unevenly distributed partition keys,
229- very similar to a hot key in a database. This means that a certain shard
230- receives more traffic than others, and if it's overloaded, it produces a
231- ProvisionedThroughputExceededException (enable detailed monitoring to
232- see that metric on shard level).
233-
234- You need to split these hot shards to increase throughput, and merge
235- cold shards to increase efficiency. For this post, you use random
236- partition keys (and therefore random shard assignment) for the records,
237- so we don't dive deeper into splitting and merging specific shards.
238- Instead, we show how to increase and decrease throughput capacity for
239- the whole stream. For more information about scaling on a shard level,
240- see [ Strategies for
241- Resharding] ( https://docs.aws.amazon.com/streams/latest/dev/kinesis-using-sdk-java-resharding-strategies.html ) .
242-
243- You can build your own scaling application utilizing the
244- [ UpdateShardCount] ( https://docs.aws.amazon.com/kinesis/latest/APIReference/API_UpdateShardCount.html ) ,
245- [ SplitShard] ( https://docs.aws.amazon.com/kinesis/latest/APIReference/API_SplitShard.html ) ,
246- and
247- [ MergeShards] ( https://docs.aws.amazon.com/kinesis/latest/APIReference/API_MergeShards.html )
248- APIs or use the custom resource scaling solution as described in [ Scale
249- Amazon Kinesis Data Streams with AWS Application Auto
250- Scaling] ( https://aws.amazon.com/blogs/big-data/scaling-amazon-kinesis-data-streams-with-aws-application-auto-scaling/ )
251- or [ Amazon Kineis Scaling
252- Utils] ( https://github.com/awslabs/amazon-kinesis-scaling-utils ) .
253- The Application Auto Scaling is an event-driven scaling architecture
254- based on CloudWatch alarms, and the Scaling Utils is a Docker container
255- that constantly monitors your data stream. The Application Auto Scaling
256- manages the number of shards for scaling, whereas the Kinesis Scaling
257- Utils additionally handles shard keyspace allocations, hot shard
258- splitting, and cold shard merging. For this solution, you use the
259- Kinesis Scaling Utils and deploy it on Amazon ECS. You can also deploy
260- it on [ AWS Elastic
261- Beanstalk] ( https://aws.amazon.com/elasticbeanstalk ) as a container
262- or on an Apache Tomcat platform.
263-
264224## Prerequisites
265225
266226For this walkthrough, you must have an [ AWS
@@ -270,21 +230,20 @@ account](https://aws.amazon.com/premiumsupport/knowledge-center/create-and-activ
270230
271231In this post, we walk through the following steps:
272232
273- 1 . Deploying the CloudFormation template.
233+ 1 . Deploying the CDK Stack template.
274234
2752352 . Sending records to Kinesis Data Streams.
276236
2772373 . Monitoring your stream and applications.
278238
279- Deploying the CloudFormation template
280-
281- Deploy the CloudFormation stack by choosing ** Launch Stack** :
239+ #### Deploying the CDK Stack
282240
283- [ <img src =" https://s3.amazonaws.com/cloudformation-examples/cloudformation-launch-stack.png " >] ( https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/new?&templateURL=https://flomair-dataprocessor-source.s3-us-west-2.amazonaws.com/deployment.yaml )
241+ 1 . Clone the repository
242+ 2 . ` cd cdk `
243+ 3 . ` npm install `
244+ 4 . ` cdk deploy `
284245
285- The template launches in the US East (N. Virginia) Region by default. To
286- launch it in a different Region, use the Region selector in the console
287- navigation bar. The following Regions are supported:
246+ The following Regions are supported:
288247
289248- US East (Ohio)
290249
@@ -300,24 +259,12 @@ navigation bar. The following Regions are supported:
300259
301260- Europe (Ireland)
302261
303- Alternatively, you can download the [ CloudFormation
304- template] ( https://flomair-dataprocessor-source.s3-us-west-2.amazonaws.com/deployment.yaml )
305- and deploy it manually. When asked to provide an IPv4 CIDR range, enter
306- the CIDR range that can send records to your application. You can change
307- it later on by adapting the [ security groups inbound
308- rule] ( https://docs.aws.amazon.com/vpc/latest/userguide/VPC_SecurityGroups.html#AddRemoveRules )
309- for the Application Load Balancer.
310262
311263### Sending records to Kinesis Data Streams
312264
313265You have several options to send records to Kinesis Data Streams. You
314- can do it from the CLI or any API client that can send REST requests, or
315- use a load testing solution like [ Distributed Load Testing on
316- AWS] ( https://aws.amazon.com/solutions/distributed-load-testing-on-aws/ )
317- or [ Artillery] ( https://artillery.io/ ) . With load testing,
318- additional charges for requests occur; as a guideline, 10,000 requests
319- per second for 10 minutes generate an AWS bill of less than \$ 5.00. To
320- do a POST request via curl, run the following command and replace
266+ can do it from the CLI or any API client that can send REST requests.
267+ To do a POST request via curl, run the following command and replace
321268* ALB_ENDPOINT* with the DNS record of your Application Load Balancer.
322269You can find it on the CloudFormation stack's ** Outputs** tab. Ensure
323270you have a JSON element "data". Otherwise, the application can't process
@@ -364,20 +311,14 @@ For example, if you increase the value of RecordMaxBufferedTime, data
364311records are buffered longer at the producer, more records can be
365312aggregated, but the latency for ingestion is increased.
366313
367- All three applications (including the Kinesis Data Streams scaler)
368- publish logs to their respective log group (for example,
369- ecs/kinesis-data-processor-producer) in CloudWatch. You can either check
314+ All applications
315+ publish logs to their respective log group in CloudWatch. You can either check
370316the CloudWatch logs of the Auto Scaling Application or the data stream
371317metrics to see the scaling behavior of Kinesis Data Streams.
372318
373319### Cleaning up
374320
375- To avoid additional cost, ensure that the provisioned resources are
376- decommissioned. To do that, delete the images in the [ Amazon Elastic
377- Container Registry] ( http://aws.amazon.com/ecr/ ) (Amazon ECR)
378- repository, the CloudFormation stack, and any remaining resources that
379- the CloudFormation stack didn't automatically delete. Additionally,
380- delete the DynamoDB table DataProcessorConsumer, which the KCL created.
321+ Run the command ` cdk destroy ` from the cdk directory.
381322
382323## Conclusion
383324
0 commit comments