Giter Club home page Giter Club logo

awslabs / amazon-kinesis-scaling-utils Goto Github PK

View Code? Open in Web Editor NEW
334.0 47.0 95.0 306.9 MB

The Kinesis Scaling Utility is designed to give you the ability to scale Amazon Kinesis Streams in the same way that you scale EC2 Auto Scaling groups – up or down by a count or as a percentage of the total fleet. You can also simply scale to an exact number of Shards. There is no requirement for you to manage the allocation of the keyspace to Shards when using this API, as it is done automatically.

License: Apache License 2.0

Shell 1.72% HTML 0.10% CSS 1.80% Java 95.76% Dockerfile 0.61%

amazon-kinesis-scaling-utils's Introduction

amazon-kinesis-scaling-utils

The Kinesis Scaling Utility is designed to give you the ability to scale Amazon Kinesis Streams in the same way that you scale EC2 Auto Scaling groups – up or down by a count or as a percentage of the total fleet. You can also simply scale to an exact number of Shards. There is no requirement for you to manage the allocation of the keyspace to Shards when using this API, as it is done automatically.

You can also deploy the Web Archive to a Java Application Server, and allow Scaling Utils to automatically manage the number of Shards in the Stream based on the observed PUT or GET rate of the stream.

Manually Managing your Stream

You can manually run the Scaling Utility from the command line by calling the ScalingClient with the following syntax.

java -cp KinesisScalingUtils-complete.jar -Dstream-name=MyStream -Dscaling-action=scaleUp -Dcount=10 -Dregion=eu-west-1 -Dwait-for-completion=true ScalingClient

Options: 
stream-name - The name of the Stream to be scaled
scaling-action - The action to be taken to scale. Must be one of "scaleUp", "scaleDown", "resize", or "report"
count - Number of shards by which to absolutely scale up or down, or resize to or:
pct - Percentage of the existing number of shards by which to scale up or down
min-shards - The minimum number of shards to maintain
max-shards - The maximum number of shards which will cap the scaling operation
region - The Region where the Stream exists, such as us-east-1 or eu-west-1 (default us-east-1)
shard-id - The Shard which you want to target for Scaling. NOTE: This will create imbalanced partitioning of the Keyspace
wait-for-completion - Set to false to return as soon as the operation has been completed, and not wait until the Stream returns to status 'Active'

Here are some useful shortcuts:

Scale a Stream up by 10 Shards

java -cp dist/KinesisScalingUtils-complete.jar -Dstream-name=MyStream -Dscaling-action=scaleUp -Dcount=10 -Dregion=eu-west-1 ScalingClient

Generate a report of Shard Keyspace Sizing

java -cp dist/KinesisScalingUtils-complete.jar -Dstream-name=MyStream -Dscaling-action=report -Dregion=eu-west-1 ScalingClient

Scale up a specific Shard by making it into 3 equally sized Shards

java -cp dist/KinesisScalingUtils-complete.jar -Dstream-name=MyStream -Dscaling-action=scaleUp -Dcount=3 -Dshard-id=shard-0000000000 -Dregion=eu-west-1 ScalingClient

Automatic Scaling

The Kinesis Autoscaling WAR can be deployed as an Elastic Beanstalk application, or to any Java application server, and once configured will monitor the CloudWatch statistics for your Stream and scale up and down as you configure it.

Architecture

Below you can see a graph of how Autoscaling will keep adequate Shard capacity to deal with PUT or GET demand:

AutoscalingGraph

To get started, create a new Elastic Beanstalk application which is a Web Server with a Tomcat predefined configuration. Deploy the WAR by uploading from your local GitHub copy of dist/KinesisAutoscaling-.9.8.8.war, or using the following S3 URLs:

region S3 Path
ap-northeast-1 https://s3.ap-northeast-1.amazonaws.com/awslabs-code-ap-northeast-1/KinesisAutoscaling/KinesisAutoscaling-.9.8.8.war
ap-northeast-2 https://s3.ap-northeast-2.amazonaws.com/awslabs-code-ap-northeast-2/KinesisAutoscaling/KinesisAutoscaling-.9.8.8.war
ap-south-1 https://s3.ap-south-1.amazonaws.com/awslabs-code-ap-south-1/KinesisAutoscaling/KinesisAutoscaling-.9.8.8.war
ap-southeast-1 https://s3.ap-southeast-1.amazonaws.com/awslabs-code-ap-southeast-1/KinesisAutoscaling/KinesisAutoscaling-.9.8.8.war
ap-southeast-2 https://s3.ap-southeast-2.amazonaws.com/awslabs-code-ap-southeast-2/KinesisAutoscaling/KinesisAutoscaling-.9.8.8.war
ca-central-1 https://s3.ca-central-1.amazonaws.com/awslabs-code-ca-central-1/KinesisAutoscaling/KinesisAutoscaling-.9.8.8.war
eu-central-1 https://s3.eu-central-1.amazonaws.com/awslabs-code-eu-central-1/KinesisAutoscaling/KinesisAutoscaling-.9.8.8.war
eu-west-1 https://s3.eu-west-1.amazonaws.com/awslabs-code-eu-west-1/KinesisAutoscaling/KinesisAutoscaling-.9.8.8.war
eu-west-2 https://s3.eu-west-2.amazonaws.com/awslabs-code-eu-west-2/KinesisAutoscaling/KinesisAutoscaling-.9.8.8.war
sa-east-1 https://s3.sa-east-1.amazonaws.com/awslabs-code-sa-east-1/KinesisAutoscaling/KinesisAutoscaling-.9.8.8.war
us-east-1 https://s3.us-east-1.amazonaws.com/awslabs-code-us-east-1/KinesisAutoscaling/KinesisAutoscaling-.9.8.8.war
us-east-2 https://s3.us-east-2.amazonaws.com/awslabs-code-us-east-2/KinesisAutoscaling/KinesisAutoscaling-.9.8.8.war
us-west-1 https://s3.us-west-1.amazonaws.com/awslabs-code-us-west-1/KinesisAutoscaling/KinesisAutoscaling-.9.8.8.war
us-west-2 https://s3.us-west-2.amazonaws.com/awslabs-code-us-west-2/KinesisAutoscaling/KinesisAutoscaling-.9.8.8.war

Once deployed, you must configure the Autoscaling engine by providing a JSON configuration file on an HTTP or S3 URL. The structure of this configuration file is as follows:

[streamMonitor1, streamMonitor2...streamMonitorN]

a streamMonitor object is a definition of an Autoscaling Policy applied to a Kinesis Stream, and this array allows a single Autoscaling Web App to monitor multiple streams. A streamMonitor object is configured by:

{"streamName":"String - name of the Stream to be Monitored",
 "region":"String - a Valid AWS Region Code, such as us-east-1 or eu-west-1",
 "scaleOnOperation":"List<String> - the types of metric to be monitored, including PUT or GET. Both PutRecord and PutRecords are monitored with PUT",
 "minShards":"Integer - the minimum number of Shards to maintain in the Stream at all times",
 "maxShards":"Integer - the maximum number of Shards to have in the Stream regardless of capacity used",
 "refreshShardsNumberAfterMin":"Integer - minutes interval after which the Stream Monitor should refresh the Shard count on the stream, to accomodate manual scaling activities. If unset, defaults to 10 minutes",
 "checkInterval":"seconds to sleep after checking metrics until next check"
 "scaleUp": {
     "scaleThresholdPct":Integer - at what threshold we should scale up,
     "scaleAfterMins":Integer - how many minutes above the scaleThresholdPct we should wait before scaling up,
     "scaleCount":Integer - number of Shards to scale up by (prevails over scalePct),
     "scalePct":Integer - % of current Stream capacity to scale up by,
     "coolOffMins":Integer - number of minutes to wait after a Stream scale up before we scale up again,
     "notificationARN" : String - the ARN of an SNS Topic to send notifications to after a scaleUp action has been taken
 },
 "scaleDown":{
     "scaleThresholdPct":Integer - at what threshold we should scale down,
     "scaleAfterMins":Integer - how many minutes below the scaleThresholdPct we should wait before scaling down,
     "scaleCount":Integer - number of Shards to scale down by (prevails over scalePct),
     "scalePct":Integer - % of current Stream capacity to scale down by,
     "coolOffMins":Integer - number of minutes to wait after a Stream scale down before we scale down again,
     "notificationARN" : String - the ARN of an SNS Topic to send notifications to after a scaleDown action has been taken
 }
}

once you've built the Autoscaling configuration required, save it to an HTTP file server or to Amazon S3. Then, access your Elastic Beanstalk application, and select 'Configuration' from the left hand Navigation Menu. Then select the 'Software Configuration' panel, and add a new configuration item called config-file-url that points to the URL of the configuration file. Acceptable formats are 'http://path to file' or 's3://bucket/path to file'. Save the configuration, and then check the application logs for correct operation.

Json Configuration Examples

Using scale count

[
    {  
       "streamName":"streamName",
       "region":"regionName",
       "scaleOnOperation": ["PUT","GET"],
       "minShards":1,
       "maxShards":16,
       "refreshShardsNumberAfterMin":5,
       "checkInterval":300,
       "scaleUp": {
            "scaleThresholdPct": 75,
            "scaleAfterMins": 5,
            "scaleCount": 1,
            "coolOffMins": 15,
            "notificationARN": "arn:aws:sns:region:accountId:topicName"
        },
        "scaleDown": {
            "scaleThresholdPct": 25,
            "scaleAfterMins": 15,
            "scaleCount": 1,
            "coolOffMins": 60,
            "notificationARN": "arn:aws:sns:region:accountId:topicName"
        }
    }
]

Using scale percentage

[
    {  
       "streamName":"streamName",
       "region":"regionName",
       "scaleOnOperation": ["PUT","GET"],
       "minShards":1,
       "maxShards":16,
       "refreshShardsNumberAfterMin":5,
       "checkInterval":300,
       "scaleUp": {
            "scaleThresholdPct": 75,
            "scaleAfterMins": 5,
            "scalePct": 150,
            "coolOffMins": 15,
            "notificationARN": "arn:aws:sns:region:accountId:topicName"
        },
        "scaleDown": {
            "scaleThresholdPct": 25,
            "scaleAfterMins": 1,
            "scaleAfterMins": 15,
            "scalePct": 25,
            "coolOffMins": 60,
            "notificationARN": "arn:aws:sns:region:accountId:topicName"
        }
    }
]

Note that when scaling up, scalePct adds scalePct of the current capacity to the existing shard count of the stream. This means that, given the above config were triggered with a stream containing 75 shards, the scale up event would add 113 shards (ceil(1.5 * 75), where 1.5 is the float representation of scalePct: 150 above) to the existing capacity of the stream, meaning that we'd end up with a stream with 188 shards.

As of version .9.8.8, any scalePct for scaling up will be used literally, so with a Stream of 1 shard, even a scalePct of 1 will result in a new Shard being added.

