ant-media / Ant-Media-Server

Ant Media Server is a live streaming engine software that provides adaptive, ultra low latency streaming by using WebRTC technology with ~0.5 seconds latency. Ant Media Server is auto-scalable and it can run on-premise or on-cloud.
https://antmedia.io
Other
4.26k stars 626 forks source link

Assign Stream Sources to Specific Node #6712

Open muratugureminoglu opened 2 days ago

muratugureminoglu commented 2 days ago
Agent Murat Ugur linked Freshdesk ticket 134982 for this issue.

alfred-stokespace commented 2 days ago

Adding some more details so folks can identity whether they care about this issue...

summary: You are trying to operate AMS in a two-tier cluster (ie. origin transcoders & edge streamers) while simultaneously utilizing the "Auto Start/Stop Streaming" feature on all your streams. context: Your origin transcoders are big and powerful GPU laden hosts. Your edge streamers are much smaller. You don't want the edge servers performing transcoding, they aren't powered for that. You also don't want to be constantly pulling rtsp streams into the origin servers 24/7. problem: With no viewers/subscribers there is no transcoding going on at the origins (you are using Start/Stop Streaming). When the browser-viewer or "subscriber" requests a stream from any of the edge servers, that edge server becomes the origin server and starts trying to transcode the (in my case rtsp) stream with all the renditions you configured. If your edge server isn't spec'd out for transcoding (which it shouldn't be, since that's the whole point of an edge node, ie. to be smaller) then you end up with an edge node that is overwhelmed and prone to failure. Specifically, in a docker context my AMS 1.9.0 instance edge node was showing a load avg of 5-6 and a CPU% of 60/70% w/4-CPU, 16GB ram rying to pull+transcode two 1080p streams into 3-renditions and after a couple minutes in that state you see stack traces of deadlocks and then eventually the docker container dies. As a non-docker configuration you see a very similar result.

I'll use the diagram from https://antmedia.io/docs/guides/clustering-and-scaling/manual-configuration/cluster-installation/ image

The way I'd like it to behave...

  1. Designate your "favored" origin (I'd be fine with this being expressed as the cluster name) on the stream object but origin-server ip address would also be fine for my use case
  2. You can safely set all those streams to "Auto Start/Stop"
  3. Edge servers takes a request from subscriber/viewers and asks the preferred origin to start transcoding
  4. Edge server grabs the appropriate rendition stream from origin and passes that to the subscriber/viewer.