tune Nextcloud Apache/PHP to fix constant crash-looping (50 restarts/6d)

Root cause: Apache prefork with 150 MaxRequestWorkers (each ~220MB RSS)
on SQLite DB causes worker exhaustion + lock contention → Apache hangs →
aggressive liveness probe (3 failures × 10s) kills container.

Fixes:
- Apache: MaxRequestWorkers 150→25, MaxConnectionsPerChild 0→200,
  StartServers 5→3 (via ConfigMap mount over mpm_prefork.conf)
- PHP: max_execution_time 0→300s, max_input_time 300s (prevent zombie workers)
- Liveness probe: period 10s→30s, failureThreshold 3→6, timeout 5s→10s
  (180s tolerance vs 30s before)
- Readiness probe: period 10s→30s, timeout 5s→10s
This commit is contained in:
Viktor Barzin 2026-03-08 21:33:27 +00:00
parent ad8b90575e
commit ff03f2b99f
2 changed files with 56 additions and 0 deletions

View file

@ -86,6 +86,26 @@ resource "helm_release" "nextcloud" {
timeout = 6000
}
resource "kubernetes_config_map" "apache_tuning" {
metadata {
name = "nextcloud-apache-tuning"
namespace = kubernetes_namespace.nextcloud.metadata[0].name
}
data = {
"mpm_prefork.conf" = <<-EOF
# Tuned for container with 6Gi memory limit
# Each worker uses ~220MB RSS, so 25 workers 5.5GB
<IfModule mpm_prefork_module>
StartServers 3
MinSpareServers 2
MaxSpareServers 5
MaxRequestWorkers 25
MaxConnectionsPerChild 200
</IfModule>
EOF
}
}
# resource "kubernetes_config_map" "config" {
# metadata {
# name = "config"