You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@samza.apache.org by GitBox <gi...@apache.org> on 2021/09/16 02:05:52 UTC

[GitHub] [samza] lakshmi-manasa-g opened a new pull request #1531: SAMZA-2688: [Elasticity] introduce configs and sub-partition concept aka SystemStreamPartitionKeyHash

lakshmi-manasa-g opened a new pull request #1531:
URL: https://github.com/apache/samza/pull/1531


   Feature: Elasticity for Samza job. Throughput via parallelism is tied to the number of tasks which is equal to the partition count of input streams. If a job is facing lag and is already at the max container count = number of tasks = number of input partitions, then the only choice it is left with is to repartition the input. This PR is part of the feature which aims to increase throughput by scaling task count beyond the input partition count. In this PR, the config and basic class for elasticity are introduced. 
   
   Changes:  Introduce config "task.elasticity.factor" which defaults to 1. If factor = X>1 then each task is split into X elastic tasks. Also, introduce SystemStreamPartitionKeyHash which represents the portion of SSP that an elastic task will consume.
   
   Tests: existing tests pass.
   
   API changes: New config "task.elasticity.factor" which if > 1 enables this elasticity feature.
   
   upgrade/usage instructions: add above config with value >1 to enable feature.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [samza] rmatharu commented on a change in pull request #1531: SAMZA-2688: [Elasticity] introduce configs and sub-partition concept aka SystemStreamPartitionKeyHash

Posted by GitBox <gi...@apache.org>.
rmatharu commented on a change in pull request #1531:
URL: https://github.com/apache/samza/pull/1531#discussion_r711292347



##########
File path: samza-core/src/main/java/org/apache/samza/config/TaskConfig.java
##########
@@ -136,6 +136,11 @@
       "task.transactional.state.retain.existing.state";
   private static final boolean DEFAULT_TRANSACTIONAL_STATE_RETAIN_EXISTING_STATE = true;
 
+  // Job Elasticity related configs
+  // Take effect only when job.elasticity.factor is > 1. otherwise there is no elasticity
+  private static final String TASK_ELASTICITY_FACTOR = "task.elasticity.factor";

Review comment:
       is this more like a task-to-partition mapping factor?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [samza] lakshmi-manasa-g commented on a change in pull request #1531: SAMZA-2688: [Elasticity] introduce configs and sub-partition concept aka SystemStreamPartitionKeyHash

Posted by GitBox <gi...@apache.org>.
lakshmi-manasa-g commented on a change in pull request #1531:
URL: https://github.com/apache/samza/pull/1531#discussion_r713277339



##########
File path: samza-api/src/main/java/org/apache/samza/system/SystemStreamPartitionKeyHash.java
##########
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.samza.system;
+
+import org.apache.samza.Partition;
+
+/**
+ * Aggregate object representing a portion of {@link SystemStreamPartition} consisting of envelopes within the
+ * SystemStreamPartition that have envelope.key % job's elasticity factor = keyHash of this object.
+ */
+public class SystemStreamPartitionKeyHash extends SystemStreamPartition {

Review comment:
       theoretically this should be possible. But the problem I forsee is with the serde of job model where the backwards compatability of reading an old job model containing old SSP serde might get impacted with the new defn and serde of SSP. Let me test this and get back on this thread. 

##########
File path: samza-api/src/main/java/org/apache/samza/system/IncomingMessageEnvelope.java
##########
@@ -71,6 +74,7 @@ public IncomingMessageEnvelope(SystemStreamPartition systemStreamPartition, Stri
     this.message = message;
     this.size = size;
     this.arrivalTime = Instant.now().toEpochMilli();
+    this.hashCodeForKeyHashComputation = key != null ? key.hashCode() : offset != null ? offset.hashCode() : hashCode();

Review comment:
       I did consider this originally but if there are multiple calls to getSystemStreamPartitionKeyHash then it would be worth having this cached.

##########
File path: samza-core/src/main/java/org/apache/samza/config/TaskConfig.java
##########
@@ -136,6 +136,11 @@
       "task.transactional.state.retain.existing.state";
   private static final boolean DEFAULT_TRANSACTIONAL_STATE_RETAIN_EXISTING_STATE = true;
 
+  // Job Elasticity related configs
+  // Take effect only when job.elasticity.factor is > 1. otherwise there is no elasticity
+  private static final String TASK_ELASTICITY_FACTOR = "task.elasticity.factor";

Review comment:
       I am looking at this more as a split multiple. As in if the factor = 2 then split each original task into 2 virtual/elastic tasks. It can also be looked at as task-to-partition/ssp factor where factor = 2 means each ssp is read by 2 virtual/elastic tasks. would lend the same semantics.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [samza] rmatharu commented on a change in pull request #1531: SAMZA-2688: [Elasticity] introduce configs and sub-partition concept aka SystemStreamPartitionKeyHash

Posted by GitBox <gi...@apache.org>.
rmatharu commented on a change in pull request #1531:
URL: https://github.com/apache/samza/pull/1531#discussion_r711291432



##########
File path: samza-api/src/main/java/org/apache/samza/system/SystemStreamPartitionKeyHash.java
##########
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.samza.system;
+
+import org.apache.samza.Partition;
+
+/**
+ * Aggregate object representing a portion of {@link SystemStreamPartition} consisting of envelopes within the
+ * SystemStreamPartition that have envelope.key % job's elasticity factor = keyHash of this object.
+ */
+public class SystemStreamPartitionKeyHash extends SystemStreamPartition {

Review comment:
       Would it be possible to add the changes (i.e., keyhash) within SystemStreamPartition class itself?
   Since logically this is representing a key-range (which is pretty such a "partition" of data, albeit different from the input kafka-partition)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [samza] rmatharu commented on a change in pull request #1531: SAMZA-2688: [Elasticity] introduce configs and sub-partition concept aka SystemStreamPartitionKeyHash

Posted by GitBox <gi...@apache.org>.
rmatharu commented on a change in pull request #1531:
URL: https://github.com/apache/samza/pull/1531#discussion_r711290092



##########
File path: samza-api/src/main/java/org/apache/samza/system/IncomingMessageEnvelope.java
##########
@@ -71,6 +74,7 @@ public IncomingMessageEnvelope(SystemStreamPartition systemStreamPartition, Stri
     this.message = message;
     this.size = size;
     this.arrivalTime = Instant.now().toEpochMilli();
+    this.hashCodeForKeyHashComputation = key != null ? key.hashCode() : offset != null ? offset.hashCode() : hashCode();

Review comment:
       Is there a benefit to caching and storing it, rather than computing and exposing it via a function?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org