high cpu usage

Arsen G.

Member
Dear Max,
I'm writing you again about high cpu usage we are facing from time to time on our server.
At the moment we have 12-14 RTSP streams (HD quality) goes through WCS, our server have 12 cores CPU.
During last few days, after 12-14 hours of working the CPU usage become very high and it's stopping - the ports are remain open, java processes are available, but there is no video and audio.
In this case we need to kill java processes and restart webcallserver service (just restart of service is not help).
Do you have any suggestion on this case?
Thank you.
 

Max

Administrator
Staff member
Hello
To decrease CPU usage you have to
1. Set H.264 codec as priority in flashphoner.properties
Code:
codecs=opus,alaw,ulaw,g729,speex16,g722,mpeg4-generic,telephone-event,h264,vp8,flv,mpv
2. For WebRTC, make sure you DO NOT set resolution when you play stream.
For example
Code:
session.createStream({name:'rtsp://host:554/live.sdp', constraints:{audio:true, video:{width:640,height:480}}}).play();
if you set a resolution, WCS will launch video transcoding even if codecs are equal and you will have high CPU.
3. For iOS Safari (Websocket), you can set playback resolution because it will be transcoded (H.264 > MPEG) anyway.
Here you can see how we set resolution for WSPlayer only in our Player sample:
https://github.com/flashphoner/flas.../examples/demo/streaming/player/player.js#L26
Code:
 if (Flashphoner.getMediaProviders()[0] == "WSPlayer") {
        resolution_for_wsplayer = {playWidth:640,playHeight:480};
    }
https://github.com/flashphoner/flas...examples/demo/streaming/player/player.js#L125
Code:
 if (resolution_for_wsplayer) {
        options.playWidth = resolution_for_wsplayer.playWidth;
        options.playHeight = resolution_for_wsplayer.playHeight;
    }
Regarding server outage (add heap memory),
Try to configure wcs-core.properties
Replace
Code:
-Xmx2048M
with
Code:
-Xms2048M -Xmx8192M
This should prevent often Java GC cycles and reduce CPU usage.
 

Arsen G.

Member
Hello
To decrease CPU usage you have to
1. Set H.264 codec as priority in flashphoner.properties
Code:
codecs=opus,alaw,ulaw,g729,speex16,g722,mpeg4-generic,telephone-event,h264,vp8,flv,mpv
2. For WebRTC, make sure you DO NOT set resolution when you play stream.
For example
Code:
session.createStream({name:'rtsp://host:554/live.sdp', constraints:{audio:true, video:{width:640,height:480}}}).play();
if you set a resolution, WCS will launch video transcoding even if codecs are equal and you will have high CPU.
3. For iOS Safari (Websocket), you can set playback resolution because it will be transcoded (H.264 > MPEG) anyway.
Here you can see how we set resolution for WSPlayer only in our Player sample:
https://github.com/flashphoner/flas.../examples/demo/streaming/player/player.js#L26
Code:
 if (Flashphoner.getMediaProviders()[0] == "WSPlayer") {
        resolution_for_wsplayer = {playWidth:640,playHeight:480};
    }
https://github.com/flashphoner/flas...examples/demo/streaming/player/player.js#L125
Code:
 if (resolution_for_wsplayer) {
        options.playWidth = resolution_for_wsplayer.playWidth;
        options.playHeight = resolution_for_wsplayer.playHeight;
    }
Regarding server outage (add heap memory),
Try to configure wcs-core.properties
Replace
Code:
-Xmx2048M
with
Code:
-Xms2048M -Xmx8192M
This should prevent often Java GC cycles and reduce CPU usage.
Good morning, Max.
I did as you told - changed codec priority in flashphoner.properties and changed configuration in wcs-core.properties.
After this changes the system worked about 10 hours and WCS stopped, there was no any port opened for WCS.
After restarting the webcallserver service everything became OK.
I would like to mention that we do set resolution for WebRTC.
Do you have any ideas?
 

Attachments

Max

Administrator
Staff member
Try to disable sampling.
Code:
stats=false
in flashphoner.properties
It should decrease server load.
This setting requires WCS restart.
 

Arsen G.

Member
Try to disable sampling.
Code:
stats=false
in flashphoner.properties
It should decrease server load.
This setting requires WCS restart.
Good morning, Max.
Just would like to inform you that till now there is no crash in our system, I'll inform you in case of any problem.
Can you please explain how the feature I disabled (stats=false) may affect us?
Thank you.
 

Max

Administrator
Staff member
Hello
Currently we are developing stream monitoring over Dashboard.
If stats=true, WCS core sends a lot of stream sampling data such as NACK, PLI, Width, Height, Bitrate, etc to WCS manager process (Dashboard).
This sampling is too frequent and this causes additional high CPU load about 40% of normal load.
We have disabled stats by default for further builds since 2329
Code:
stats=false
Once we optimize the monitoring feature and complete load tests, we will turn this on again.
 

Arsen G.

Member
Hello
Currently we are developing stream monitoring over Dashboard.
If stats=true, WCS core sends a lot of stream sampling data such as NACK, PLI, Width, Height, Bitrate, etc to WCS manager process (Dashboard).
This sampling is too frequent and this causes additional high CPU load about 40% of normal load.
We have disabled stats by default for further builds since 2329
Code:
stats=false
Once we optimize the monitoring feature and complete load tests, we will turn this on again.
Thank you for explanation, Max!
And thank you very much for your assistance. I'm highly appreciated :)
 
Top