Reduce memory use of the JVM services

The services now run on Java 17, with a periodic G1 GC that returns unused
heap to the OS when idle. Previously Java 11 kept the committed heap, so
events-processors held 5.5 GB while its live data was ~250 MB.

All RocksDB state stores now share one bounded block cache and write buffer
(ROCKSDB_TOTAL_MEMORY_MB, default 256 MB), instead of each of the ~45 stores
having its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lazzexus 2026-11-03 10:31:04 +01:00
parent e1e59fe66c
commit ba9cbe5afe
7 changed files with 78 additions and 7 deletions

View file

@ -29,7 +29,11 @@ services:
# merge repeated map-chunk updates for 10s before forwarding them (128MB cache per topology)
KAFKA_STREAMS_COMMIT_INTERVAL_MS: "10000"
KAFKA_STREAMS_CACHE_MAX_BYTES: "134217728"
JAVA_OPTS: "-Xmx4g"
# Map chunk bursts (e.g. `/kafkatorio chunks 30`) need a large heap for a while. G1 hands
# unused heap back to the OS when idle (G1PeriodicGCInterval).
JAVA_OPTS: "-Xmx3g -XX:G1PeriodicGCInterval=60000 -XX:MaxHeapFreeRatio=30 -XX:MinHeapFreeRatio=10"
# off-heap memory shared by all RocksDB state stores
ROCKSDB_TOTAL_MEMORY_MB: "256"
networks: [ kafkatorio-nw ]
depends_on: [ infra-kafka ]
volumes:
@ -46,7 +50,7 @@ services:
restart: unless-stopped
environment:
KAFKA_BOOTSTRAP_SERVERS: "kafka:29092"
JAVA_OPTS: "-Xmx256m"
JAVA_OPTS: "-Xmx256m -XX:G1PeriodicGCInterval=60000"
SOCKET_SERVER_HOST: "0.0.0.0"
SOCKET_SERVER_PORT: "9002"
ports:
@ -65,7 +69,7 @@ services:
environment:
KAFKA_BOOTSTRAP_SERVERS: "kafka:29092"
KAFKA_STREAMS_NUM_THREADS: "3"
JAVA_OPTS: "-Xmx1536m"
JAVA_OPTS: "-Xmx768m -XX:G1PeriodicGCInterval=60000 -XX:MaxHeapFreeRatio=30 -XX:MinHeapFreeRatio=10"
WEB_SERVER_PORT: "80"
networks: [ kafkatorio-nw ]
depends_on: [ infra-kafka ]