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

Issue 1960 - Add properties for table batching lambdas memory & timeout #2002

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions example/full/instance.properties
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ sleeper.table.properties.provider.timeout.minutes=60
# consistent.
sleeper.tables.index.dynamo.consistent.reads=true

# The amount of memory for lambdas that create table batches.
sleeper.table.batching.lambdas.memory=1024

# The timeout in seconds for lambdas that create table batches.
sleeper.table.batching.lambdas.timeout.seconds=60


## The following properties relate to standard ingest.

Expand Down
6 changes: 4 additions & 2 deletions java/cdk/src/main/java/sleeper/cdk/stack/CompactionStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@
import static sleeper.configuration.properties.instance.CommonProperty.ACCOUNT;
import static sleeper.configuration.properties.instance.CommonProperty.ID;
import static sleeper.configuration.properties.instance.CommonProperty.REGION;
import static sleeper.configuration.properties.instance.CommonProperty.TABLE_BATCHING_LAMBDAS_MEMORY_IN_MB;
import static sleeper.configuration.properties.instance.CommonProperty.TABLE_BATCHING_LAMBDAS_TIMEOUT_IN_SECONDS;
import static sleeper.configuration.properties.instance.CommonProperty.TASK_RUNNER_LAMBDA_MEMORY_IN_MB;
import static sleeper.configuration.properties.instance.CommonProperty.TASK_RUNNER_LAMBDA_TIMEOUT_IN_SECONDS;
import static sleeper.configuration.properties.instance.CommonProperty.VPC_ID;
Expand Down Expand Up @@ -267,8 +269,8 @@ private void lambdaToCreateCompactionJobsBatchedViaSQS(
.functionName(triggerFunctionName)
.description("Create batches of tables and send requests to create compaction jobs for those batches")
.runtime(JAVA_11)
.memorySize(256)
.timeout(Duration.seconds(30))
.memorySize(instanceProperties.getInt(TABLE_BATCHING_LAMBDAS_MEMORY_IN_MB))
.timeout(Duration.seconds(instanceProperties.getInt(TABLE_BATCHING_LAMBDAS_TIMEOUT_IN_SECONDS)))
.handler("sleeper.compaction.job.creation.lambda.CreateCompactionJobsTriggerLambda::handleRequest")
.environment(environmentVariables)
.reservedConcurrentExecutions(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
import static sleeper.configuration.properties.instance.CdkDefinedInstanceProperty.GARBAGE_COLLECTOR_QUEUE_URL;
import static sleeper.configuration.properties.instance.CommonProperty.ID;
import static sleeper.configuration.properties.instance.CommonProperty.JARS_BUCKET;
import static sleeper.configuration.properties.instance.CommonProperty.TABLE_BATCHING_LAMBDAS_MEMORY_IN_MB;
import static sleeper.configuration.properties.instance.CommonProperty.TABLE_BATCHING_LAMBDAS_TIMEOUT_IN_SECONDS;
import static sleeper.configuration.properties.instance.GarbageCollectionProperty.GARBAGE_COLLECTOR_LAMBDA_MEMORY_IN_MB;
import static sleeper.configuration.properties.instance.GarbageCollectionProperty.GARBAGE_COLLECTOR_PERIOD_IN_MINUTES;

Expand Down Expand Up @@ -89,8 +91,8 @@ public GarbageCollectorStack(
.runtime(Runtime.JAVA_11)
.handler("sleeper.garbagecollector.GarbageCollectorTriggerLambda::handleRequest")
.environment(Utils.createDefaultEnvironment(instanceProperties))
.memorySize(256)
.timeout(Duration.minutes(1))
.memorySize(instanceProperties.getInt(TABLE_BATCHING_LAMBDAS_MEMORY_IN_MB))
.timeout(Duration.seconds(instanceProperties.getInt(TABLE_BATCHING_LAMBDAS_TIMEOUT_IN_SECONDS)))
.logGroup(createLambdaLogGroup(this, "GarbageCollectorTriggerLogGroup", triggerFunctionName, instanceProperties)));
IFunction handlerFunction = gcJar.buildFunction(this, "GarbageCollectorLambda", builder -> builder
.functionName(functionName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
import static sleeper.configuration.properties.instance.CdkDefinedInstanceProperty.PARTITION_SPLITTING_TABLE_BATCH_QUEUE_URL;
import static sleeper.configuration.properties.instance.CdkDefinedInstanceProperty.PARTITION_SPLITTING_TRIGGER_LAMBDA_FUNCTION;
import static sleeper.configuration.properties.instance.CommonProperty.ID;
import static sleeper.configuration.properties.instance.CommonProperty.TABLE_BATCHING_LAMBDAS_MEMORY_IN_MB;
import static sleeper.configuration.properties.instance.CommonProperty.TABLE_BATCHING_LAMBDAS_TIMEOUT_IN_SECONDS;
import static sleeper.configuration.properties.instance.PartitionSplittingProperty.FIND_PARTITIONS_TO_SPLIT_LAMBDA_MEMORY_IN_MB;
import static sleeper.configuration.properties.instance.PartitionSplittingProperty.FIND_PARTITIONS_TO_SPLIT_TIMEOUT_IN_SECONDS;
import static sleeper.configuration.properties.instance.PartitionSplittingProperty.PARTITION_SPLITTING_TRIGGER_PERIOD_IN_MINUTES;
Expand Down Expand Up @@ -190,8 +192,8 @@ private void createTriggerFunction(InstanceProperties instanceProperties, Lambda
.functionName(triggerFunctionName)
.description("Creates batches of Sleeper tables to perform partition splitting for and puts them on a queue to be processed")
.runtime(software.amazon.awscdk.services.lambda.Runtime.JAVA_11)
.memorySize(256)
.timeout(Duration.seconds(30))
.memorySize(instanceProperties.getInt(TABLE_BATCHING_LAMBDAS_MEMORY_IN_MB))
.timeout(Duration.seconds(instanceProperties.getInt(TABLE_BATCHING_LAMBDAS_TIMEOUT_IN_SECONDS)))
.handler("sleeper.splitter.lambda.FindPartitionsToSplitTriggerLambda::handleRequest")
.environment(environmentVariables)
.reservedConcurrentExecutions(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
import static sleeper.configuration.properties.instance.CdkDefinedInstanceProperty.TABLE_METRICS_RULE;
import static sleeper.configuration.properties.instance.CommonProperty.ID;
import static sleeper.configuration.properties.instance.CommonProperty.JARS_BUCKET;
import static sleeper.configuration.properties.instance.CommonProperty.TABLE_BATCHING_LAMBDAS_MEMORY_IN_MB;
import static sleeper.configuration.properties.instance.CommonProperty.TABLE_BATCHING_LAMBDAS_TIMEOUT_IN_SECONDS;

public class TableMetricsStack extends NestedStack {
public TableMetricsStack(
Expand All @@ -70,8 +72,8 @@ public TableMetricsStack(
.runtime(Runtime.JAVA_11)
.handler("sleeper.metrics.TableMetricsTriggerLambda::handleRequest")
.environment(Utils.createDefaultEnvironment(instanceProperties))
.memorySize(256)
.timeout(Duration.minutes(1))
.memorySize(instanceProperties.getInt(TABLE_BATCHING_LAMBDAS_MEMORY_IN_MB))
.timeout(Duration.seconds(instanceProperties.getInt(TABLE_BATCHING_LAMBDAS_TIMEOUT_IN_SECONDS)))
.logGroup(createLambdaLogGroup(this, "MetricsTriggerLogGroup", triggerFunctionName, instanceProperties)));
IFunction tableMetricsPublisher = metricsJar.buildFunction(this, "MetricsPublisher", builder -> builder
.functionName(publishFunctionName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,18 @@ public interface CommonProperty {
.validationPredicate(Utils::isTrueOrFalse)
.propertyGroup(InstancePropertyGroup.COMMON)
.build();
UserDefinedInstanceProperty TABLE_BATCHING_LAMBDAS_MEMORY_IN_MB = Index.propertyBuilder("sleeper.table.batching.lambdas.memory")
.description("The amount of memory for lambdas that create table batches.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe "that create batches of tables to run some operation against, eg. create compaction jobs, garbage collection, partition splitting"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks that sounds better, i've updated the description

.defaultValue("1024")
.validationPredicate(Utils::isPositiveInteger)
.propertyGroup(InstancePropertyGroup.COMMON)
.build();
UserDefinedInstanceProperty TABLE_BATCHING_LAMBDAS_TIMEOUT_IN_SECONDS = Index.propertyBuilder("sleeper.table.batching.lambdas.timeout.seconds")
.description("The timeout in seconds for lambdas that create table batches.")
.defaultValue("60")
.validationPredicate(Utils::isPositiveInteger)
.propertyGroup(InstancePropertyGroup.COMMON)
.build();

static List<UserDefinedInstanceProperty> getAll() {
return Index.INSTANCE.getAll();
Expand Down
6 changes: 6 additions & 0 deletions scripts/templates/instanceproperties.template
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ sleeper.table.properties.provider.timeout.minutes=60
# consistent.
sleeper.tables.index.dynamo.consistent.reads=true

# The amount of memory for lambdas that create table batches.
sleeper.table.batching.lambdas.memory=1024

# The timeout in seconds for lambdas that create table batches.
sleeper.table.batching.lambdas.timeout.seconds=60


## The following properties relate to standard ingest.

Expand Down
Loading