This message was deleted.
# ask-ai
s
This message was deleted.
t
Thanks for reaching out, massrylama. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Let's walk through how you can enable Horizontal Pod Autoscaler (HPA) automatically for both your Egress service and LiveKit server by configuring the
autoscaling
section in their Helm chart values. Don't worry, I'll guide you step-by-step! For Egress:
Copy code
autoscaling:
  enabled: true
  minReplicas: 1
  maxReplicas: 5
  targetCPUUtilizationPercentage: 60
  targetMemoryUtilizationPercentage: 60
  custom:
    metricName: livekit_egress_available
    targetAverageValue: 70
Here, you can use the custom metric
livekit_egress_available
to get even more precise scaling. To make this work smoothly, just make sure you have the Prometheus adapter installed in your Kubernetes cluster and that the
prometheus_port
is configured in your Egress settings to expose the necessary metrics. For LiveKit Server:
Copy code
autoscaling:
  enabled: true
  minReplicas: 2
  maxReplicas: 10
  targetCPUUtilizationPercentage: 70
  targetMemoryUtilizationPercentage: 80
This setup will create an HPA object that targets your LiveKit server deployment, scaling it based on CPU and memory usage. One important tip: make sure you have resource limits defined in your container specs to ensure autoscaling behaves as expected. And if you're using custom metrics, don't forget to configure the Prometheus adapter accordingly. If you need any help with these steps, feel free to ask—I’m here to support you! Sources: Self-hosting the Egress Service | LiveKit Docs | Self-hosting the Ingress Service | LiveKit Docs | egress-sample.yaml
It looks like the limitation to 2 Egress instances might be related to configuration settings or resource constraints. Let’s walk through some key points together to help you troubleshoot this: 1. Autoscaling Configuration: • First, please check that
autoscaling.enabled
is set to
true
in your Helm chart values. If it’s set to
false
, the number of instances will be fixed at
replicaCount
, which seems to be 2 in your setup. • Also, make sure the HPA resource is created and active by running:
Copy code
kubectl get hpa
kubectl describe hpa livekit-egress-hpa
2. Metrics Availability: • If you’re using CPU/memory-based scaling, please confirm that the metrics-server is running with:
Copy code
kubectl get pods -n kube-system | grep metrics-server
• And if you’re relying on custom metrics like
livekit_egress_available
, double-check that the Prometheus adapter is installed and properly configured. 3. Resource Requests: • For the HPA to work effectively,
resources.requests
need to be defined in your deployment. For example:
Copy code
resources:
  requests:
    cpu: "1"
    memory: "2Gi"
  limits:
    cpu: "4"
    memory: "8Gi"
4. Cluster Constraints: • Lastly, it’s a good idea to check if your cluster has enough resources or quotas to allow scaling beyond 2 instances by running:
Copy code
kubectl describe nodes
kubectl describe quota
If you’d like, I’m here to help you go through any of these steps or clarify anything. Just let me know! Sources: ingress-sample.yaml | Self-hosting the Egress Service | LiveKit Docs
I'm happy to help you understand how many Egress pods can run in parallel on an AWS
c5.4xlarge
instance, and it really depends on the type of workload you're working with: 1. Room Composite Egress: Each pod needs 4 CPUs and 4 GB of memory. Since a
c5.4xlarge
instance offers 16 vCPUs and 32 GB memory, you can comfortably run up to 4 Room Composite Egress pods at the same time. 2. Track Egress: These are much lighter on resources, so you can actually run hundreds of Track Egress jobs simultaneously on that same instance. To make sure you're getting the most out of your resources, here are a couple of tips: • Keep an eye on the
livekit_egress_available
Prometheus metric to monitor how much capacity your instance has and scale accordingly. • Consider enabling autoscaling so the number of pods adjusts automatically based on the resources being used. If you'd like, I’d be more than happy to guide you through setting up monitoring or autoscaling tailored to your needs. Just let me know! Sources: Self-hosting the Egress Service | LiveKit Docs | egress/values.yaml
I'm glad to help you with setting up autoscaling and monitoring using the
livekit_egress_available
metric. Here's a friendly example configuration to guide you through the process: 1. Helm Chart Configuration: Let's start by updating your Helm values file for Egress:
Copy code
autoscaling:
  enabled: true
  minReplicas: 1
  maxReplicas: 10
  custom:
    metricName: livekit_egress_available
    targetAverageValue: 3

resources:
  requests:
    cpu: 4000m
    memory: 4Gi
  limits:
    cpu: 8000m
    memory: 8Gi
2. Prometheus Adapter Configuration: Next, to expose the
livekit_egress_available
metric as a Kubernetes custom metric, you’ll want to configure the Prometheus adapter like this:
Copy code
rules:
- seriesQuery: 'livekit_egress_available'
  resources:
    overrides:
      pod: {resource: "pod"}
  name:
    matches: "^livekit_egress_available"
  metricsQuery: 'avg(<<.Series>>{<<.LabelMatchers>>}) by (<<.GroupBy>>)'
3. Deploy the Prometheus Adapter: Now, install the Prometheus adapter in your Kubernetes cluster. Using Helm makes this straightforward:
Copy code
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm install prometheus-adapter prometheus-community/prometheus-adapter -n monitoring
4. Verify Metrics: Finally, let's make sure the
livekit_egress_available
metric is showing up correctly:
Copy code
kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1" | jq .
If you have any questions or need a hand with any of these steps, please don’t hesitate to reach out. I’m here to help!
The
livekit_eggress_available
metric is a Prometheus metric provided by the LiveKit Egress service to help with intelligent autoscaling decisions. It indicates whether an individual Egress instance is available to accept new incoming requests. How it Works: • Each Egress instance evaluates its own CPU utilization and determines availability based on: ◦ Total CPU: The total number of CPUs available on the instance. ◦ Pending CPU: CPU reserved for requests that have been accepted but haven’t started processing yet. ◦ Used CPU: CPU currently being used by active egress processes. ◦ Available CPU: Calculated as
total * MaxCpuUtilization - pending - used
. • Memory constraints are also considered when determining availability. Why Use It: • This metric is more accurate than using average CPU or memory utilization across instances because egress requests are long-running and resource-intensive. • It helps maintain a specific number or percentage of available instances, ensuring your deployment can handle incoming requests efficiently. Usage for Autoscaling: • You can configure autoscaling to use this metric by setting the
custom
option in your Helm chart values. • For example, you can configure it to keep at least 3 instances available or maintain 30% of instances as available. If you'd like, I'm here to help you set up this metric for your deployment—just let me know! Sources: Self-hosting the Egress Service | LiveKit Docs | pkg/server/server_rpc.go
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!