mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-11-05 20:58:21 +00:00
feat(web-app-peertube): add dynamic performance tuning for heap and transcoding concurrency
- Dynamically calculate PEERTUBE_MAX_OLD_SPACE_SIZE (~35% of container RAM, clamped between 768–3072 MB) - Dynamically calculate PEERTUBE_TRANSCODING_CONCURRENCY (~½ vCPUs, min 1, max 8) - Added default resource limits for Redis and Peertube containers - Updated test suite to include human_to_bytes filter in built-in filter list https://chatgpt.com/share/690914d2-6100-800f-a850-94e6d226e7c9
This commit is contained in:
@@ -30,6 +30,10 @@ docker:
|
||||
services:
|
||||
redis:
|
||||
enabled: true
|
||||
cpus: "0.5"
|
||||
mem_reservation: "256m"
|
||||
mem_limit: "512m"
|
||||
pids_limit: 512
|
||||
database:
|
||||
enabled: true
|
||||
peertube:
|
||||
@@ -38,6 +42,10 @@ docker:
|
||||
image: "chocobozzz/peertube"
|
||||
backup:
|
||||
no_stop_required: true
|
||||
cpus: 4
|
||||
mem_reservation: "4g"
|
||||
mem_limit: "8g"
|
||||
pids_limit: 2048 # ffmpeg spawnt Threads/Prozesse
|
||||
volumes:
|
||||
data: peertube_data
|
||||
config: peertube_config
|
||||
@@ -12,6 +12,17 @@
|
||||
- assets:/app/client/dist
|
||||
- data:/data
|
||||
- config:/config
|
||||
environment:
|
||||
- NODE_OPTIONS=--max-old-space-size={{ PEERTUBE_MAX_OLD_SPACE_SIZE }}
|
||||
- PEERTUBE_TRANSCODING_CONCURRENCY={{ PEERTUBE_TRANSCODING_CONCURRENCY }}
|
||||
shm_size: "512m"
|
||||
tmpfs:
|
||||
- /tmp:size=1g,exec
|
||||
ulimits:
|
||||
nofile:
|
||||
soft: 131072
|
||||
hard: 131072
|
||||
nproc: 8192
|
||||
{% include 'roles/docker-container/templates/depends_on/dmbs_excl.yml.j2' %}
|
||||
{% include 'roles/docker-container/templates/networks.yml.j2' %}
|
||||
{% include 'roles/docker-container/templates/healthcheck/tcp.yml.j2' %}
|
||||
|
||||
@@ -14,4 +14,34 @@ PEERTUBE_CONFIG_VOLUME: "{{ applications | get_app_conf(application_id,
|
||||
|
||||
# OIDC
|
||||
PEERTUBE_OIDC_PLUGIN: "peertube-plugin-auth-openid-connect"
|
||||
PEERTUBE_OIDC_ENABLED: "{{ applications | get_app_conf(application_id, 'features.oidc', False) }}"
|
||||
PEERTUBE_OIDC_ENABLED: "{{ applications | get_app_conf(application_id, 'features.oidc') }}"
|
||||
|
||||
# === Dynamic performance defaults ==========================================
|
||||
|
||||
# Raw Docker configuration values (with sane fallbacks)
|
||||
peertube_cpus: "{{ applications | get_app_conf(application_id, 'docker.services.peertube.cpus') | float }}"
|
||||
peertube_mem_limit_raw: "{{ applications | get_app_conf(application_id, 'docker.services.peertube.mem_limit') }}"
|
||||
peertube_mem_bytes: "{{ peertube_mem_limit_raw | human_to_bytes }}"
|
||||
peertube_mem_mb: "{{ ((peertube_mem_bytes | int) // (1024 * 1024)) | int }}"
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Node heap size:
|
||||
# ~35% of total RAM, but at least 768 MB, at most 3072 MB,
|
||||
# and never more than 60% of total memory (safety cap for small containers)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
_peertube_heap_candidate_mb: "{{ ((peertube_mem_mb | float) * 0.35) | round(0, 'floor') | int }}"
|
||||
_peertube_heap_cap_mb: "{{ ((peertube_mem_mb | float) * 0.60) | round(0, 'floor') | int }}"
|
||||
|
||||
# Step 1: enforce minimum (≥768 MB)
|
||||
_peertube_heap_min_applied: "{{ [ (_peertube_heap_candidate_mb | int), 768 ] | max }}"
|
||||
|
||||
# Step 2: determine hard cap (min of 3072 MB and 60% of total memory)
|
||||
_peertube_heap_hardcap: "{{ [ 3072, (_peertube_heap_cap_mb | int) ] | min }}"
|
||||
|
||||
# Step 3: final heap = min(min-applied, hardcap)
|
||||
PEERTUBE_MAX_OLD_SPACE_SIZE: "{{ [ (_peertube_heap_min_applied | int), (_peertube_heap_hardcap | int) ] | min }}"
|
||||
|
||||
# Transcoding concurrency: half the vCPUs; min 1, max 8
|
||||
_peertube_concurrency_candidate: "{{ ((peertube_cpus | float) * 0.5) | round(0, 'floor') | int }}"
|
||||
PEERTUBE_TRANSCODING_CONCURRENCY: "{{ [ ( [ (_peertube_concurrency_candidate | int), 1 ] | max ), 8 ] | min }}"
|
||||
|
||||
@@ -32,12 +32,7 @@ SHOPWARE_WORKER_REPLICAS: "{{ applications | get_app_conf(application_id,
|
||||
SHOPWARE_REDIS_ENABLED: "{{ applications | get_app_conf(application_id, 'docker.services.redis.enabled') }}"
|
||||
SHOPWARE_REDIS_ADDRESS: "redis:6379"
|
||||
SHOPWARE_OPENSEARCH_ENABLED: "{{ applications | get_app_conf(application_id, 'docker.services.opensearch.enabled') }}"
|
||||
SHOPWARE_OPENSEARCH_ENGINE: "{{ applications | get_app_conf(application_id, 'docker.services.opensearch.engine') }}"
|
||||
SHOPWARE_OPENSEARCH_IMAGE: "{{ applications | get_app_conf(application_id, 'docker.services.opensearch.image') }}"
|
||||
SHOPWARE_OPENSEARCH_VERSION: "{{ applications | get_app_conf(application_id, 'docker.services.opensearch.version') }}"
|
||||
SHOPWARE_OPENSEARCH_CONTAINER: "{{ applications | get_app_conf(application_id, 'docker.services.opensearch.name') }}"
|
||||
SHOPWARE_OPENSEARCH_MEM_RESERVATION: "{{ applications | get_app_conf(application_id, 'docker.services.opensearch.mem_reservation') }}"
|
||||
SHOPWARE_OPENSEARCH_MEM_LIMIT: "{{ applications | get_app_conf(application_id, 'docker.services.opensearch.mem_limit') }}"
|
||||
|
||||
# IAM (true if either OIDC or LDAP is enabled)
|
||||
SHOPWARE_IAM_ENABLED: "{{ applications | get_app_conf(application_id, 'features.oidc') or applications | get_app_conf(application_id, 'features.ldap') }}"
|
||||
|
||||
@@ -37,7 +37,7 @@ BUILTIN_FILTERS: Set[str] = {
|
||||
"type_debug", "json_query", "mandatory", "hash", "checksum",
|
||||
"lower", "upper", "capitalize", "unique", "dict2items", "items2dict",
|
||||
"password_hash", "path_join", "product", "quote", "split", "ternary", "to_nice_yaml",
|
||||
"tojson", "to_nice_json",
|
||||
"tojson", "to_nice_json", "human_to_bytes",
|
||||
|
||||
|
||||
# Date/time-ish
|
||||
|
||||
Reference in New Issue
Block a user