Integration best practices

Updated

Rate limits, high-availability domain strategy, and troubleshooting guidance for Media Gateway in production.

This document presents best practices for reliably integrating Media Gateway in your app. Before reading this document, follow the Media Gateway quickstart to understand the basic process of using Media Gateway.

API call limits

The Agora server limits the call rate of the Media Gateway API and returns the 429 (Too Many Requests) status code when the rate limit is exceeded.

APICalling rate limit per project
Create50 per second
Delete50 per second
Query100 per second
Update50 per second

Maximum number of concurrent tasks

The limitation for concurrent streams is:

  • 10 for streams with video transcoding
  • 50 for streams without transcoding

For higher quotas, contact Agora technical support.

If you use dual-stream high availability, each protected source counts as two streams against this limit: one for the primary push and one for the backup, even while the backup is on standby.

Ensure high availability of streaming services

Agora provides alternate domain names to reduce outages caused by regional network failures.

Geographical areaPrimary domain nameAlternate primary domain nameSecondary domain name
North Americartls-ingress-prod-na.agoramdn.comna.rtmpg.rtelink.comna-backup.rtmpg.rtelink.com
Europertls-ingress-prod-eu.agoramdn.comeu.rtmpg.rtelink.comeu-backup.rtmpg.rtelink.com
Asia excluding Mainland Chinartls-ingress-prod-ap.agoramdn.comap.rtmpg.rtelink.comap-backup.rtmpg.rtelink.com
Mainland Chinartls-ingress-prod-cn.agoramdn.comnonertls-ingress-prod-backup-cn.agoramdn.com

Best practice:

  1. Use the primary domain based on the geographical location of your source stream.
  2. If the request fails, retry using the same primary domain.
  3. If the retry still fails, try the alternate domain name.

For continuous protection against a degraded connection or a mid-broadcast drop, rather than just a failed push, see Dual-stream.

Ensure high availability of REST services

To ensure high availability of REST services, Agora enables you to switch domain names when you experience service outages due to regional network failures.

  • If your service server is outside Mainland China, set the primary domain name to api.agora.io.
  • If your service server is in Mainland China, set the primary domain name to api.sd-rtn.com.

If your primary-domain request fails, use a retry strategy with:

  1. Primary domain retry
  2. Alternate domain retry
  3. Adjacent region domain retry

Precautions

  • Use a back-off strategy to avoid exceeding QPS limits with retry requests
  • If the request fails because of a network problem rather than DNS resolution, skip alternate-domain retry and proceed to adjacent-domain retry
  • Ensure that the REST services you use are deployed in the region you switch to

Troubleshooting checklist

#ImportanceCheck
1requiredThe Media Gateway service has been enabled for your App ID
2requiredThe API call rate is below the maximum limit
3requiredThe number of concurrent tasks in a project is less than 50
4requiredThe region is set to the geographical region of your media stream source, and the code is lowercase
5optionalIf calling the RESTful API fails, use a back-off strategy and inspect the response status
6optionalIf RTMP, SRT, or WHIP streaming fails, ensure that the streaming key has not expired and that OBS frame loss is normal
7optionalIf the streaming or REST service is unavailable due to a network failure, retry with the current primary domain first, then the backup domain