fix(clickhouse): tune memory settings to prevent OOM on insert
ClickHouse 24.12 auto-sizes caches from the cgroup limit, leaving insufficient headroom for MV processing and background merges. Adds a custom config that shrinks mark/index/expression caches and caps per-query memory at 2 GiB. Bumps container limit 4Gi → 6Gi. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -40,12 +40,16 @@ spec:
|
||||
mountPath: /var/lib/clickhouse
|
||||
- name: initdb
|
||||
mountPath: /docker-entrypoint-initdb.d
|
||||
- name: config
|
||||
mountPath: /etc/clickhouse-server/config.d/memory-tuning.xml
|
||||
subPath: memory-tuning.xml
|
||||
readOnly: true
|
||||
resources:
|
||||
requests:
|
||||
memory: "2Gi"
|
||||
cpu: "500m"
|
||||
limits:
|
||||
memory: "4Gi"
|
||||
memory: "6Gi"
|
||||
cpu: "2000m"
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
@@ -67,6 +71,9 @@ spec:
|
||||
- name: initdb
|
||||
configMap:
|
||||
name: clickhouse-initdb
|
||||
- name: config
|
||||
configMap:
|
||||
name: clickhouse-config
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: data
|
||||
@@ -95,6 +102,36 @@ spec:
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: clickhouse-config
|
||||
namespace: cameleer
|
||||
data:
|
||||
memory-tuning.xml: |
|
||||
<clickhouse>
|
||||
<!-- Fit comfortably in a 6Gi container (cgroup limit). -->
|
||||
<!-- Without this file ClickHouse auto-sizes caches and buffers from the -->
|
||||
<!-- cgroup limit, leaving almost no room for query execution. -->
|
||||
|
||||
<!-- Cap any single query/insert (including MV processing) at 2 GiB -->
|
||||
<profiles>
|
||||
<default>
|
||||
<max_memory_usage>2147483648</max_memory_usage>
|
||||
</default>
|
||||
</profiles>
|
||||
|
||||
<!-- Shrink internal caches — defaults are sized for beefy servers -->
|
||||
<mark_cache_size>134217728</mark_cache_size>
|
||||
<index_mark_cache_size>67108864</index_mark_cache_size>
|
||||
<uncompressed_cache_size>0</uncompressed_cache_size>
|
||||
<compiled_expression_cache_size>67108864</compiled_expression_cache_size>
|
||||
|
||||
<merge_tree>
|
||||
<max_bytes_to_merge_at_max_space_in_pool>536870912</max_bytes_to_merge_at_max_space_in_pool>
|
||||
</merge_tree>
|
||||
</clickhouse>
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: clickhouse-initdb
|
||||
namespace: cameleer
|
||||
|
||||
Reference in New Issue
Block a user