When scaling down, the autoscaler does something similar, but in reverse. Assuming a scale down event is triggered with the above config on a stream with 75 shards, the scaler will subtract 19 shards (ceil(0.25 * 75) from the existing capacity of the stream, so we'd end up with 56 shards after our scale down is triggered.

As of version .9.8.8, the behaviour of scalePct above and below 100% has been rationalised, meaning that in a scaleDown config, a scalePct value of 50 will logically be treated the same as 200. Please validate your configurations to ensure that this doesn't change the desired target Shard count. You can view a wide array of examples of scale up/down behaviour in TestScalingUtils.java.

Autoscaling on Puts & Gets

From version .9.5.0, Autoscaling added the ability to scale on the basis of PUT and GET utilisation. This change means that you carefully have to consider your actual utilisation of each metric prior to configuring autoscaling with both metrics. For information on how the AutoScaling module will react with both metrics, consider the following table:

PUT
Range Below In Above
GET Below Down Do Nothing Up
In Do Nothing Do Nothing Up
Above Up Up Up

Monitoring Autoscaling

To determine if the service is running, you can simply make an HTTP request to the host on which you run autoscaling. If you get an HTTP 200, then it's running. However, if there was a problem with system setup, from version .9.5.9, the service will exit with a fatal error, and this will return an HTTP 503. If you wish to suppress this behaviour, then please set configuration value suppress-abort-on-fatal and the system will stay up, but not working as expected.

amazon-kinesis-scaling-utils's People

Contributors

atorstling avatar avram avatar az3 avatar barneagal avatar bryant1410 avatar cesar-manrique avatar cesarmanriqueh avatar dependabot[bot] avatar f-ganz avatar fblundun avatar glissand0 avatar hyandell avatar ianmeyers avatar imcdnzl avatar mahmedk91 avatar moskyb avatar ngoyal16 avatar patriziomunzi avatar rohitnair avatar shmick avatar smallo avatar tsein-bc avatar yegeniy avatar yisheng-liang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

amazon-kinesis-scaling-utils's Issues

Request - publish to Maven

Hi
I couldn't find this on Maven Central, any chance you can push it there? it'll make our (java devs) life much simpler

Thanks
Gal

Kinesis autoscaling application not working

Unfortunately I don't have a more descriptive title for this ticket. I'll describe what I've done so far. I am using version 0.9.1.5.

Using Elastic Beanstalk, I installed the Kinesis Autoscaling WAR to a Web Server with Tomcat predefined configuration. Here is my autoscaling configuration:

[
    {
        "streamName":"mytest",
         "region":"us-east-1",
         "scaleOnOperation":"PUT",
         "scaleUp": {
            "scaleThresholdPct": 90,
            "scaleAfterMins": 5,
            "scaleCount": 2
        },
        "scaleDown":{
            "scaleThresholdPct": 50,
            "scaleAfterMins": 5,
            "scaleCount": 2,
            "coolOffMins": 2
        }
    },
    {
        "streamName":"mytest",
         "region":"us-east-1",
         "scaleOnOperation":"GET",
         "scaleUp": {
            "scaleThresholdPct": 90,
            "scaleAfterMins": 5,
            "scaleCount": 2
        },
        "scaleDown":{
            "scaleThresholdPct": 50,
            "scaleAfterMins": 5,
            "scaleCount": 2,
            "coolOffMins": 2
        }
    }
]

I created the mytest stream with 6 shards. There is absolutely no data being pushed through the stream. I would expect the stream to be downscaled to 1 shard over the last weekend, but this morning I'm still seeing 6 shards. I am hosting the configuration on S3, and I've set the permissions on the file such that anyone can download it. So the application should have access to grab the config.

Within the Configuration/Software Configuration settings in the EB application, I have provided values for:

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_KEY
  • config_file_url

The format of the config_file_url value is https://s3.amazonaws.com/my-bucket/kin-scale-config.json. The AWS keys are the keys for the account that created the Kinesis stream.

I can get the logs from the EB instance. Everything looks fine, there are no errors obvious to me. Sensitive data has been omitted:

-------------------------------------
/var/log/eb-version-deployment.log
-------------------------------------
2015-03-27 20:47:34,705 [INFO] Found the latest version manifest file <Key: elasticbeanstalk-us-east-1-OMIT,resources/environments/e-OMIT/_runtime/versions/manifest_OMIT> from bucket elasticbeanstalk-us-east-1-OMIT and prefix resources/environments/e-OMIT/_runtime/versions/
2015-03-27 20:47:34,751 [INFO] Downloaded the manifest file to /tmp/version_file_manifest
2015-03-27 20:47:35,060 [INFO] Downloaded version label First Release from s3 key <Key: elasticbeanstalk-us-east-1-OMIT,resources/environments/e-OMIT/_runtime/_versions/mytest/First Release>



-------------------------------------
/var/log/tomcat8/manager.2015-03-27.log
-------------------------------------




-------------------------------------
/var/log/httpd/error_log
-------------------------------------
[Mon Mar 30 14:01:01 2015] [notice] Digest: generating secret for digest authentication ...
[Mon Mar 30 14:01:01 2015] [notice] Digest: done
[Mon Mar 30 14:01:02 2015] [notice] Apache/2.2.29 (Unix) DAV/2 configured -- resuming normal operations



-------------------------------------
/var/log/tomcat8/localhost.2015-03-27.log
-------------------------------------




-------------------------------------
/var/log/tomcat8/catalina.2015-03-27.log
-------------------------------------




-------------------------------------
/var/log/tomcat8/tomcat8-initd.log
-------------------------------------




-------------------------------------
/var/log/tomcat8/localhost_access_log.txt
-------------------------------------




-------------------------------------
/var/log/eb-activity.log
-------------------------------------
[2015-03-27T20:53:46.781Z] INFO  [1887]  - [CMD-ConfigDeploy] : Completed activity. Result:
  Command CMD-ConfigDeploy succeeded.
[2015-03-27T20:54:41.929Z] INFO  [2071]  - [CMD-TailLogs] : Starting activity...
[2015-03-27T20:54:42.422Z] INFO  [2071]  - [CMD-TailLogs/AddonsBefore] : Starting activity...
[2015-03-27T20:54:42.422Z] INFO  [2071]  - [CMD-TailLogs/AddonsBefore] : Completed activity.
[2015-03-27T20:54:42.423Z] INFO  [2071]  - [CMD-TailLogs/TailLogs] : Starting activity...
[2015-03-27T20:54:42.423Z] INFO  [2071]  - [CMD-TailLogs/TailLogs/TailLogs] : Starting activity...
[2015-03-27T20:54:42.972Z] INFO  [2071]  - [CMD-TailLogs/TailLogs/TailLogs] : Completed activity.
[2015-03-27T20:54:42.973Z] INFO  [2071]  - [CMD-TailLogs/TailLogs] : Completed activity. Result:
  Command CMD-TailLogs stage 0 completed.
[2015-03-27T20:54:42.973Z] INFO  [2071]  - [CMD-TailLogs/AddonsAfter] : Starting activity...
[2015-03-27T20:54:42.973Z] INFO  [2071]  - [CMD-TailLogs/AddonsAfter] : Completed activity.
[2015-03-27T20:54:42.973Z] INFO  [2071]  - [CMD-TailLogs] : Completed activity. Result:
  Command CMD-TailLogs succeeded.
[2015-03-27T20:57:37.249Z] INFO  [2109]  - [CMD-BundleLogs] : Starting activity...
[2015-03-27T20:57:37.756Z] INFO  [2109]  - [CMD-BundleLogs/AddonsBefore] : Starting activity...
[2015-03-27T20:57:37.756Z] INFO  [2109]  - [CMD-BundleLogs/AddonsBefore] : Completed activity.
[2015-03-27T20:57:37.757Z] INFO  [2109]  - [CMD-BundleLogs/BundleLogs] : Starting activity...
[2015-03-27T20:57:37.757Z] INFO  [2109]  - [CMD-BundleLogs/BundleLogs/BundleLogs] : Starting activity...
[2015-03-27T20:57:38.148Z] INFO  [2109]  - [CMD-BundleLogs/BundleLogs/BundleLogs] : Completed activity.
[2015-03-27T20:57:38.148Z] INFO  [2109]  - [CMD-BundleLogs/BundleLogs] : Completed activity. Result:
  Command CMD-BundleLogs stage 0 completed.
[2015-03-27T20:57:38.149Z] INFO  [2109]  - [CMD-BundleLogs/AddonsAfter] : Starting activity...
[2015-03-27T20:57:38.149Z] INFO  [2109]  - [CMD-BundleLogs/AddonsAfter] : Completed activity.
[2015-03-27T20:57:38.149Z] INFO  [2109]  - [CMD-BundleLogs] : Completed activity. Result:
  Command CMD-BundleLogs succeeded.
[2015-03-27T21:04:27.206Z] INFO  [2219]  - [CMD-TailLogs] : Starting activity...
[2015-03-27T21:04:27.701Z] INFO  [2219]  - [CMD-TailLogs/AddonsBefore] : Starting activity...
[2015-03-27T21:04:27.701Z] INFO  [2219]  - [CMD-TailLogs/AddonsBefore] : Completed activity.
[2015-03-27T21:04:27.702Z] INFO  [2219]  - [CMD-TailLogs/TailLogs] : Starting activity...
[2015-03-27T21:04:27.702Z] INFO  [2219]  - [CMD-TailLogs/TailLogs/TailLogs] : Starting activity...
[2015-03-27T21:04:28.114Z] INFO  [2219]  - [CMD-TailLogs/TailLogs/TailLogs] : Completed activity.
[2015-03-27T21:04:28.114Z] INFO  [2219]  - [CMD-TailLogs/TailLogs] : Completed activity. Result:
  Command CMD-TailLogs stage 0 completed.
[2015-03-27T21:04:28.115Z] INFO  [2219]  - [CMD-TailLogs/AddonsAfter] : Starting activity...
[2015-03-27T21:04:28.115Z] INFO  [2219]  - [CMD-TailLogs/AddonsAfter] : Completed activity.
[2015-03-27T21:04:28.115Z] INFO  [2219]  - [CMD-TailLogs] : Completed activity. Result:
  Command CMD-TailLogs succeeded.
[2015-03-27T21:15:45.265Z] INFO  [2321]  - [CMD-ConfigDeploy] : Starting activity...
[2015-03-27T21:15:45.776Z] INFO  [2321]  - [CMD-ConfigDeploy/AddonsBefore] : Starting activity...
[2015-03-27T21:15:45.776Z] INFO  [2321]  - [CMD-ConfigDeploy/AddonsBefore] : Completed activity.
[2015-03-27T21:15:45.776Z] INFO  [2321]  - [CMD-ConfigDeploy/ConfigDeployStage0] : Starting activity...
[2015-03-27T21:15:45.777Z] INFO  [2321]  - [CMD-ConfigDeploy/ConfigDeployStage0/InfraWriteConfig] : Starting activity...
[2015-03-27T21:15:45.785Z] INFO  [2321]  - [CMD-ConfigDeploy/ConfigDeployStage0/InfraWriteConfig] : Completed activity. Result:
  Recreated directory /opt/elasticbeanstalk/deploy/configuration/.
  Generate appsource url file at /opt/elasticbeanstalk/deploy/configuration/appsourceurl.
  Generate container config file at /opt/elasticbeanstalk/deploy/configuration/containerconfiguration.
[2015-03-27T21:15:45.785Z] INFO  [2321]  - [CMD-ConfigDeploy/ConfigDeployStage0/ConfigDeployPreHook] : Starting activity...
[2015-03-27T21:15:45.786Z] INFO  [2321]  - [CMD-ConfigDeploy/ConfigDeployStage0/ConfigDeployPreHook/01clean.sh] : Starting activity...
[2015-03-27T21:15:45.989Z] INFO  [2321]  - [CMD-ConfigDeploy/ConfigDeployStage0/ConfigDeployPreHook/01clean.sh] : Completed activity. Result:
  ++ /opt/elasticbeanstalk/bin/get-config container -k config_staging_dir
  + EB_CONFIG_STAGING_DIR=/tmp/deployment/config
  + rm -rf /tmp/deployment/config
  + mkdir -p /tmp/deployment/config
[2015-03-27T21:15:45.990Z] INFO  [2321]  - [CMD-ConfigDeploy/ConfigDeployStage0/ConfigDeployPreHook/04config_generate.sh] : Starting activity...
[2015-03-27T21:15:46.651Z] INFO  [2321]  - [CMD-ConfigDeploy/ConfigDeployStage0/ConfigDeployPreHook/04config_generate.sh] : Completed activity. Result:
  + /opt/elasticbeanstalk/containerfiles/generate_config
[2015-03-27T21:15:46.651Z] INFO  [2321]  - [CMD-ConfigDeploy/ConfigDeployStage0/ConfigDeployPreHook] : Completed activity. Result:
  Successfully execute directory: /opt/elasticbeanstalk/hooks/configdeploy/pre.
[2015-03-27T21:15:46.652Z] INFO  [2321]  - [CMD-ConfigDeploy/ConfigDeployStage0] : Completed activity. Result:
  Command CMD-ConfigDeploy stage 0 completed.
[2015-03-27T21:15:46.652Z] INFO  [2321]  - [CMD-ConfigDeploy/ConfigDeployStage1] : Starting activity...
[2015-03-27T21:15:46.652Z] INFO  [2321]  - [CMD-ConfigDeploy/ConfigDeployStage1/ConfigDeployEnactHook] : Starting activity...
[2015-03-27T21:15:46.653Z] INFO  [2321]  - [CMD-ConfigDeploy/ConfigDeployStage1/ConfigDeployEnactHook/01deploy.sh] : Starting activity...
[2015-03-27T21:15:47.214Z] INFO  [2321]  - [CMD-ConfigDeploy/ConfigDeployStage1/ConfigDeployEnactHook/01deploy.sh] : Completed activity. Result:
  ++ /opt/elasticbeanstalk/bin/get-config container -k config_staging_dir
  + EB_CONFIG_STAGING_DIR=/tmp/deployment/config
  ++ /opt/elasticbeanstalk/bin/get-config container -k config_deploy_dir
  + EB_CONFIG_DEPLOY_DIR=/etc/sysconfig
  ++ /opt/elasticbeanstalk/bin/get-config container -k config_filename
  + EB_CONFIG_FILENAME=tomcat8
  + cp /tmp/deployment/config/tomcat8 /etc/sysconfig/tomcat8
[2015-03-27T21:15:47.214Z] INFO  [2321]  - [CMD-ConfigDeploy/ConfigDeployStage1/ConfigDeployEnactHook] : Completed activity. Result:
  Successfully execute directory: /opt/elasticbeanstalk/hooks/configdeploy/enact.
[2015-03-27T21:15:47.215Z] INFO  [2321]  - [CMD-ConfigDeploy/ConfigDeployStage1/ConfigDeployPostHook] : Starting activity...
[2015-03-27T21:15:47.215Z] INFO  [2321]  - [CMD-ConfigDeploy/ConfigDeployStage1/ConfigDeployPostHook/01restart.sh] : Starting activity...
[2015-03-27T21:15:49.438Z] INFO  [2321]  - [CMD-ConfigDeploy/ConfigDeployStage1/ConfigDeployPostHook/01restart.sh] : Completed activity. Result:
  + [[ '' != \t\r\u\e ]]
  ++ /opt/elasticbeanstalk/bin/get-config container -k tomcat_version
  + TOMCAT_VERSION=8
  + TOMCAT_NAME=tomcat8
  + /usr/bin/monit unmonitor tomcat
  + /etc/init.d/tomcat8 stop
  Stopping tomcat8: [  OK  ]
+ /etc/init.d/tomcat8 start
  Starting tomcat8: [  OK  ]
+ /usr/bin/monit monitor tomcat
[2015-03-27T21:15:49.438Z] INFO  [2321]  - [CMD-ConfigDeploy/ConfigDeployStage1/ConfigDeployPostHook] : Completed activity. Result:
  Successfully execute directory: /opt/elasticbeanstalk/hooks/configdeploy/post.
[2015-03-27T21:15:49.439Z] INFO  [2321]  - [CMD-ConfigDeploy/ConfigDeployStage1] : Completed activity. Result:
  Command CMD-ConfigDeploy stage 1 completed.
[2015-03-27T21:15:49.439Z] INFO  [2321]  - [CMD-ConfigDeploy/AddonsAfter] : Starting activity...
[2015-03-27T21:15:49.439Z] INFO  [2321]  - [CMD-ConfigDeploy/AddonsAfter] : Completed activity.
[2015-03-27T21:15:49.439Z] INFO  [2321]  - [CMD-ConfigDeploy] : Completed activity. Result:
  Command CMD-ConfigDeploy succeeded.
[2015-03-30T14:17:00.023Z] INFO  [19451] - [CMD-TailLogs] : Starting activity...
[2015-03-30T14:17:00.530Z] INFO  [19451] - [CMD-TailLogs/AddonsBefore] : Starting activity...
[2015-03-30T14:17:00.530Z] INFO  [19451] - [CMD-TailLogs/AddonsBefore] : Completed activity.
[2015-03-30T14:17:00.530Z] INFO  [19451] - [CMD-TailLogs/TailLogs] : Starting activity...
[2015-03-30T14:17:00.530Z] INFO  [19451] - [CMD-TailLogs/TailLogs/TailLogs] : Starting activity...



-------------------------------------
/var/log/httpd/elasticbeanstalk-access_log
-------------------------------------




-------------------------------------
/var/log/httpd/access_log
-------------------------------------




-------------------------------------
/var/log/eb-commandprocessor.log
-------------------------------------
[2015-03-27T20:57:37.756Z] DEBUG [2109]  : Loaded definition of Command CMD-BundleLogs.
[2015-03-27T20:57:37.756Z] INFO  [2109]  : Executing command CMD-BundleLogs activities...
[2015-03-27T20:57:37.756Z] DEBUG [2109]  : Setting environment variables..
[2015-03-27T20:57:37.756Z] INFO  [2109]  : Running AddonsBefore for command CMD-BundleLogs...
[2015-03-27T20:57:37.757Z] DEBUG [2109]  : Running stages of Command CMD-BundleLogs from stage 0 to stage 0...
[2015-03-27T20:57:37.757Z] INFO  [2109]  : Running stage 0 of command CMD-BundleLogs...
[2015-03-27T20:57:37.757Z] DEBUG [2109]  : Loaded 1 actions for stage 0.
[2015-03-27T20:57:37.757Z] INFO  [2109]  : Running 1 of 1 actions: BundleLogs...
[2015-03-27T20:57:38.148Z] INFO  [2109]  : Running AddonsAfter for command CMD-BundleLogs...
[2015-03-27T20:57:38.149Z] INFO  [2109]  : Command CMD-BundleLogs succeeded!
[2015-03-27T20:57:38.150Z] INFO  [2109]  : Command processor returning results:
{"status":"SUCCESS","api_version":"1.0","truncated":"false","results":[{"status":"SUCCESS","msg":"","returncode":0,"events":[{"msg":"[Instance: i-OMIT] Successfully finished bundling 26 log(s)","severity":"INFO","timestamp":1427489858150}]}]}
[2015-03-27T21:04:27.200Z] DEBUG [2219]  : Reading config file: /etc/elasticbeanstalk/.aws-eb-stack.properties
[2015-03-27T21:04:27.201Z] INFO  [2219]  : Received command CMD-TailLogs: {"command_name":"CMD-TailLogs","execution_data":"{\"aws_access_key_id\":\"OMIT\",\"policy\":\"OMIT==\",\"security_token\":\"OMIT\",\"signature\":\"OMIT\"}","request_id":"OMIT","resource_name":"AWSEBAutoScalingGroup","data":"OMIT","command_timeout":"600","api_version":"1.0"}
[2015-03-27T21:04:27.201Z] DEBUG [2219]  : Checking if the command processor should execute.
[2015-03-27T21:04:27.205Z] DEBUG [2219]  : Checking whether the command is applicable to instance (i-OMIT)..
[2015-03-27T21:04:27.205Z] INFO  [2219]  : Command is applicable to this instance (i-OMIT)..
[2015-03-27T21:04:27.205Z] DEBUG [2219]  : Checking if the received command stage is valid..
[2015-03-27T21:04:27.205Z] INFO  [2219]  : No stage_num in command. Valid stage..
[2015-03-27T21:04:27.205Z] INFO  [2219]  : Command processor should execute command.
[2015-03-27T21:04:27.205Z] DEBUG [2219]  : Storing current stage..
[2015-03-27T21:04:27.205Z] DEBUG [2219]  : Stage_num does not exist. Not saving null stage. Returning..
[2015-03-27T21:04:27.206Z] INFO  [2219]  : Executing command: CMD-TailLogs...
[2015-03-27T21:04:27.206Z] DEBUG [2219]  : Reading config file: /etc/elasticbeanstalk/.aws-eb-stack.properties
[2015-03-27T21:04:27.206Z] DEBUG [2219]  : Refreshing metadata..
[2015-03-27T21:04:27.698Z] DEBUG [2219]  : Refreshed environment metadata.
[2015-03-27T21:04:27.698Z] DEBUG [2219]  : Retrieving metadata for key: AWS::ElasticBeanstalk::Ext||_ContainerConfigFileContent||commands..
[2015-03-27T21:04:27.700Z] DEBUG [2219]  : Retrieving metadata for key: AWS::ElasticBeanstalk::Ext||_API||_Commands..
[2015-03-27T21:04:27.701Z] INFO  [2219]  : Found enabled addons: [].
[2015-03-27T21:04:27.701Z] DEBUG [2219]  : Loaded definition of Command CMD-TailLogs.
[2015-03-27T21:04:27.701Z] INFO  [2219]  : Executing command CMD-TailLogs activities...
[2015-03-27T21:04:27.701Z] DEBUG [2219]  : Setting environment variables..
[2015-03-27T21:04:27.701Z] INFO  [2219]  : Running AddonsBefore for command CMD-TailLogs...
[2015-03-27T21:04:27.702Z] DEBUG [2219]  : Running stages of Command CMD-TailLogs from stage 0 to stage 0...
[2015-03-27T21:04:27.702Z] INFO  [2219]  : Running stage 0 of command CMD-TailLogs...
[2015-03-27T21:04:27.702Z] DEBUG [2219]  : Loaded 1 actions for stage 0.
[2015-03-27T21:04:27.702Z] INFO  [2219]  : Running 1 of 1 actions: TailLogs...
[2015-03-27T21:04:28.114Z] INFO  [2219]  : Running AddonsAfter for command CMD-TailLogs...
[2015-03-27T21:04:28.115Z] INFO  [2219]  : Command CMD-TailLogs succeeded!
[2015-03-27T21:04:28.116Z] INFO  [2219]  : Command processor returning results:
{"status":"SUCCESS","api_version":"1.0","truncated":"false","results":[{"status":"SUCCESS","msg":"","returncode":0,"events":[{"msg":"[Instance: i-OMIT] Successfully finished tailing 14 log(s)","severity":"INFO","timestamp":1427490268116}]}]}
[2015-03-27T21:15:45.231Z] DEBUG [2321]  : Reading config file: /etc/elasticbeanstalk/.aws-eb-stack.properties
[2015-03-27T21:15:45.231Z] INFO  [2321]  : Received command CMD-ConfigDeploy: {"command_name":"CMD-ConfigDeploy","request_id":"OMIT","resource_name":"AWSEBAutoScalingGroup","command_timeout":"600","api_version":"1.0"}
[2015-03-27T21:15:45.231Z] DEBUG [2321]  : Checking if the command processor should execute.
[2015-03-27T21:15:45.264Z] DEBUG [2321]  : Checking whether the command is applicable to instance (i-OMIT)..
[2015-03-27T21:15:45.264Z] INFO  [2321]  : Command is applicable to this instance (i-OMIT)..
[2015-03-27T21:15:45.264Z] DEBUG [2321]  : Checking if the received command stage is valid..
[2015-03-27T21:15:45.264Z] INFO  [2321]  : No stage_num in command. Valid stage..
[2015-03-27T21:15:45.264Z] INFO  [2321]  : Command processor should execute command.
[2015-03-27T21:15:45.264Z] DEBUG [2321]  : Storing current stage..
[2015-03-27T21:15:45.264Z] DEBUG [2321]  : Stage_num does not exist. Not saving null stage. Returning..
[2015-03-27T21:15:45.265Z] INFO  [2321]  : Executing command: CMD-ConfigDeploy...
[2015-03-27T21:15:45.266Z] DEBUG [2321]  : Reading config file: /etc/elasticbeanstalk/.aws-eb-stack.properties
[2015-03-27T21:15:45.266Z] DEBUG [2321]  : Refreshing metadata..
[2015-03-27T21:15:45.772Z] DEBUG [2321]  : Refreshed environment metadata.
[2015-03-27T21:15:45.773Z] DEBUG [2321]  : Retrieving metadata for key: AWS::ElasticBeanstalk::Ext||_ContainerConfigFileContent||commands..
[2015-03-27T21:15:45.774Z] DEBUG [2321]  : Retrieving metadata for key: AWS::ElasticBeanstalk::Ext||_API||_Commands..
[2015-03-27T21:15:45.775Z] INFO  [2321]  : Found enabled addons: [].
[2015-03-27T21:15:45.776Z] DEBUG [2321]  : Loaded definition of Command CMD-ConfigDeploy.
[2015-03-27T21:15:45.776Z] INFO  [2321]  : Executing command CMD-ConfigDeploy activities...
[2015-03-27T21:15:45.776Z] DEBUG [2321]  : Setting environment variables..
[2015-03-27T21:15:45.776Z] INFO  [2321]  : Running AddonsBefore for command CMD-ConfigDeploy...
[2015-03-27T21:15:45.776Z] DEBUG [2321]  : Running stages of Command CMD-ConfigDeploy from stage 0 to stage 1...
[2015-03-27T21:15:45.776Z] INFO  [2321]  : Running stage 0 of command CMD-ConfigDeploy...
[2015-03-27T21:15:45.776Z] DEBUG [2321]  : Loaded 2 actions for stage 0.
[2015-03-27T21:15:45.777Z] INFO  [2321]  : Running 1 of 2 actions: InfraWriteConfig...
[2015-03-27T21:15:45.785Z] INFO  [2321]  : Running 2 of 2 actions: ConfigDeployPreHook...
[2015-03-27T21:15:46.652Z] INFO  [2321]  : Running stage 1 of command CMD-ConfigDeploy...
[2015-03-27T21:15:46.652Z] DEBUG [2321]  : Loaded 2 actions for stage 1.
[2015-03-27T21:15:46.652Z] INFO  [2321]  : Running 1 of 2 actions: ConfigDeployEnactHook...
[2015-03-27T21:15:47.215Z] INFO  [2321]  : Running 2 of 2 actions: ConfigDeployPostHook...
[2015-03-27T21:15:49.439Z] INFO  [2321]  : Running AddonsAfter for command CMD-ConfigDeploy...
[2015-03-27T21:15:49.439Z] INFO  [2321]  : Command CMD-ConfigDeploy succeeded!
[2015-03-27T21:15:49.440Z] INFO  [2321]  : Command processor returning results:
{"status":"SUCCESS","api_version":"1.0","truncated":"false","results":[{"status":"SUCCESS","msg":"","returncode":0,"events":[]}]}
[2015-03-30T14:17:00.018Z] DEBUG [19451] : Reading config file: /etc/elasticbeanstalk/.aws-eb-stack.properties
[2015-03-30T14:17:00.018Z] INFO  [19451] : Received command CMD-TailLogs: {"command_name":"CMD-TailLogs","execution_data":"{\"aws_access_key_id\":\"OMIT\",\"policy\":\"OMIT\",\"security_token\":\"OMIT\",\"signature\":\"OMIT\"}","request_id":"OMIT","resource_name":"AWSEBAutoScalingGroup","data":"OMIT","command_timeout":"600","api_version":"1.0"}
[2015-03-30T14:17:00.018Z] DEBUG [19451] : Checking if the command processor should execute.
[2015-03-30T14:17:00.022Z] DEBUG [19451] : Checking whether the command is applicable to instance (i-OMIT)..
[2015-03-30T14:17:00.022Z] INFO  [19451] : Command is applicable to this instance (i-OMIT)..
[2015-03-30T14:17:00.022Z] DEBUG [19451] : Checking if the received command stage is valid..
[2015-03-30T14:17:00.022Z] INFO  [19451] : No stage_num in command. Valid stage..
[2015-03-30T14:17:00.022Z] INFO  [19451] : Command processor should execute command.
[2015-03-30T14:17:00.022Z] DEBUG [19451] : Storing current stage..
[2015-03-30T14:17:00.022Z] DEBUG [19451] : Stage_num does not exist. Not saving null stage. Returning..
[2015-03-30T14:17:00.023Z] INFO  [19451] : Executing command: CMD-TailLogs...
[2015-03-30T14:17:00.023Z] DEBUG [19451] : Reading config file: /etc/elasticbeanstalk/.aws-eb-stack.properties
[2015-03-30T14:17:00.023Z] DEBUG [19451] : Refreshing metadata..
[2015-03-30T14:17:00.526Z] DEBUG [19451] : Refreshed environment metadata.
[2015-03-30T14:17:00.527Z] DEBUG [19451] : Retrieving metadata for key: AWS::ElasticBeanstalk::Ext||_ContainerConfigFileContent||commands..
[2015-03-30T14:17:00.528Z] DEBUG [19451] : Retrieving metadata for key: AWS::ElasticBeanstalk::Ext||_API||_Commands..
[2015-03-30T14:17:00.529Z] INFO  [19451] : Found enabled addons: [].
[2015-03-30T14:17:00.529Z] DEBUG [19451] : Loaded definition of Command CMD-TailLogs.
[2015-03-30T14:17:00.529Z] INFO  [19451] : Executing command CMD-TailLogs activities...
[2015-03-30T14:17:00.529Z] DEBUG [19451] : Setting environment variables..
[2015-03-30T14:17:00.529Z] INFO  [19451] : Running AddonsBefore for command CMD-TailLogs...
[2015-03-30T14:17:00.530Z] DEBUG [19451] : Running stages of Command CMD-TailLogs from stage 0 to stage 0...
[2015-03-30T14:17:00.530Z] INFO  [19451] : Running stage 0 of command CMD-TailLogs...
[2015-03-30T14:17:00.530Z] DEBUG [19451] : Loaded 1 actions for stage 0.
[2015-03-30T14:17:00.530Z] INFO  [19451] : Running 1 of 1 actions: TailLogs...



-------------------------------------
/var/log/httpd/elasticbeanstalk-error_log
-------------------------------------




-------------------------------------
/var/log/tomcat8/host-manager.2015-03-27.log
-------------------------------------




-------------------------------------
/var/log/tomcat8/catalina.out
-------------------------------------

Health check URL doesn't indicate whether service is running correctly

When an exception occurs within one of the AutoscalingController executors it kills the thread pool and stops the entire service from executing, requiring a restart. When this occurs, there is no impact on the service status page that gets served up on /.

Is the purpose of that page to indicate whether or not the service is running correctly, or is there some other way I can check?

Thanks

Scaling logic is broken

If you have a stream with 1 shard and you run the war with a config of minShards:10 maxShards:20, for example, war application does nothing if the new shard count is outside of the min, max range.
Instead, the application must honor the minShards value and scale up to the new minimum set in the config.

Does not auto-scale with 9.5.4

We have a stream currently running with 1 shard. I start tomcat with the following config

[
     {
        "streamName": "rest-service-prod",
        "region": "us-east-1",
        "scaleOnOperation": ["PUT","GET"],
        "minShards": 1,
        "maxShards": 1000,
        "refreshShardsNumberAfterMin": 1,
        "scaleUp": {
            "scaleThresholdPct": 75,
            "scaleAfterMins": 1,
            "scalePct": 200
        },
        "scaleDown": {
            "scaleThresholdPct": 25,
            "scaleAfterMins": 15,
            "scalePct": 50,
            "coolOffMins": 5
        }
    },
    {
        "streamName": "rest-service-qa",
        "region": "us-east-1",
        "scaleOnOperation": ["PUT","GET"],
        "minShards": 40,
        "maxShards": 1000,
        "refreshShardsNumberAfterMin": 1,
        "scaleUp": {
            "scaleThresholdPct": 75,
            "scaleAfterMins": 1,
            "scalePct": 200
        },
        "scaleDown": {
            "scaleThresholdPct": 25,
            "scaleAfterMins": 15,
            "scalePct": 50,
            "coolOffMins": 5
        }
    }
]

Stream shard count is stuck at 1. Is minimum shard count not respected when no other scaling action based on PUT/GET thresholds is required??

I just threw some load at it and I see tomcat logging

Requesting Scale Up of Stream rest-service-qa by 200% as [PUT, GET] has been above 75% for 1 Minutes

But the stream count remains unchanged at 1 in the Kinesis console.

Feature request: Add capacity metrics to SNS

I think it would be useful if the metric that triggered a scaling change was included with the notification. i.e., include the metric name, the metric value and the percent of current capacity.

Monitoring multiple metrics

Hey Ian, it looks like amazon-kinesis-scaling-utils lets you autoscale based on either PUT or GET throughput, but not both at once. Is that correct?

It would be nice to be able to autoscale based on the maximum of the two metrics. We are happy to work on this feature!

ExpiredTokenException

I have build an application which is putting data into Kinesis Streams.
But while putting the data it shows “ExpiredTokenException”. Below is the error captured in Kibana Logs.

tockenexpiredexception

I am using below code in java to create AWS Kinesis Client and my application runs on EC2 Instance

aws kinesis client

Though when I restart the application by deleting the old DynamoDB table ,it runs successfully and after couple of hours it again shows the same error.

Please suggest on the issue.

Having Issues Getting ElasticBeanstalk Version to Work

Hello,

Currently testing this with some of my Kinesis streams, with the elasticbeanstalk method.

Have referenced #6 but unfortunately, I appear to have exhausted all troubleshooting and experimentation to get things working.

Have deployed single instance ElasticBeanstalk app with tomcat server and the included .war file from the dist folder.

Using the following config, stored on an s3 bucket:

[
    {
        "streamName": "mystream",
        "region": "ap-southeast-2",
        "scaleOnOperation": "PUT",
        "minShards": 1,
        "maxShards": 8,
        "refreshShardsNumberAfterMin": 2,
        "snsArn": "....",
        "scaleUp": {
            "scaleThresholdPct": 75,
            "scaleAfterMins": 2,
            "scalePct": 50
        },
        "scaleDown": {
            "scaleThresholdPct": 50,
            "scaleAfterMins": 2,
            "scalePct": 50,
            "coolOffMins": 2
        }
    },
    {
        "streamName": "mystream",
        "region": "ap-southeast-2",
        "scaleOnOperation": "GET",
        "minShards": 1,
        "maxShards": 8,
        "refreshShardsNumberAfterMin": 2,
        "snsArn": "....",
        "scaleUp": {
            "scaleThresholdPct": 75,
            "scaleAfterMins": 2,
            "scalePct": 50
        },
        "scaleDown": {
            "scaleThresholdPct": 50,
            "scaleAfterMins": 2,
            "scalePct": 50,
            "coolOffMins": 2
        }
    }
]

Unfortunately, the only info I can glean from the logs on the eb server is that it successfully got the config-file-url from s3 and started with it. Aside from that, I can't detect anything in the logs that it is otherwise working. But the number of shards on my test stream never changes and I've tried to set the scaleUp & Down ranges to be pretty extreme so that it should trigger. I've even tried on a not-in-use stream, that I'd assume should automatically trigger scaleDowns.

My IAM roles applied to the elastic beanstalk server have the following policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "kinesis:Get*",
                "kinesis:List*",
                "kinesis:Describe*",
                "kinesis:MergeShards",
                "kinesis:SplitShard"
            ],
            "Resource": "....:stream/mystream"
        },
        {
            "Action": [
                "sns:Publish"
            ],
            "Effect": "Allow",
            "Resource": "...."
        },
        {
            "Action": [
                "cloudwatch:GetMetricStatistics"
            ],
            "Effect": "Allow",
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:GetObject"
            ],
            "Resource": "..../*"
        }
    ]
}

