I am trying to understand, which part of Mediasoup SFU server causes CPU or ram utilisation? Is it doing simulcast transcoding with 3 videos or or high resolution or high
bandwidth video or during transmitting the producer to multiple consumers? Doea it do any job other than forwarding the streams?
I am asking this because in the service, we can optimize that part for reducing the CPU usage
Also, how much role CPU vs memory play in Mediasoup?
I am trying to understand, which part of Mediasoup SFU server causes CPU or ram utilisation?
For CPU it’s the active looping each produce/consume. Data must be sent/received. Ram utilization is very minimal, you can expect 512mb-1gb is more than enough per logical core. You’ll mostly be storing little re-transmission data and information about worker/router/transports.
With mediasoup most of your usage will be CPU, there’s not much to optimize this process but perhaps speaking too early cause I’d like to see a decrease in CPU usage.
This is precisely I want to understand in details, to understand the CPU usage:
- Is it more like active looping, where each packet is specifically obtained and then sent to the consumers?
- Or is it, at OS level, forwarding the track to the different UDP ports of the target system (in our case other consumer)?
- Is it looping, because the RTC needs to be encrypted with different credentials to each consumer? I mean does it only change the headers and adds those and forwards the packets to the consumer? (Also in case of Simulcast, only selects the track to send and only change the headers?)
- If looping, does it take more CPU time if the producer resolution is higher? for e.g. CPU time increasing in 1080p video as against 240p?
- When CPU gets full, is it possible that with a setting and trade off on the quality of the video but allow more consumers? Say the drop in frame rate?
- If Simulcast, can we have a setting so that we initially start with the lowest or chosen bandwidth and then it can send higher if needed (specifically asked by consumer) or lower if consumer download bandwidth is choked up?
- If Simulcast, is it spending more CPU in constantly estimating remote consumer bandwidth and taking CPU in each consumer’s processing? If so, it is spending more time because of simulcast?
- Would reducing number of simulcast tracks (3 tracks) to 2 reduce the CPU consumption?
- If retransmissions are allowed, then why? because RTP is supposed to be the real time communication and should be lossy and without retransmission, right?
I am just giving pointer and don’t expect answer to each point above. I rather expect the answer to the main question, what specific part in the SFU is causing higher CPU utilization?
Since, I am no wise in the libraries, this question to the people contributing to the library.
There’s a whole process for how the payload is handled that would be causing that usage. There’s no clearer answer than there’s many things during this handling state that contribute to it. You’d maybe want to check the source out to see for yourself, perhaps something isn’t optimized as well as it could have been.
Any views? I haven’t gone through entire code of mediasoup server, to check what part actually uses CPU? Can someone throw some light?