Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable autoscaling when using programmatic tables #140

Merged
merged 2 commits into from Apr 19, 2018

Conversation

amcp
Copy link
Contributor

@amcp amcp commented Apr 10, 2018

Fixes #131

I use default values present in the AWS console for all numbers (initial r/w CU, minimum r/w CU, maximum r/w CU and target r/w utilization).

@@ -252,8 +278,8 @@ private void initializeTable() {

logger.debug("Creating table if it does not exist yet");

Long readCapacityUnits = Long.parseLong(this.config.getReadCapacityUnits());
Long writeCapacityUnits = Long.parseLong(this.config.getWriteCapacityUnits());
Long readCapacityUnits = this.config.getReadCapacityUnits();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for myself: In my initial PR for the DDB plugin #76 I had this as Long and Eureka had some issues with it. That is why I changed it to String and did the funky parseLong stuff.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -134,6 +154,12 @@ public void init(DataGenerator dataGenerator) throws Exception {
} else {
dynamoDB = new DynamoDB(client);
}
autoScalingClient = AWSApplicationAutoScalingClientBuilder.standard()
Copy link
Contributor

@ipapapa ipapapa Apr 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume we want to configure autoscaling if we use this.config.programmableTables() otherwise, the user should use the AWS Console to play around with Table configurations. Therefore this should fit in the initializeTable() method. Am I missing something here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, programmableTables=false and autoscaling=true is an invalid configuration. ill put this logic in initialize.

@ipapapa
Copy link
Contributor

ipapapa commented Apr 11, 2018

@amcp @vinaykumarchella @jolynch @shailesh33 I am not sure if it clear in the code. There are two ways to use the plugin. One way that the user does everything through the AWS Console and the second way that the user does most Table configurations programmatically. It feels to me that the first would be the majority of the use cases. Hence this PR should fit in the initializeTable() method. An alternative approach would be to have a separate plugin one that the user configures the table programmatically and one that the user does it through the AWS console. Thoughts on which approach?

writeCapacityUnits,
limits.getTableMaxWriteCapacityUnits().intValue(),
targetWriteUtilization);
createAndVerifyScalableTargetAndScalingPolicy(serviceRoleArn,
Copy link
Contributor

@ipapapa ipapapa Apr 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason calling createAndVerifyScalableTargetAndScalingPolicy twice?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, once for the read utilization/capacity target and once for the write utilization/capacity target

Copy link
Contributor

@ipapapa ipapapa Apr 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, my mistake. I missed the difference in the arguments. It might worth adding a comment above for people who read the code.


// configure autoscaling - from aws docs
// https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/AutoScaling.HowTo.SDK.html
final String resourceID = "table/" + config.getTableName();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These final variables definition at the end of the method does not help the readability of the code. Their scope of usage is in createAndVerifyScalableTargetAndScalingPolicy hence I am wondering if it is better to define them in there. Moreover, the class is becoming too long, does it worth splitting into a different class?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed the final and moving to a different class.

@amcp
Copy link
Contributor Author

amcp commented Apr 12, 2018

@ipapapa seems like I am going to have to do the credential refactoring first then rebase this branch on the credential refactoring. lets put this PR on hold until then.

@ipapapa
Copy link
Contributor

ipapapa commented Apr 12, 2018

OK, I will block it to avoid mistakenly merging it until you tell me to unblock it.

Copy link
Contributor

@ipapapa ipapapa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking it based on author request.

@amcp amcp force-pushed the autoscale branch 2 times, most recently from 761f1da to 442a17c Compare April 14, 2018 06:32
@ipapapa
Copy link
Contributor

ipapapa commented Apr 15, 2018

Is there an update on this PR? is it WIP?

@amcp amcp force-pushed the autoscale branch 4 times, most recently from 53fcc9c to dde7e12 Compare April 16, 2018 11:29
@amcp
Copy link
Contributor Author

amcp commented Apr 16, 2018

I've opened PR #182 to fix the story on credential injection. After merging #182, let me rebase this PR and then we can merge it.

@amcp
Copy link
Contributor Author

amcp commented Apr 16, 2018

I rebased on the cli branch for easier testing.

@amcp
Copy link
Contributor Author

amcp commented Apr 16, 2018

Setup:

sudo yum update -y \
&& sudo yum upgrade -y \
&& sudo yum install -y java-1.8.0-openjdk-devel git emacs \
&& sudo yum remove -y java-1.7.0-openjdk \
&& git clone https://github.com/amcp/ndbench.git \
&& cd ndbench \
&& git checkout consumed \
&& ./gradlew build

Test:

DISCOVERY_ENV=AWS ./gradlew run \
-Dndbench.config.cli.clientName=DynamoDBKeyValue \
-Dndbench.config.cli.bulkSize=1 \
-Dndbench.config.cli.timeoutMillis=600000 \
-Dndbench.config.dataSize=1000 \
-Dndbench.config.numKeys=1 \
-Dndbench.config.readEnabled=true \
-Dndbench.config.readRateLimit=4 \
-Dndbench.config.writeEnabled=true \
-Dndbench.config.writeRateLimit=4 \
-Dndbench.config.dynamodb.rcu=5 \
-Dndbench.config.dynamodb.wcu=5 \
-Dndbench.config.dynamodb.tablename=auto \
-Dndbench.config.dynamodb.consistentread=true \
-Dndbench.config.dynamodb.maxRetries=0 \
-Dndbench.config.dynamodb.requestTimeout=100 \
-Dndbench.config.dynamodb.maxConnections=1 \
-Dndbench.config.dynamodb.numReaders=1 \
-Dndbench.config.dynamodb.numWriters=1 \
-Dndbench.config.dynamodb.programmableTables=true

@amcp amcp force-pushed the autoscale branch 2 times, most recently from c5e535b to d5e15a1 Compare April 16, 2018 20:21
@amcp amcp closed this Apr 16, 2018
@amcp amcp reopened this Apr 16, 2018
@amcp amcp force-pushed the autoscale branch 2 times, most recently from 10b332b to f0f1455 Compare April 18, 2018 18:42
Partially addresses Netflix#118
@ipapapa ipapapa merged commit 0bd861f into Netflix:master Apr 19, 2018
@amcp amcp deleted the autoscale branch April 19, 2018 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants