High CPU usage on server

342 views
Skip to first unread message

Divyanshu Kalra

unread,
Oct 2, 2020, 3:45:33 PM10/2/20
to Ant Media Server
We have a conference app setup, and if 2 people connect, and i share my screen, and then unshare and share again a couple of times, CPU usage of server jumps to 50%+. (CPU config: 4cores, 16gb RAM, AWS). I am using ant-media-server-enterprise-2.1.1-20200902_1011. I am attaching the output of /rest/thread-dump-json if that helps. Also once we end the call, the CPU usage goes back to single digits.
dumpThread.json

Nagendra Kumar

unread,
Oct 2, 2020, 4:14:56 PM10/2/20
to Divyanshu Kalra, Ant Media Server
Hi Divyanshu,

   We are using screenshare with antmedia server. I had the issue of client cpu usage but when we reduced the fps then everything was very good and no issue so far. Server side I am using 4 core 15GB ram all good so far.

Thanks
Nagendra

On Fri, Oct 2, 2020 at 12:45 PM Divyanshu Kalra <kalradi...@gmail.com> wrote:
We have a conference app setup, and if 2 people connect, and i share my screen, and then unshare and share again a couple of times, CPU usage of server jumps to 50%+. (CPU config: 4cores, 16gb RAM, AWS). I am using ant-media-server-enterprise-2.1.1-20200902_1011. I am attaching the output of /rest/thread-dump-json if that helps. Also once we end the call, the CPU usage goes back to single digits.

--
You received this message because you are subscribed to the Google Groups "Ant Media Server" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ant-media-serv...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ant-media-server/5b17471f-4648-49a9-ab72-0f2e0ffd918bn%40googlegroups.com.

Divyanshu Kalra

unread,
Oct 2, 2020, 4:16:56 PM10/2/20
to Ant Media Server
Hey, I am not talking about client cpu usage, we are facing high level of cpu usage on the server. It is normal in the start, but if i toggle screenshare 3-4 times, it suddenly shoots up to 50 - 60%.

Selim Emre

unread,
Oct 2, 2020, 4:21:05 PM10/2/20
to Ant Media Server
Hi kalradivyanshu,

Did you enable Adaptive option? Also which Instance type are you using? Could you please share your console/error logs(based in /usr/local/antmedia/log folder)? 

Best Regards,
Selim

Divyanshu Kalra

unread,
Oct 2, 2020, 4:43:44 PM10/2/20
to Ant Media Server
Hey,
I have adaptive option disabled. t2.xlarge is the aws instance. I have attached all the logs.
errorLogs.txt
threadRaw.txt
threadinfo.txt
accessLogs.txt
cpu.png
threadJSON.txt

ahmet oguz mermerkaya

unread,
Oct 2, 2020, 5:46:14 PM10/2/20
to Ant Media Server
Hi,

Just a reminder,  media streaming and especially the WebRTC streaming is a process intensive operation. It's always good to use Computed Optimized Instance types.
For AWS, you can use C family. 

Secondly, t2 family provides variable CPU and each instance has some CPU credits. Its CPU credit is 54 per hour. 
A CPU Credit provides the performance of a full CPU core for one minute. So baseline performance of t2.xlarge is 54/60 of a CPU core. 
I mean its baseline is almost 1 core CPU. If you don't use the credits, it's accumulated and you can have some spike up to 4 core CPU. 
If you consume all the credits, you can get less CPU than the baseline.  For more information, please take a look the https://aws.amazon.com/ec2/instance-types/#Burstable_Performance_Instances

Please try with C5 or C6 type instance having 4 cores CPU and let us know the results.

Regards,
A. Oguz  

Divyanshu Kalra

unread,
Oct 3, 2020, 6:38:49 AM10/3/20
to ahmet oguz mermerkaya, Ant Media Server
Hey, I shifted to digitalocean, we are now using compute optimized droplet (CPU-Optimized droplet), and still were able to recreate the issue. Can you please look into this?

--
You received this message because you are subscribed to a topic in the Google Groups "Ant Media Server" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ant-media-server/3V8qrmaen8A/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ant-media-serv...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ant-media-server/aef88526-a218-47eb-b501-c11ffb61695cn%40googlegroups.com.

ahmet oğuz mermerkaya

unread,
Oct 3, 2020, 9:19:37 AM10/3/20
to Divyanshu Kalra, Ant Media Server
Hi Divyanshu,

I just need to re-produce the issue on my end. 
Could you please let us have the exact re-produce scenario step by step?

Regards,
A. Oguz 

Divyanshu Kalra

unread,
Oct 3, 2020, 10:52:19 AM10/3/20
to ahmet oğuz mermerkaya, Ant Media Server
 I created a small POC:

I was able to recreate the issue when i used 2 laptops, and connected (using ngrok). Turn screensharing on and off a couple of times, and you will see cpu usage spikes to as high as 60%.

ahmet oğuz mermerkaya

unread,
Oct 4, 2020, 12:47:56 AM10/4/20
to Divyanshu Kalra, Ant Media Server
Thank you. 

I'll try to reproduce on my end. Let me confirm the reproduce scenario. There are some missing parts for me. 

1. Run Ant Media Server in a 4 Core CPU optimized instance in Digital Ocean
2. Deploy the files at antBug.zip to Ant Media Server
3. Turn screen sharing on and off a couple of times