Any glaring faults with those configs & policies? Or ideas on how to further debug from the logs to see why this is or isn't working?

Strange behaviour

Hi there,

I deployed it to an EB application (dist/KinesisAutoscaling-.9.4.1.war file) and I use the following config:
[{ "streamName": "prod-tracking", "region": "us-east-1", "scaleOnOperation": "PUT", "minShards": 1, "maxShards": 10, "refreshShardsNumberAfterMin": 10, "scaleUp": { "scaleThresholdPct": 20, "scaleAfterMins": 1, "scalePct": 25 }, "scaleDown":{ "scaleThresholdPct": 5, "scaleAfterMins": 1, "scalePct": 20, "coolOffMins": 3 } }]
In the log I can see that it tries to scale down (but it should scale up, because I have traffic on it), because the threshold is under 25% (which belongs to the scale up)
screen shot 2016-04-28 at 08 10 35
screen shot 2016-04-28 at 08 10 58

What am I missing? Why is it not scaling up?

Option for min number of shards

If the stream is quiet than application will reduce the shard to 1. But if a sudden data burst occurs (2-3 MB/sec) than stream with 1 shard will not be able to handle it resulting in lot of failed req, so there should be an option for min number of shard that need to be maintained always

Consistency issue with ListShards use in getOpenShards

