Skip to content

Commit

Permalink
feat(backend): allow setting JVM options by using entrypoint.sh in do…
Browse files Browse the repository at this point in the history
…ckerfile, 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)
  • Loading branch information
corneliusroemer authored May 14, 2024
1 parent c348613 commit 7ccbfd3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
4 changes: 3 additions & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ FROM eclipse-temurin:21-jre-alpine
WORKDIR /app

COPY build/libs/backend.jar app.jar
COPY entrypoint.sh entrypoint.sh
RUN chmod +x entrypoint.sh

EXPOSE 8079

ENTRYPOINT ["java", "-jar", "app.jar", "--spring.profiles.active=docker"]
ENTRYPOINT ["./entrypoint.sh"]
13 changes: 13 additions & 0 deletions backend/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
JVM_OPTS=${JVM_OPTS:-}
# Take script arguments
ARGS="${*}"

if [ -n "$JVM_OPTS" ]; then
CMD="java $JVM_OPTS -jar app.jar --spring.profiles.active=docker $ARGS"
else
CMD="java -jar app.jar --spring.profiles.active=docker $ARGS"
fi
echo Running:
echo "$CMD"
$CMD
2 changes: 1 addition & 1 deletion kubernetes/loculus/templates/lapis-silo-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ spec:
memory: "100Mi"
cpu: "10m"
limits:
memory: "1Gi"
memory: "3Gi"
command:
- sh
- /silo_import_wrapper.sh
Expand Down
4 changes: 3 additions & 1 deletion kubernetes/loculus/templates/loculus-backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ spec:
memory: "640Mi"
cpu: "100m"
limits:
memory: "1Gi" # Backend requires at least 635741K of memory
memory: "3Gi" # Backend requires at least 635741K of memory
livenessProbe:
httpGet:
path: "/actuator/health/liveness"
Expand Down Expand Up @@ -59,6 +59,8 @@ spec:
- "--spring.datasource.username=$(DB_USERNAME)"
- "--spring.security.oauth2.resourceserver.jwt.jwk-set-uri=http://loculus-keycloak-service:8083/realms/loculus/protocol/openid-connect/certs"
env:
- name: JVM_OPTS
value: -XX:+UseContainerSupport -XX:+UseG1GC -XX:MaxHeapFreeRatio=5 -XX:MinHeapFreeRatio=2
{{- if .Values.enableCrossRefCredentials }}
- name: CROSSREF_USERNAME
valueFrom:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ spec:
memory: "40Mi"
cpu: "10m"
limits:
memory: "1Gi"
memory: "3Gi"
env:
- name: KEYCLOAK_PASSWORD
valueFrom:
Expand Down

0 comments on commit 7ccbfd3

Please sign in to comment.