You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by tr...@apache.org on 2022/02/07 15:55:12 UTC
[flink-statefun-playground] 04/04: [FLINK-25934] Reduce Statefun's memory consumption to 300mb
This is an automated email from the ASF dual-hosted git repository.
trohrmann pushed a commit to branch release-3.2
in repository https://gitbox.apache.org/repos/asf/flink-statefun-playground.git
commit 54fb18dd5d5b16c74ed09603568755bbf0d2a7a0
Author: Till Rohrmann <tr...@apache.org>
AuthorDate: Sun Feb 6 13:14:30 2022 +0100
[FLINK-25934] Reduce Statefun's memory consumption to 300mb
---
playground-internal/statefun-playground-entrypoint/Dockerfile | 4 +++-
.../statefun-playground-entrypoint/docker-entrypoint.sh | 10 ++++++++++
.../internal/entrypoint/LocalEnvironmentEntrypoint.java | 7 +++++++
3 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/playground-internal/statefun-playground-entrypoint/Dockerfile b/playground-internal/statefun-playground-entrypoint/Dockerfile
index 0438cc9..31bfb44 100644
--- a/playground-internal/statefun-playground-entrypoint/Dockerfile
+++ b/playground-internal/statefun-playground-entrypoint/Dockerfile
@@ -23,4 +23,6 @@ RUN mvn -f /usr/src/app/pom.xml clean package
FROM openjdk:11
WORKDIR /
COPY --from=builder /usr/src/app/target/statefun-playground-entrypoint*.jar statefun-playground-entrypoint.jar
-ENTRYPOINT ["java", "-jar", "statefun-playground-entrypoint.jar"]
+COPY docker-entrypoint.sh /
+RUN chmod +x /docker-entrypoint.sh
+ENTRYPOINT ["/docker-entrypoint.sh"]
diff --git a/playground-internal/statefun-playground-entrypoint/docker-entrypoint.sh b/playground-internal/statefun-playground-entrypoint/docker-entrypoint.sh
new file mode 100644
index 0000000..f542d2f
--- /dev/null
+++ b/playground-internal/statefun-playground-entrypoint/docker-entrypoint.sh
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+
+java \
+-XX:MaxDirectMemorySize=${MAX_DIRECT_MEMORY_SIZE:-80m} \
+-XX:MaxMetaspaceSize=${MAX_METASPACE_SIZE:-64m} \
+-Xms${MIN_HEAP_SIZE:-64m} \
+-Xmx${MAX_HEAP_SIZE:-192m} \
+-jar \
+statefun-playground-entrypoint.jar \
+"$@"
diff --git a/playground-internal/statefun-playground-entrypoint/src/main/java/org/apache/flink/statefun/playground/internal/entrypoint/LocalEnvironmentEntrypoint.java b/playground-internal/statefun-playground-entrypoint/src/main/java/org/apache/flink/statefun/playground/internal/entrypoint/LocalEnvironmentEntrypoint.java
index fb43e85..8503cf2 100644
--- a/playground-internal/statefun-playground-entrypoint/src/main/java/org/apache/flink/statefun/playground/internal/entrypoint/LocalEnvironmentEntrypoint.java
+++ b/playground-internal/statefun-playground-entrypoint/src/main/java/org/apache/flink/statefun/playground/internal/entrypoint/LocalEnvironmentEntrypoint.java
@@ -21,7 +21,9 @@ import java.util.Collection;
import org.apache.flink.api.java.utils.MultipleParameterTool;
import org.apache.flink.configuration.CheckpointingOptions;
import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.MemorySize;
import org.apache.flink.configuration.StateBackendOptions;
+import org.apache.flink.configuration.TaskManagerOptions;
import org.apache.flink.statefun.flink.core.StatefulFunctionsConfig;
import org.apache.flink.statefun.flink.core.StatefulFunctionsJob;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
@@ -96,6 +98,11 @@ public final class LocalEnvironmentEntrypoint {
flinkConfiguration.set(StateBackendOptions.STATE_BACKEND, "rocksdb");
flinkConfiguration.set(CheckpointingOptions.INCREMENTAL_CHECKPOINTS, true);
+ // reduce Flink's memory footprint a bit
+ flinkConfiguration.set(TaskManagerOptions.MANAGED_MEMORY_SIZE, MemorySize.ofMebiBytes(64));
+ flinkConfiguration.set(TaskManagerOptions.NETWORK_MEMORY_MIN, MemorySize.ofMebiBytes(16));
+ flinkConfiguration.set(TaskManagerOptions.NETWORK_MEMORY_MAX, MemorySize.ofMebiBytes(16));
+
return flinkConfiguration;
}
}