Skip to content

Commit 7ccbfd3

Browse files
feat(backend): allow setting JVM options by using entrypoint.sh in dockerfile, free memory (#1901)
- Use an entrypoint.sh file for backend to allow passing JVM options - Pass `-XX:+UseContainerSupport -XX:+UseG1GC -XX:MaxHeapFreeRatio=5 -XX:MinHeapFreeRatio=2` to free memory, this allows us to set the memory limit fairly high without Java taking up a lot of memory - Increase memory limit of: a) silo preprocessing (it can spike up to 3GB for full mpox), b) nextclade preprocessing (it can also go beyond 1GB), c) backend (it can go above 1GB with full mpox)
1 parent c348613 commit 7ccbfd3

File tree

5 files changed

+21
-4
lines changed

5 files changed

+21
-4
lines changed

backend/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ FROM eclipse-temurin:21-jre-alpine
33
WORKDIR /app
44

55
COPY build/libs/backend.jar app.jar
6+
COPY entrypoint.sh entrypoint.sh
7+
RUN chmod +x entrypoint.sh
68

79
EXPOSE 8079
810

9-
ENTRYPOINT ["java", "-jar", "app.jar", "--spring.profiles.active=docker"]
11+
ENTRYPOINT ["./entrypoint.sh"]

backend/entrypoint.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
JVM_OPTS=${JVM_OPTS:-}
3+
# Take script arguments
4+
ARGS="${*}"
5+
6+
if [ -n "$JVM_OPTS" ]; then
7+
CMD="java $JVM_OPTS -jar app.jar --spring.profiles.active=docker $ARGS"
8+
else
9+
CMD="java -jar app.jar --spring.profiles.active=docker $ARGS"
10+
fi
11+
echo Running:
12+
echo "$CMD"
13+
$CMD

kubernetes/loculus/templates/lapis-silo-deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ spec:
6767
memory: "100Mi"
6868
cpu: "10m"
6969
limits:
70-
memory: "1Gi"
70+
memory: "3Gi"
7171
command:
7272
- sh
7373
- /silo_import_wrapper.sh

kubernetes/loculus/templates/loculus-backend.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ spec:
3131
memory: "640Mi"
3232
cpu: "100m"
3333
limits:
34-
memory: "1Gi" # Backend requires at least 635741K of memory
34+
memory: "3Gi" # Backend requires at least 635741K of memory
3535
livenessProbe:
3636
httpGet:
3737
path: "/actuator/health/liveness"
@@ -59,6 +59,8 @@ spec:
5959
- "--spring.datasource.username=$(DB_USERNAME)"
6060
- "--spring.security.oauth2.resourceserver.jwt.jwk-set-uri=http://loculus-keycloak-service:8083/realms/loculus/protocol/openid-connect/certs"
6161
env:
62+
- name: JVM_OPTS
63+
value: -XX:+UseContainerSupport -XX:+UseG1GC -XX:MaxHeapFreeRatio=5 -XX:MinHeapFreeRatio=2
6264
{{- if .Values.enableCrossRefCredentials }}
6365
- name: CROSSREF_USERNAME
6466
valueFrom:

kubernetes/loculus/templates/loculus-preprocessing-deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ spec:
3939
memory: "40Mi"
4040
cpu: "10m"
4141
limits:
42-
memory: "1Gi"
42+
memory: "3Gi"
4343
env:
4444
- name: KEYCLOAK_PASSWORD
4545
valueFrom:

0 commit comments

Comments
 (0)