Skip to main content

Resource limits

This guide explains how to configure resource limits for Faheem Code Enterprise components. Proper resource configuration ensures stable operation and prevents issues like OOMKills and pod evictions.

Values file structure

All configuration examples in this guide show keys that belong in your site-values.yaml file. The examples show the complete path from the root of the file.

Understanding Kubernetes resources

Kubernetes uses two key resource settings:

  • Requests: The minimum resources guaranteed to a pod. The scheduler uses this to place pods on nodes with sufficient capacity.
  • Limits: The maximum resources a pod can use. Exceeding memory limits causes an OOMKill; exceeding CPU limits causes throttling.

Application server resources

The Faheem Code application server (deployment name: faheemcode) handles the UI, API, and agent orchestration. Configure its resources under the deployment section in your values file.

Default configuration

# site-values.yaml

# ============================================================================
# Application Server (Faheem Code deployment)
# ============================================================================
# Root-level key: deployment
# Controls the main Faheem Code server pod resources
# ============================================================================
deployment:
replicas: 1
resources:
requests:
memory: 1200Mi
cpu: 100m
limits:
memory: 3Gi

For production workloads, increase memory and add replicas for redundancy:

# site-values.yaml

deployment: # Root-level key
replicas: 2
resources:
requests:
memory: 2560Mi # 2.5Gi - aligns with typical usage
cpu: 100m
limits:
memory: 4Gi # Buffer against OOMKill

When to adjust

Increase resources if you observe:

SymptomMetric to CheckAction
Pod restartsRESTARTS column in kubectl get podsIncrease limits.memory
High memory usagekubectl top pods shows >80% of limitIncrease limits.memory
Evictions during node pressurePod events show evictionIncrease requests.memory to match actual usage
Slow response timesApplication latency metricsAdd replicas or increase CPU

Horizontal pod autoscaling

For automatic scaling based on load, enable the HorizontalPodAutoscaler:

# site-values.yaml

deployment: # Root-level key
replicas: 2 # Minimum baseline
resources:
requests:
memory: 2560Mi
cpu: 200m # Increase for HPA to use as scaling signal
limits:
memory: 4Gi

autoscaling: # Root-level key (separate from deployment)
enabled: true
minReplicas: 2
maxReplicas: 5
targetCPUUtilizationPercentage: 80
targetMemoryUtilizationPercentage: 80

Sandbox resources

Sandboxes (also called runtimes) are the isolated containers where agents execute code. Each conversation runs in its own sandbox pod. Configure these via environment variables in the runtime-api.env section.

Available settings

VariableDefaultDescription
MEMORY_REQUEST3072MiMinimum memory guaranteed per sandbox
MEMORY_LIMIT3072MiMaximum memory per sandbox
CPU_REQUEST500mMinimum CPU guaranteed (500m = 0.5 cores)
CPU_LIMIT(none)Maximum CPU per sandbox
EPHEMERAL_STORAGE_SIZE10GiTemporary storage per sandbox

Default configuration

# site-values.yaml

# ============================================================================
# Runtime API (Sandbox Manager)
# ============================================================================
# Root-level key: runtime-api
# This is a subchart that manages sandbox pod lifecycle.
# The env section passes environment variables to the runtime-api container,
# which uses them when creating sandbox pods.
# ============================================================================
runtime-api:
env:
MEMORY_REQUEST: "3072Mi"
MEMORY_LIMIT: "3072Mi"
CPU_REQUEST: "500m"
EPHEMERAL_STORAGE_SIZE: "10Gi"

High-resource configuration

For workloads that require more resources (large codebases, memory-intensive builds):

# site-values.yaml

runtime-api: # Root-level key (subchart configuration)
env:
MEMORY_REQUEST: "8192Mi"
MEMORY_LIMIT: "8192Mi"
CPU_REQUEST: "2000m"
CPU_LIMIT: "4000m"
EPHEMERAL_STORAGE_SIZE: "50Gi"

Resource format

  • Memory: Use Mi suffix (mebibytes). Examples: 1024Mi, 4096Mi, 8192Mi
  • CPU: Use millicores. 1000m = 1 CPU core. Examples: 500m, 2000m, 4000m
  • Storage: Use Gi suffix (gibibytes). Examples: 10Gi, 50Gi, 100Gi

Applying changes

1. Update your values file

Edit site-values.yaml with your desired configuration:

# site-values.yaml
#
# This file contains your custom overrides for the Faheem Code Helm chart.
# All keys shown here are root-level keys in the values hierarchy.

# ============================================================================
# Application Server Resources
# ============================================================================
deployment:
replicas: 2
resources:
requests:
memory: 2560Mi
cpu: 100m
limits:
memory: 4Gi

# ============================================================================
# Sandbox Resources (via Runtime API subchart)
# ============================================================================
runtime-api:
env:
MEMORY_REQUEST: "8192Mi"
MEMORY_LIMIT: "8192Mi"
CPU_REQUEST: "2000m"
CPU_LIMIT: "4000m"
EPHEMERAL_STORAGE_SIZE: "50Gi"

2. Apply with Helm upgrade

helm upgrade faheemcode \
oci://ghcr.io/alsairy/faheem-code-charts/faheemcode \
-f site-values.yaml \
-n faheemcode

Verifying changes

Check application server resources

kubectl get deployment faheemcode -n faheemcode \
-o jsonpath='{.spec.template.spec.containers[0].resources}' | jq

Check replica count

kubectl get deployment faheemcode -n faheemcode \
-o jsonpath='{.spec.replicas}'

Check runtime-api environment variables

Verify the sandbox resource settings are configured in the runtime-api deployment:

kubectl get deployment runtime-api -n faheemcode \
-o jsonpath='{.spec.template.spec.containers[0].env}' | \
jq '.[] | select(.name | test("MEMORY|CPU|STORAGE"))'

Monitoring resource usage

Current resource consumption

kubectl top pods -n faheemcode

Resource usage over time

For production deployments, we recommend integrating with a monitoring solution (Prometheus/Grafana, Datadog, etc.) to track:

  • Memory usage vs. limits (to predict OOMKills)
  • Memory usage vs. requests (to predict evictions)
  • CPU throttling events
  • Pod restart counts

Next steps