I recently scaled a stream using this utility from 1500 to 3000 shards by using this tool invoked with -Dscaling-action=scaleUp -Dcount=1500. I had to restart it twice due to the following issue:

Exception in thread "main" java.lang.Exception: Unable to resolve high/low shard mapping for Target Hash Value 82008050427946169683330534827024856845
        at com.amazonaws.services.kinesis.scaling.ShardHashInfo.doSplit(ShardHashInfo.java:163)
        at com.amazonaws.services.kinesis.scaling.StreamScaler.scaleStream(StreamScaler.java:437)
        at com.amazonaws.services.kinesis.scaling.StreamScaler.scaleStream(StreamScaler.java:460)
        at com.amazonaws.services.kinesis.scaling.StreamScaler.doResize(StreamScaler.java:269)
        at com.amazonaws.services.kinesis.scaling.StreamScaler.scaleUp(StreamScaler.java:134)
        at ScalingClient.run(ScalingClient.java:165)
        at ScalingClient.main(ScalingClient.java:220)

When looking at the code where this exception is thrown, it looks like this can only happen if the new child shards that are created from the StreamScalingUtils.splitShard method are not in the Map returned from the StreamScalingUtils.getOpenShards method which is called right after the split is done. I can think of two reasons this could occur:

  1. If the ListShards API has an eventual consistency model then there is a race condition where the shard split is done but there is a chance the following ListShards call doesn't include the child shards due to this model. I couldn't find information about the consistency guarantees of this API in the documentation. If this is the case then additional retries could be added to the getOpenShards method.
  2. The current getOpenShards method handles pagination by checking if result.nextToken != null and then making another LIstShards call by passing the last shardId included in the first request as the ExclusiveStartShardId parameter instead of passing the nextToken which is recommended by the docs. Is it possible that this pagination logic doesn't guarantee that the correct/full shard list is returned? If so, this PR could fix this issue.