Expected Behavior
CPU usage should be about (let's say) %15

Actual Behaviour
CPU usage goes to %60

I'm not sure about why and how to use ngrok in this scenario above.

Secondly, we encounter that TCP candidates sometimes cause high CPU usage.  Closing TCP cpu candidates resolves unexpected CPU usage. This issue will be investigated. As a workaround, you may try disabling TCP candidates by putting following properties in /usr/local/antmedia/webapps/{YOUR_APP}/WEB-INF/red5-web.properties file and restart the service

settings.webrtc.tcpCandidateEnabled=false

Regards,
A. Oguz

Divyanshu Kalra

unread,
Oct 4, 2020, 2:39:17 AM10/4/20
to ahmet oğuz mermerkaya, Ant Media Server
Will try that, ngrok will be used if you deploy the demo on localhost, no need to use if you are using a server.

ahmet oguz mermerkaya

unread,
Oct 4, 2020, 8:54:15 AM10/4/20
to Ant Media Server
Before trying to it on my end. Just let me ask something. 

You're trying it on localhost are and you also capturing or playing the video on the same host? If yes, capturing video means rendering and encoding the video, playing the video means decoding and rendering the video. These are also process intensive operations for the processing unit. 

Regards,
A. Oguz

Divyanshu Kalra

unread,
Oct 4, 2020, 9:47:57 AM10/4/20
to ahmet oguz mermerkaya, Ant Media Server
I am just showing the localstream in the preview. I doubt that will take the servers cpu.

Divyanshu Kalra

unread,
Oct 4, 2020, 10:04:59 AM10/4/20
to Ant Media Server
I tried the settings.webrtc.tcpCandidateEnabled=false, and it still spiked to 30%+, and stayed there after 10 - 12 mins of call between 2 people with screen shared. Attaching the corresponding htop, when the cpu spiked.
antBug.png

ahmet oğuz mermerkaya

unread,
Oct 4, 2020, 1:10:05 PM10/4/20
to Divyanshu Kalra, Ant Media Server
Yes, showing a local stream takes the server's CPU. 

Anyway,  I have not had time to test your case yet. Let's make things clear . So the following re-produce scenario is true for you? Because it's not clear for me to test on Digital Ocean or local computer or AWS. Let's agree the re-produce scenario 

1. Run Ant Media Server in a 4 Core CPU optimized instance in Digital Ocean
2. Deploy the files at antBug.zip to Ant Media Server
3. Turn screen sharing on and off a couple of times
4. Wait for 10-12 minutes

Expected Behavior
CPU usage should be about (let's say) %15

Actual Behaviour
CPU usage goes to %60

Divyanshu Kalra

unread,
Oct 4, 2020, 1:20:17 PM10/4/20
to ahmet oğuz mermerkaya, Ant Media Server
Yeah, but have more than 2 publishers, one sharing their screen, so total 3 streams (2 camera, 1 screen).

ahmet oguz mermerkaya

unread,
Oct 5, 2020, 12:12:15 PM10/5/20
to Ant Media Server
We'll investigate this case as an issue. Because if we don't schedule, we will burn out. I've almost experienced that a couple of times. 

Selim Emre

unread,
Oct 11, 2020, 8:18:12 AM10/11/20
to Ant Media Server
Hi kalradivyanshu,

Have a good day. I have tried your use case. But I couldn't achieve.

I need to clear about below things:
1- Are you sure about settings.webrtc.tcpCandidateEnabled=false with right application?
2- Did you restart AMS, when you added this parameter in settings?

Looing forward to hearing from you soon.

Best Regards,
Selim

ahmet oğuz mermerkaya

unread,
Oct 12, 2020, 6:11:58 AM10/12/20
to Selim Emre, Ant Media Server
Hey Selim,

Have you tried the exact same scenario with html and js files that Divyanshu provided? Maybe there is a problem in js files that trigger this problem. 

Could you also let us know the results of your tests and steps you've followed?

Regards,
A. Oguz

You received this message because you are subscribed to the Google Groups "Ant Media Server" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ant-media-serv...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ant-media-server/8726de32-e34e-44ac-b7a1-69f459752529n%40googlegroups.com.

Selim Emre

unread,
Oct 12, 2020, 9:19:25 AM10/12/20
to Ant Media Server
Hi Ahmet,

Yes, I tried with provided HTML and js files. 

Here are the steps:

1- I created 4 core Instance on Digital Ocean and Installed AMS 2.1.1 version(added settings.webrtc.tcpCandidateEnabled=false version).Also, I enabled SSL.
2- I installed and configured ngrok for publishing localhost HTML and js files.
3- I published the stream with ubuntu 18.04 and Windows 10 machines with 15 min.
4- I see everything seems normal. Also, I attached htop and other detail images.
error.log
Screenshot from 2020-10-12 16-13-06.png
Screenshot from 2020-10-12 16-13-13.png
console.log
Screenshot from 2020-10-12 16-12-55.png

ahmet oğuz mermerkaya

unread,
Oct 12, 2020, 12:44:39 PM10/12/20
to Selim Emre, Divyanshu Kalra, Ant Media Server
I see. Thank you. 

We cannot create the reproduce scenario. Are we missing something?

Reply all
Reply to author
Forward
0 new messages