Hey folks, Livekit has been an awesome platform so far. I was doing some profiling and was seeing egress takes a lot of time to initialize
• startup_total: 4447ms
• start_egress: 1791ms
Is this normal or am i doing something wrong, I am calling this before calling ctx.connect. Is there a way I can start egress in background and call connect at the same time?
c
clever-nail-49292
11/18/2025, 9:32 PM
Hey @kind-policeman-90304 thanks for the report. I have a few questions. May you share some details on how you profiled it? Are you using cloud or self hosted egress? In case you use cloud - may you share egressID for the recording you profiled?
d
dazzling-apartment-68328
11/19/2025, 12:59 AM
I read today that the newer “participantEgress” seems to have less of a startup lag compared to trackComposite egress. Potentially useful. I am using video+audio. not sure if it is applicable in your usecase.
k
kind-policeman-90304
11/23/2025, 12:25 PM
Hi @clever-nail-49292 sorry for the late response here.
I was able to trim off the egress times by doing it in parallel with other parts of the codebase and making it non blocking. We are using Livekit Cloud Growth Plan.
I did however notice that room connection and session connections are now are largest bottlenecks. Room connection came down significantly after turning off noise cancellation.
However it is still somewhat significant compared to other parts of the stack. Can you advice on if there are any steps we could take to mitigate it?
There are roughly the profiled metrics:
• startup_total: 1767ms (0.0%)
• session_start: 653ms (0.0%) [just calls session.start]
• room_connect: 576ms (0.0%) [just calls ctx.connect]
• load_components_parallel: 171ms (0.0%) [load agents, tools, etc from db configs]
• create_agent: 171ms (0.0%) [initialize a livekit agent]
• load_agent: 84ms (0.0%)
• background_audio_start: 62ms (0.0%)
• log_session_started: 46ms (0.0%)
• setup_otel: 3ms (0.0%)
• setup_background_audio: 1ms (0.0%)
kind-policeman-90304
11/23/2025, 12:25 PM
Happy to provide any other details but the code is largely the same as that in the agent reference barring the fact that we dont use noise cancellation. With noise cancellation, room connection takes about 1-2s