I am hoping that my issue is caused by 2) above. Any thoughts?

The service should not just hangs when encountering a LimitExceededException

If the service encounters a LimitExceededException it hangs until restarted. This makes no sense since LimitExceededException are not unusual not "show-stoppers". Instead it should just log a warning and continue to monitor.

15-Feb-2017 19:20:45.251 SEVERE [pool-1-thread-16] com.amazonaws.services.kinesis.scaling.auto.StreamMonitor.processCloudwatchMetrics Failed to process stream com.gilt.svcfeedeventprocessor.avro.ProductLookRecommendation
com.amazonaws.services.kinesis.model.LimitExceededException: Rate exceeded for stream com.gilt.svcfeedeventprocessor.avro.ProductLookRecommendation under account xxxxxxxxxxxxxx. (Service: AmazonKinesis; Status Code: 400; Error Code: LimitExceededException; Request ID: e6627d14-7953-fcf3-b77c-d159895e0058)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1545)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1183)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:964)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:676)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:650)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:633)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$300(AmazonHttpClient.java:601)
at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:583)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:447)
at com.amazonaws.services.kinesis.AmazonKinesisClient.doInvoke(AmazonKinesisClient.java:1747)
at com.amazonaws.services.kinesis.AmazonKinesisClient.invoke(AmazonKinesisClient.java:1723)
at com.amazonaws.services.kinesis.AmazonKinesisClient.updateShardCount(AmazonKinesisClient.java:1687)
at com.amazonaws.services.kinesis.scaling.StreamScaler.updateShardCount(StreamScaler.java:476)
at com.amazonaws.services.kinesis.scaling.auto.StreamMonitor.processCloudwatchMetrics(StreamMonitor.java:308)
at com.amazonaws.services.kinesis.scaling.auto.StreamMonitor.run(StreamMonitor.java:379)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

An error occurred (UnrecognizedClientException) when calling the DescribeDeliveryStream operation: The security token included in the request is invalid.

When I am trying get my application version id by typing the command
aws kinesisanalytics describe-application --application-name <application name from above> | grep ApplicationVersionId

This might arise due to wrong security credentials of the access key and secret key, but at the same time I am able to send my data to AWS IoT so I think my aws-configure has the corrwect info but when I open an another terminal in my rpi, this error pops up when I try to get the application version ID.

What am I doing wrong?

Smoother scaling up by having checkInterval configurable and a cool off period when upscaling

Given the scale up configuration:

    "scaleUp": {
      "scaleThresholdPct": 90,
      "scaleAfterMins": 5,
      "scaleCount": 2
    }

Given that checkInterval is hardcoded to 45 seconds and not configurable; and given that the resharding operation can take more than 45 seconds, it normally happens that amazon-kinesis-scaling-utils ends up deciding to scale up several times, when only once was necessary.

In that situation, the number of total shards is greater than it should be, which means the scale down policy will need to decrease the unnecessary shards. And which is even worse, many intermediate shards are created when upscaling and downscaling (in order to evenly distribute the hashes between the final opened shards), which occasionally makes consumers using the KCL library to be unbalanced as most of the opened shards are concentrated in one or a few consumers.

This effect creates several problems:

  • Increased kinesis costs due to unnecessary shards
  • Increased dynamodb costs, due to extra traffic to KCL dynamodb tables
  • Consumers misbehaviour due to assigned opened shards unbalancing

A couple of easy changes to the JSON configuration would fix this problem, they can be used independently or be complementary:

  • Add checkInterval in the JSON configuration: this also has the benefit of reducing the CloudWatch traffic produced by this application
  • Add scaleUp.coolOffMins with the same behaviour as the current scaleDown.coolOffMins

With this two changes the user can increase the checkInterval to a value greater than the time it takes to do the resharding while reducing the traffic to CloudWatch. Or, if the user wants to react much faster to a traffic increase, he can set a scaleUp.coolOffMins value to let the system do the resharding.

Obviously, these two parameters are also useful to adapt the way a given system wants to react in front of specific traffic patterns as they provide configuration options closer to those which can be found in EC2.

CloudwatchMetrics collection wrong

Running autoscaling 9.5.5. It seems that StreamMonitor collects wrong data from CloudWatch. I'm seeing roughly 10x lower numbers in the logs:

INFO: Records: Stream raw Used PUT[Records] Capacity ~ 1.25% (25 Records of 2000)
INFO: Bytes: Stream raw Used PUT[Bytes] Capacity ~ 7.52% (158,772 Bytes of 2097152)

In CloudWatch dashboard under same timestamp I'm seeing 250 records and ~1.6 MB PUT capacity usage. This causes the application to scaledown aggressively.

Question about minumum shards to resize on pct

Hi,
Does the Auto-Process has some minimum of shards to split when you set scale Pct? For example if I have an stream that should be scaled and this stream has 2 shards and have specified 15% in scalePct a new hard will be added ?

Thanks,
Gabriel.

Uneven shard key distribution

We've been using this application to manage our stream, and I discovered that the hash key distributions for each shard are uneven:

Joel:s3logger jrosen$ aws kinesis describe-stream --stream-name profile_vertica_logs_production_localytics
{
    "StreamDescription": {
        "StreamStatus": "ACTIVE", 
        "StreamName": "profile_vertica_logs_production_localytics", 
        "StreamARN": "arn:aws:kinesis:us-east-1:294150496849:stream/profile_vertica_logs_production_localytics", 
        "Shards": [
            {
                "ShardId": "shardId-000000000874", 
                "HashKeyRange": {
                    "EndingHashKey": "300249147351239883522035629954940250949", 
                    "StartingHashKey": "280232537532583562635223583154768590786"
                }, 
                "ParentShardId": "shardId-000000000870", 
                "AdjacentParentShardId": "shardId-000000000872", 
                "SequenceNumberRange": {
                    "StartingSequenceNumber": "49554468058145507846763513171201233418429267577761969826"
                }
            }, 
            {
                "ShardId": "shardId-000000000877", 
                "HashKeyRange": {
                    "EndingHashKey": "320265757169356079890549598711728836438", 
                    "StartingHashKey": "300249147351239883522035629954940250950"
                }, 
                "ParentShardId": "shardId-000000000873", 
                "AdjacentParentShardId": "shardId-000000000875", 
                "SequenceNumberRange": {
                    "StartingSequenceNumber": "49554732340597232675420810692645089059174495303185217234"
                }
            }, 
            {
                "ShardId": "shardId-000000000878", 
                "HashKeyRange": {
                    "EndingHashKey": "340282366920938463463374607431768211455", 
                    "StartingHashKey": "320265757169356079890549598711728836439"
                }, 
                "ParentShardId": "shardId-000000000876", 
                "AdjacentParentShardId": "shardId-000000000826", 
                "SequenceNumberRange": {
                    "StartingSequenceNumber": "49554468092131843529324182838901668065945370512876123874"
                }
            }, 
            {
                "ShardId": "shardId-000000000881", 
                "HashKeyRange": {
                    "EndingHashKey": "24305883360235455442838331915739612791", 
                    "StartingHashKey": "0"
                }, 
                "ParentShardId": "shardId-000000000829", 
                "AdjacentParentShardId": "shardId-000000000879", 
                "SequenceNumberRange": {
                    "StartingSequenceNumber": "49554468438306311246115045864960622812265886170210121490"
                }
            }, 
            {
                "ShardId": "shardId-000000000884", 
                "HashKeyRange": {
                    "EndingHashKey": "48611766697147529041415588084174029605", 
                    "StartingHashKey": "24305883360235455442838331915739612792"
                }, 
                "ParentShardId": "shardId-000000000880", 
                "AdjacentParentShardId": "shardId-000000000882", 
                "SequenceNumberRange": {
                    "StartingSequenceNumber": "49554468462993236180888445682640662940087622357330442050"
                }
            }, 
            {
                "ShardId": "shardId-000000000887", 
                "HashKeyRange": {
                    "EndingHashKey": "72917650050263527726213560516824835796", 
                    "StartingHashKey": "48611766697147529041415588084174029606"
                }, 
                "ParentShardId": "shardId-000000000883", 
                "AdjacentParentShardId": "shardId-000000000885", 
                "SequenceNumberRange": {
                    "StartingSequenceNumber": "49554468485896101499779395648997845606097489623972329330"
                }
            }, 
            {
                "ShardId": "shardId-000000000890", 
                "HashKeyRange": {
                    "EndingHashKey": "97223533390416380489178248897960958917", 
                    "StartingHashKey": "72917650050263527726213560516824835797"
                }, 
                "ParentShardId": "shardId-000000000886", 
                "AdjacentParentShardId": "shardId-000000000888", 
                "SequenceNumberRange": {
                    "StartingSequenceNumber": "49554468508798966818670345615355028272107356890614216610"
                }
            }, 
            {
                "ShardId": "shardId-000000000894", 
                "HashKeyRange": {
                    "EndingHashKey": "121529416757035643727222635693274104944", 
                    "StartingHashKey": "97223533390416380489178248897960958918"
                }, 
                "ParentShardId": "shardId-000000000891", 
                "AdjacentParentShardId": "shardId-000000000892", 
                "SequenceNumberRange": {
                    "StartingSequenceNumber": "49554468544569362117113465134378320381435328746206803938"
                }
            }, 
            {
                "ShardId": "shardId-000000000897", 
                "HashKeyRange": {
                    "EndingHashKey": "145835300102049674424392379258801301030", 
                    "StartingHashKey": "121529416757035643727222635693274104945"
                }, 
                "ParentShardId": "shardId-000000000893", 
                "AdjacentParentShardId": "shardId-000000000895", 
                "SequenceNumberRange": {
                    "StartingSequenceNumber": "49554468566044979743298455219677217077995700876465944594"
                }
            }, 
            {
                "ShardId": "shardId-000000000900", 
                "HashKeyRange": {
                    "EndingHashKey": "170141183450304490751314526534861009228", 
                    "StartingHashKey": "145835300102049674424392379258801301031"
                }, 
                "ParentShardId": "shardId-000000000896", 
                "AdjacentParentShardId": "shardId-000000000898", 
                "SequenceNumberRange": {
                    "StartingSequenceNumber": "49554468589304656985365895156298971236367941927203518530"
                }
            }, 
            {
                "ShardId": "shardId-000000000903", 
                "HashKeyRange": {
                    "EndingHashKey": "194447066811106967209212391235731229719", 
                    "StartingHashKey": "170141183450304490751314526534861009229"
                }, 
                "ParentShardId": "shardId-000000000899", 
                "AdjacentParentShardId": "shardId-000000000901", 
                "SequenceNumberRange": {
                    "StartingSequenceNumber": "49554468611850710381080355152391582410015435409749719154"
                }
            }, 
            {
                "ShardId": "shardId-000000000906", 
                "HashKeyRange": {
                    "EndingHashKey": "218752950167879235613208499400926401491", 
                    "StartingHashKey": "194447066811106967209212391235731229720"
                }, 
                "ParentShardId": "shardId-000000000902", 
                "AdjacentParentShardId": "shardId-000000000904", 
                "SequenceNumberRange": {
                    "StartingSequenceNumber": "49554468634039951853618325178219622091300555108200233122"
                }
            }, 
            {
                "ShardId": "shardId-000000000909", 
                "HashKeyRange": {
                    "EndingHashKey": "260215927711226584039780879896832127821", 
                    "StartingHashKey": "243058833536118888773728969223528864133"
                }, 
                "ParentShardId": "shardId-000000000868", 
                "SequenceNumberRange": {
                    "StartingSequenceNumber": "49554468656586005249332785174312233264948048590746433746"
                }
            }, 
            {
                "ShardId": "shardId-000000000910", 
                "HashKeyRange": {
                    "EndingHashKey": "243058833536118888773728969223528864132", 
                    "StartingHashKey": "218752950167879235613208499400926401492"
                }, 
                "ParentShardId": "shardId-000000000907", 
                "AdjacentParentShardId": "shardId-000000000908", 
                "SequenceNumberRange": {
                    "StartingSequenceNumber": "49554732662107076202636804524165539395945923134904875234"
                }
            }, 
            {
                "ShardId": "shardId-000000000911", 
                "HashKeyRange": {
                    "EndingHashKey": "267364716887074354948759097083674869129", 
                    "StartingHashKey": "260215927711226584039780879896832127822"
                }, 
                "ParentShardId": "shardId-000000000871", 
                "SequenceNumberRange": {
                    "StartingSequenceNumber": "49554468679109757899848714547263308720322893711786653938"
                }
            }, 
            {
                "ShardId": "shardId-000000000912", 
                "HashKeyRange": {
                    "EndingHashKey": "280232537532583562635223583154768590785", 
                    "StartingHashKey": "267364716887074354948759097083674869130"
                }, 
                "ParentShardId": "shardId-000000000871", 
                "SequenceNumberRange": {
                    "StartingSequenceNumber": "49554468678775246721870755200140272946233168289196947714"
                }
            }
        ]
    }
}

I did a little math and found that some shards have a range of 24305883360235455442838331915739612791 values, while the smallest shard only takes a range of 7148789175847770908978217186842741307 values.

This is causing data to be distributed unevenly across the shards, and our consumer application takes much longer to keep up to real time on the larger shards.

Here is our config:

[
  {
   "streamName":"profile_vertica_logs_production_localytics",
   "region":"us-east-1",
   "scaleOnOperation":"PUT",
   "minShards":12,
   "maxShards":40,
   "scaleUp": {
       "scaleThresholdPct":80,
       "scaleAfterMins":1,
       "scalePct":50
   },
   "scaleDown":{
       "scaleThresholdPct": 50,
       "scaleAfterMins": 30,
       "scalePct": 20,
       "coolOffMins": 15
   }
  }
]

I'm not sure how the scaling operation works. Does it try to size shards evenly? I'm concerned this may be causing us production issues.

ScaleUp and ScaleThresholdPct Question

Hello,

We are trying scaling utils on WildFly and a stream with 14 shards.

Although scaleThresholdPct for scaleUp is 80 and the stream uses 95% of it's put records limit; it didn't scale up.

Would you please check our config;

[{"streamName":"my-test-stream",
 "region":"us-east-1",
 "scaleOnOperation":["PUT","GET"],
 "minShards":1,
 "maxShards":45,
 "refreshShardsNumberAfterMin":30,
 "scaleUp": {
     "scaleThresholdPct":80,
     "scaleAfterMins":5,
     "scalePct":25
 },
 "scaleDown":{
     "scaleThresholdPct":50,
     "scaleAfterMins":10,
     "scalePct":25,
     "coolOffMins":5
 }
}]

Here are the logs from server.log;

2016-05-10 12:53:53,276 INFO  [com.amazonaws.services.kinesis.scaling.auto.StreamMonitor] (pool-5-thread-1) Bytes: Stream my-test-stream Used GET[Bytes] Capacity ~ 46.07% (12,373,817 Bytes of 29360128)
2016-05-10 12:53:53,277 INFO  [com.amazonaws.services.kinesis.scaling.auto.StreamMonitor] (pool-5-thread-1) Records: Stream my-test-stream Used GET[Records] Capacity ~ 0.10% (27 Records of 28000)
2016-05-10 12:53:53,277 INFO  [com.amazonaws.services.kinesis.scaling.auto.StreamMonitor] (pool-5-thread-1) Will decide scaling action based on metric GET[Bytes] due to higher utilisation metric 46.07%
2016-05-10 12:53:53,277 INFO  [com.amazonaws.services.kinesis.scaling.auto.StreamMonitor] (pool-5-thread-1) Bytes: Stream my-test-stream Used PUT[Bytes] Capacity ~ 42.52% (6,155,363 Bytes of 14680064)
2016-05-10 12:53:53,277 INFO  [com.amazonaws.services.kinesis.scaling.auto.StreamMonitor] (pool-5-thread-1) Records: Stream my-test-stream Used PUT[Records] Capacity ~ 95.50% (14,061 Records of 14000)
2016-05-10 12:53:53,277 INFO  [com.amazonaws.services.kinesis.scaling.auto.StreamMonitor] (pool-5-thread-1) Will decide scaling action based on metric PUT[Records] due to higher utilisation metric 95.50%
2016-05-10 12:53:53,277 INFO  [com.amazonaws.services.kinesis.scaling.auto.StreamMonitor] (pool-5-thread-1) No Scaling required - Stream capacity within specified tolerances

Unsupported major.minor version 51.0

Getting this error in my /var/log/tomcat7/catalina.out log at application start time. I'm trying to use EB with solution stack 64bit Amazon Linux running Tomcat 7.

SEVERE: ContainerBase.addChild: start: 
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1099)
    at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1621)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:679)
Caused by: java.lang.UnsupportedClassVersionError: com/amazonaws/services/kinesis/scaling/auto/app/KinesisAutoscalingBeanstalkApp : Unsupported major.minor version 51.0 (unable to load class com.amazonaws.services.kinesis.scaling.auto.app.KinesisAutoscalingBeanstalkApp)
    at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2893)
    at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1170)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
    at org.apache.catalina.startup.WebAnnotationSet.loadClass(WebAnnotationSet.java:480)
    at org.apache.catalina.startup.WebAnnotationSet.loadApplicationListenerAnnotations(WebAnnotationSet.java:82)
    at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:64)
    at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:381)
    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:858)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:345)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5161)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 11 more
Apr 21, 2015 4:05:55 PM org.apache.catalina.startup.HostConfig deployDirectory
SEVERE: Error deploying web application directory /var/lib/tomcat7/webapps/ROOT
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:898)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1099)
    at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1621)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:679)

How do I use a non-default profile from ~/.aws/credentials?

Hi, ref this comment: #5 (comment)

Running something like java -cp dist/KinesisScalingUtils-complete.jar -Dstream-name=MyStream -Dscaling-action=report -Dregion=eu-west-1 ScalingClient is using my [default] profile from the credentials file. How do I specify the use of a different profile?

To draw a parallel aws cli uses the --profile flag to use a named profile.

MissingAuthenticationTokenException with Java KMS encryption

I'm trying to put encrypted data into S3, as per the example suggested in ,http://docs.aws.amazon.com/AmazonS3/latest/dev/client-side-using-kms-java.html

I removed ProfileCredentialsProvider as an arugment to AmazonS3EncryptionClient as we are going with I AM Role based crednetials.

Facing this excepion at the line at

		encryptionClient.putObject(
				new PutObjectRequest(bucketName, objectKey, new ByteArrayInputStream(plaintext), new ObjectMetadata()));


	```

String objectKey = "ExampleKMSEncryptedObject";
String kms_cmk_id = "arn:aws:kms:******************************************************";

	KMSEncryptionMaterialsProvider materialProvider = new KMSEncryptionMaterialsProvider(kms_cmk_id);
	AmazonS3EncryptionClient encryptionClient;

	encryptionClient = new AmazonS3EncryptionClient(materialProvider,new CryptoConfiguration().withKmsRegion(Regions.US_WEST_1))
					.withRegion(Region.getRegion(Regions.US_WEST_1));

	// Upload object using the encryption client.
	byte[] plaintext = "Hello World, S3 Client-side Encryption Using Asymmetric Master Key!".getBytes();
	System.out.println("plaintext's length: " + plaintext.length);
	encryptionClient.putObject(
			new PutObjectRequest(bucketName, objectKey, new ByteArrayInputStream(plaintext), new ObjectMetadata()));

	// Download the object.
	S3Object downloadedObject = encryptionClient.getObject(bucketName, objectKey);
	byte[] decrypted = IOUtils.toByteArray(downloadedObject.getObjectContent());
com.amazonaws.services.kms.model.AWSKMSException: Missing Authentication Token (Service: AWSKMS; Status Code: 400; Error Code: MissingAuthenticationTokenException; Request ID: 2ccee8e2-78e9-11e7-b8fd-cd59b619a526)
	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1586) ~[aws-java-sdk-core-1.11.75.jar:?]
	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1254) ~[aws-java-sdk-core-1.11.75.jar:?]
	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1035) ~[aws-java-sdk-core-1.11.75.jar:?]
	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:747) ~[aws-java-sdk-core-1.11.75.jar:?]
	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:721) ~[aws-java-sdk-core-1.11.75.jar:?]
	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:704) ~[aws-java-sdk-core-1.11.75.jar:?]
	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:672) ~[aws-java-sdk-core-1.11.75.jar:?]
	at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:654) ~[aws-java-sdk-core-1.11.75.jar:?]
	at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:518) ~[aws-java-sdk-core-1.11.75.jar:?]
	at com.amazonaws.services.kms.AWSKMSClient.doInvoke(AWSKMSClient.java:2607) ~[aws-java-sdk-kms-1.11.76.jar:?]
	at com.amazonaws.services.kms.AWSKMSClient.invoke(AWSKMSClient.java:2583) ~[aws-java-sdk-kms-1.11.76.jar:?]
	at com.amazonaws.services.kms.AWSKMSClient.generateDataKey(AWSKMSClient.java:1378) ~[aws-java-sdk-kms-1.11.76.jar:?]
	at com.amazonaws.services.s3.internal.crypto.S3CryptoModuleBase.buildContentCryptoMaterial(S3CryptoModuleBase.java:539) ~[aws-java-sdk-s3-1.11.76.jar:?]
	at com.amazonaws.services.s3.internal.crypto.S3CryptoModuleBase.newContentCryptoMaterial(S3CryptoModuleBase.java:490) ~[aws-java-sdk-s3-1.11.76.jar:?]
	at com.amazonaws.services.s3.internal.crypto.S3CryptoModuleBase.createContentCryptoMaterial(S3CryptoModuleBase.java:456) ~[aws-java-sdk-s3-1.11.76.jar:?]
	at com.amazonaws.services.s3.internal.crypto.S3CryptoModuleBase.putObjectUsingMetadata(S3CryptoModuleBase.java:165) ~[aws-java-sdk-s3-1.11.76.jar:?]
	at com.amazonaws.services.s3.internal.crypto.S3CryptoModuleBase.putObjectSecurely(S3CryptoModuleBase.java:161) ~[aws-java-sdk-s3-1.11.76.jar:?]
	at com.amazonaws.services.s3.internal.crypto.CryptoModuleDispatcher.putObjectSecurely(CryptoModuleDispatcher.java:108) ~[aws-java-sdk-s3-1.11.76.jar:?]

Undocumented but required configuration parameter "refreshShardsNumberAfterMin"

There seems to be a configuration parameter refreshShardsNumberAfterMin which, if not set, defaults to null and causes a NullPointerException after the daemon runs for a few minutes. However, I didn't see this in the README anywhere. This ended up biting us, so maybe this should be documented to save others the trouble? Some other things that would be helpful:

  1. It'd be nice if the autoscaling daemon failed early with a helpful error message if the configuration isn't right. This would have saved us a lot of time.
  2. When a StreamMonitor fails, it'd be helpful if it printed a stack trace to make debugging what went wrong easier. I ended up adding a line just above here to log the exception from the failed StreamMonitor, which helped me debug my issue.

Let me know what you think, thanks!
-Josh

Source

Will the source be made available for the utils?

How to run this without Elastic Beanstalk

Hey, I was wondering if anyone can provide some simple instructions on running this on an EC2 instance without Elastic Beanstalk.

I've downloaded installed Tomcat 7, and successfully deployed the application (I can see the "OK - Kinesis Autoscaling Online"). However, I am unable to get the configuration file url working:

com.amazonaws.services.kinesis.scaling.auto.InvalidConfigurationException: Unable to instantiate AutoscalingController without System Property config-file-url
  at com.amazonaws.services.kinesis.scaling.auto.AutoscalingController.getInstance(AutoscalingController.java:84)
  at com.amazonaws.services.kinesis.scaling.auto.app.KinesisAutoscalingBeanstalkApp.contextInitialized(KinesisAutoscalingBeanstalkApp.java:46)
  at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5010)
  at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5504)
  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
  at org.apache.catalina.core.StandardContext.reload(StandardContext.java:4025)
  at org.apache.catalina.manager.ManagerServlet.reload(ManagerServlet.java:954)
  at org.apache.catalina.manager.HTMLManagerServlet.reload(HTMLManagerServlet.java:633)
  at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:211)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
  at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:213)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
  at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
  at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:610)
  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
  at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
  at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
  at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
  at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
  at java.lang.Thread.run(Thread.java:745)

Not sure if this is the right approach, but I have export TOMCAT_OPTS="-Dconfig-file-url=<url>" in my ~/.bashrc.

Scaling fails intermittently

I tried manual scaling using the jar and at times shard doesn't scale fully. For example I scaled up from 32 to 46 and it stopped at 41 and the shard status turned active. But this is an intermittent issue and if I try again it does scale up to that number too.

Is there any way to monitoring the monitor?

There is any way to know if I will get some error starting a service? (I want to make sure that monitor is monitoring, periodically)
This king of error:
java.io.IOException: Unable to load local file from /config/autoscaling.json

I tried to make a curl to:
curl -I -X GET http://localhost:8080/KinesisAutoscaling-.9.5.2/index.html

but this is the apache status (ever is 200 for me)

Readme.md links to corrupted WAR files.

Hi AWS Team,

I tried to deploy your package with Amazon Elastic Beanstalk. I downloaded .war file specific to my region and created a new EB app.

Sadly, app couldn't load. After some digging I saw an exception in logs:

27-Sep-2017 16:18:09.839 SEVERE [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start: 
 org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:729)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
	at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1129)
	at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1871)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@6c5a4690]
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)
	at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4969)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5099)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	... 10 more
Caused by: org.apache.catalina.LifecycleException: Failed to initialize component [org.apache.catalina.webresources.JarResourceSet@2f457ec1]
	at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:107)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:135)
	at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:707)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	... 13 more
Caused by: java.lang.IllegalArgumentException: java.util.zip.ZipException: invalid LOC header (bad signature)
	at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.initInternal(AbstractSingleArchiveResourceSet.java:113)
	at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
	... 16 more
Caused by: java.util.zip.ZipException: invalid LOC header (bad signature)
	at java.util.zip.ZipFile.read(Native Method)
	at java.util.zip.ZipFile.access$1400(ZipFile.java:60)
	at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:717)
	at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:419)
	at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
	at sun.misc.IOUtils.readFully(IOUtils.java:65)
	at java.util.jar.JarFile.getBytes(JarFile.java:425)
	at java.util.jar.JarFile.getManifestFromReference(JarFile.java:193)
	at java.util.jar.JarFile.getManifest(JarFile.java:180)
	at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.initInternal(AbstractSingleArchiveResourceSet.java:111)
	... 17 more

27-Sep-2017 16:18:09.842 SEVERE [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Error deploying web application directory /var/lib/tomcat8/webapps/ROOT
 java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:757)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:729)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
	at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1129)
	at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1871)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

27-Sep-2017 16:18:09.850 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /var/lib/tomcat8/webapps/ROOT has finished in 285 ms

That give me some clues -> it looks like one of the .jar files are corrupted in your bundles.
I unpacked a war file and executed following commands:

ଘ( ᐛ )ଓ ♥ WEB-INF/lib → ls -1 |xargs -n 1 zip -T 
test of aws-java-sdk-cloudwatch-1.11.188.jar OK
test of aws-java-sdk-core-1.11.188.jar OK
test of aws-java-sdk-kinesis-1.11.188.jar OK
warning [aws-java-sdk-kms-1.11.188.jar]:  44875 extra bytes at beginning or within zipfile
  (attempting to process anyway)
file #1:  bad zipfile offset (local header sig):  44875
  (attempting to re-compensate)
test of aws-java-sdk-kms-1.11.188.jar FAILED

zip error: Zip file invalid, could not spawn unzip, or wrong unzip (original files unmodified)
test of aws-java-sdk-s3-1.11.188.jar OK
test of aws-java-sdk-sns-1.11.188.jar OK
warning [aws-java-sdk-sqs-1.11.188.jar]:  69300 extra bytes at beginning or within zipfile
  (attempting to process anyway)
file #1:  bad zipfile offset (local header sig):  69300
  (attempting to re-compensate)
test of aws-java-sdk-sqs-1.11.188.jar FAILED

zip error: Zip file invalid, could not spawn unzip, or wrong unzip (original files unmodified)
test of commons-codec-1.9.jar OK
test of commons-io-2.5.jar OK
test of commons-logging-1.1.3.jar OK
test of httpclient-4.5.2.jar OK
test of httpcore-4.4.4.jar OK
test of ion-java-1.0.2.jar OK
test of jackson-annotations-2.7.4.jar OK
test of jackson-core-2.6.7.jar OK
test of jackson-databind-2.6.7.1.jar OK
test of jackson-dataformat-cbor-2.6.7.jar OK
test of javatuples-1.2.jar OK
test of jmespath-java-1.11.188.jar OK
test of joda-time-2.2.jar OK

Looks like libs for SQS and KMS services are corrupted. After I removed those 2 files from .war-bundle, AWS EB is able to run this app without ZIP error.
Could you update the links in README or upload working .war files again?
Thanks in advance,

ScaleDown action keep adding the number of shards.

Tested application and noticed following issues:

  1. On quiet stream the application keep adding shards. I thought there will be some dependency on the throughput.
  2. scaleDown works the same way as scaleUp. I ended up with 100 shards in 20 min.
  3. Web instance of the application is very scripted... some additional light would be helpful.

Handle transient CloudWatch errors

A transient CloudWatch error seems to have triggered the application to shutdown.

Perhaps there is a way to be more tolerant of this kind of error short of shutting down the whole application.

19-Aug-2016 16:56:21.863 SEVERE [20] com.amazonaws.services.kinesis.scaling.auto.AutoscalingController.startMonitors Unable to unmarshall error response () (Service: AmazonCloudWatch; Status Code: 500; Error Code: 500 Internal Server Error; Request ID: null)
 java.lang.InterruptedException: Unable to unmarshall error response () (Service: AmazonCloudWatch; Status Code: 500; Error Code: 500 Internal Server Error; Request ID: null)
        at com.amazonaws.services.kinesis.scaling.auto.AutoscalingController.startMonitors(AutoscalingController.java:149)
        at com.amazonaws.services.kinesis.scaling.auto.AutoscalingController.run(AutoscalingController.java:177)
        at java.lang.Thread.run(Thread.java:745)

19-Aug-2016 16:56:21.863 INFO [20] com.amazonaws.services.kinesis.scaling.auto.AutoscalingController.startMonitors Terminating Thread Pool

Missing license template (asl.txt)

Upon running mvn check, I run into a failure due to the license header template not being included in the repository:

[INFO] 
[INFO] --- maven-jar-plugin:2.3.2:jar (default-jar) @ kinesis-scaling-utils ---
[INFO] 
[INFO] --- license-maven-plugin:2.3:check (default) @ kinesis-scaling-utils ---
[INFO] Checking licenses...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.146s
[INFO] Finished at: Mon Mar 30 16:58:06 PDT 2015
[INFO] Final Memory: 9M/325M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.mycila:license-maven-plugin:2.3:check (default) on project kinesis-scaling-utils: Resource /Users/avram/Projects/amazon-kinesis-scaling-utils/license/asl/header.txt not found in file system, classpath or URL: no protocol: /Users/avram/Projects/amazon-kinesis-scaling-utils/license/asl/header.txt -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

It would be best if the template was included in the repo, so that contributors can run the normal Maven lifecycle tasks.

CloudWatch timeouts crash the service

I'm running 9.5.7 of this service, and I've noticed that sometimes the entire service will crash when a CloudWatch error is thrown:

2019-05-15 03:24:57 ERROR AutoscalingController:155 - Unable to execute HTTP request: Connect to monitoring.eu-central-1.amazonaws.com:443 [monitoring.eu-central-1.amazonaws.com/52.94.205.59] failed: connect timed out
java.lang.InterruptedException: Unable to execute HTTP request: Connect to monitoring.eu-central-1.amazonaws.com:443 [monitoring.eu-central-1.amazonaws.com/52.94.205.59] failed: connect timed out
    at com.amazonaws.services.kinesis.scaling.auto.AutoscalingController.startMonitors(AutoscalingController.java:142)
    at com.amazonaws.services.kinesis.scaling.auto.AutoscalingController.run(AutoscalingController.java:170)
    at java.lang.Thread.run(Thread.java:748)
2019-05-15 03:24:57 INFO  AutoscalingController:156 - Terminating Thread Pool

How to scale a specific Shard as mentioned in the README file?

As mentioned in the document, I tried up-scaling a specific shard with a factor of 3, it prints 'Scaling Operation Complete', and a Null Pointer Exception is thrown. Exception Stack -

Exception in thread "main" java.lang.NullPointerException
at ScalingClient.run(ScalingClient.java:204)
at ScalingClient.main(ScalingClient.java:220)

After going through the codebase, I can see some methods for Scaling a specific Shard but it hasn't been completely implemented yet! Is this feature available in a beta version that I have missed. I am using KinesisScalingUtils-.9.5.4-complete.jar

Lambda Parallelization Factor

We use Lambda functions fed by Kinesis in our architecture.

This app monitors throughput for Kinesis (number of records, amount of data) via CloudWatch. In addition to this it would be good to monitor lambda performance via the CloudWatch metric IteratorAge to scale the relatively new parameter in Kinesis/Lamba, "parallelization factor".

https://aws.amazon.com/about-aws/whats-new/2019/11/aws-lambda-supports-parallelization-factor-for-kinesis-and-dynamodb-event-sources/

Scale on GetRecords.IteratorAgeMilliseconds

I have a setup where a Lambda function is reading a steady stream of data from a Kinesis Stream.

I ran into an issue where the Lambda function had a code issue and it couldnt process any data for sometime. That caused the GetRecords.IteratorAgeMilliseconds to spike up (obviously).
I fixed the issue with the Lambda function and also increased the no of shards in Kinesis Stream but it took a long time for the GetRecords.IteratorAgeMilliseconds to come to around 0.

I was wondering if I can keep on adding more shards once the GetRecords.IteratorAgeMilliseconds starts going up so that in the case I described above, once the issue is resolved, the catch up is much faster.

scale down only reduce one shard at one time

I found in the test that scale down only reduces one shard at a time.

The problem should be here

else {
	report = this.scaler.updateShardCount(this.config.getStreamName(), currentShardCount,
		new Double(currentShardCount - (new Double(this.config.getScaleDown().getScalePct()) / 100)).intValue(),
	this.config.getMinShards(), this.config.getMaxShards(), false);
						}

Should be modified to(+ -> *):

else {
	report = this.scaler.updateShardCount(this.config.getStreamName(), currentShardCount,
		new Double(currentShardCount * (new Double(this.config.getScaleDown().getScalePct()) / 100)).intValue(), this.config.getMinShards(), this.config.getMaxShards(), false);
						}

The security token included in the request is invalid.

How are security tokens configured when using the CLI? I have tokens for profiles configured in my ~/.aws/config file, but I don't see how I supply to the CLI which token it should be using.

$ java -cp KinesisScalingUtils.jar-complete.jar -Dstream-name=mytest -Dscaling-action=scaleUp -Dcount=5 -Dregion=us-east-1 ScalingClient
Exception in thread "main" com.amazonaws.AmazonServiceException: The security token included in the request is invalid. (Service: AmazonKinesis; Status Code: 400; Error Code: UnrecognizedClientException; Request ID: UUID-OMIT)
    at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1078)
    at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:726)
    at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:461)
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:296)
    at com.amazonaws.services.kinesis.AmazonKinesisClient.invoke(AmazonKinesisClient.java:2498)
    at com.amazonaws.services.kinesis.AmazonKinesisClient.describeStream(AmazonKinesisClient.java:861)
    at com.amazonaws.services.kinesis.scaling.StreamScalingUtils.safeDescribeStream(StreamScalingUtils.java:122)
    at com.amazonaws.services.kinesis.scaling.StreamScalingUtils.getOpenShards(StreamScalingUtils.java:202)
    at com.amazonaws.services.kinesis.scaling.StreamScalingUtils.getOpenShardCount(StreamScalingUtils.java:145)
    at com.amazonaws.services.kinesis.scaling.StreamScaler.scaleUp(StreamScaler.java:127)
    at ScalingClient.run(ScalingClient.java:148)
    at ScalingClient.main(ScalingClient.java:196)

NPE when down scaling omitted from configuration

It looks like the initial configuration validation requires minimally an upScaling or a downScaling section, but further on there is an assumption that downScaling is present. (I had omitted the down scaling section from our configuration but then saw this)

01-Sep-2016 21:45:23.088 SEVERE [localhost-startStop-1] com.amazonaws.services.kinesis.scaling.auto.AutoscalingController.getInstance null
 java.lang.NullPointerException
    at com.amazonaws.services.kinesis.scaling.auto.AutoscalingConfiguration.validate(AutoscalingConfiguration.java:237)
    at com.amazonaws.services.kinesis.scaling.auto.AutoscalingConfiguration.loadFromURL(AutoscalingConfiguration.java:212)
    at com.amazonaws.services.kinesis.scaling.auto.AutoscalingController.getInstance(AutoscalingController.java:76)
    at com.amazonaws.services.kinesis.scaling.auto.app.KinesisAutoscalingBeanstalkApp.contextInitialized(KinesisAutoscalingBeanstalkApp.java:46)

As a workaround, I just fully configured the down scaling but put -1 for the scaleThresholdPct.

Error with security token

Application ran fine for several days, then aborted when this exception started happening:

com.amazonaws.services.kinesis.model.AmazonKinesisException: The security token included in the request is invalid (Service: AmazonKinesis; Status Code: 400; Error Code: UnrecognizedClientException; Request ID: ed73b632-759a-4028-bdf4-968a6a1f5501)
        at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1386)
        at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:939)
        at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:714)
        at com.amazonaws.http.AmazonHttpClient.doExecute(AmazonHttpClient.java:465)
        at com.amazonaws.http.AmazonHttpClient.executeWithTimer(AmazonHttpClient.java:427)
        at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:376)
        at com.amazonaws.services.kinesis.AmazonKinesisClient.doInvoke(AmazonKinesisClient.java:2023)
        at com.amazonaws.services.kinesis.AmazonKinesisClient.invoke(AmazonKinesisClient.java:1993)
        at com.amazonaws.services.kinesis.AmazonKinesisClient.describeStream(AmazonKinesisClient.java:711)

Threshold should be a range

Threshold should be range instead of a single point. Otherwise stream will keep updating after coolOffMins.

Lambda support

It would be great if this could be run as a scheduled lambda function instead of on EC2/EB. Though I did notice that there's already a LambdaApp branch, I didn't see any obvious or documented way to do this.

can't scale up from minimum

If you create a stream having $minShards, auto-scaling will not scale up even though it thinks it needs to.

I think this is due to the short circuit logic here:

https://github.com/awslabs/amazon-kinesis-scaling-utils/blob/master/src/main/java/com/amazonaws/services/kinesis/scaling/StreamScaler.java#L342-L354

Basically if numberOfShards == minShards, it will not scale up. It also looks like it will not scale down once it reaches maxShards.

Here are some logs from where I tested this:

19-May-2015 22:35:43.203 INFO [pool-1-thread-1] com.amazonaws.services.kinesis.scaling.auto.StreamMonitor.processCloudwatchMetrics Stream Used Capacity 92.82% (973,236 Bytes of 1,048,576)
19-May-2015 22:35:43.203 INFO [pool-1-thread-1] com.amazonaws.services.kinesis.scaling.auto.StreamMonitor.processCloudwatchMetrics Scale Up Stream test-stream by 2 Shards as PUT has been above 85% for 1 Minute
s
19-May-2015 22:35:43.469 INFO [pool-1-thread-1] com.amazonaws.services.kinesis.scaling.StreamScaler.scaleStream Scaling Stream test-stream from 1 Shards to 3
19-May-2015 22:35:43.686 INFO [pool-1-thread-1] com.amazonaws.services.kinesis.scaling.StreamScaler.scaleStream Minimum Shard Count of 1 Reached

scaleDown can terminate autoscaling

My scaleDown configuration:

...
    "scaleDown": {
         "scaleThresholdPct": 50,
         "scaleAfterMins": 0,
         "scaleCount": 3,
         "coolOffMins": 1
    }
...

When I use the continuous autoscaling on a stream with 2 shards and no records, rather than rescaling the stream to 1 shard, it terminates with this message:

INFO: Scale Down Stream multiput-test by 3 Shards as PUT has been below 50% for 0 Minutes
Apr 28, 2015 10:30:40 AM com.snowplowanalytics.devops.autoscalekinesis.StreamMonitor stop
INFO: Signalling Monitor for Stream multiput-test to Stop
Apr 28, 2015 10:30:40 AM com.snowplowanalytics.devops.autoscalekinesis.AutoscalingController startMonitors
SEVERE: java.lang.InterruptedException: Cannot resize to 0 or negative Shard Count
Apr 28, 2015 10:30:40 AM com.snowplowanalytics.devops.autoscalekinesis.AutoscalingController startMonitors
SEVERE: Terminating Thread Pool

If scaleCount is set to 1, no problem occurs.

Autoscaling - Beanstalk logs

Hi,

I have more of a question than an issue. I have deployed the app to Beanstalk. Using version 9.5.1, everything seems to be running fine and the logs are quite detailed. Switching to version 9.5.4, the application logs seem incomplete or at least much less detailed. The app does its job, but I can't see at which point it starts scaling down, what shard it's currently on etc.

For example, here's a screenshot from when the app down-scaled a stream from 3 to 1 shards and these are part of the logs. When the stream is finally at 1 shard, the logs don't say that it can't down-scale further as they did in version 9.5.1, the logs go on the same way as during the resharding process so it's almost impossible to know when the actual resharding happened:
resharding log

Having detailed logs (the same as those in 9.5.1) while using version 9.5.4 would be very helpful. Any suggestions you might have will be very much appreciated.

Thanks,

Mirna

Can only monitor 20 streams

I've observed that of the 26 streams we have configured to be monitored, only 20 are actually monitored.

This appears to be a consequence of the fixed thread pool of 20 initialized in AutoscalingController. Since each stream monitor consumes a thread for the lifetime of the app, 6 streams never get a thread.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.