Integration best practice
This document presents the best practice to reliably integrate 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 limit rate is exceeded. If you have higher call rate requirements, please contact Agora technical support.
API | Calling rate limit per project |
---|---|
Create | 50 per second. |
Delete | 50 per second. |
Query | 100 per second. |
Update | 50 per second. |
Maximum number of concurrent tasks
The limitation for concurrent streams is the following:
- 10 for streams with video transcoding
- 50 for streams without transcoding.
For higher quotas, please contact Agora technical support.
Ensure high availability of streaming services
To ensure high availability of streaming services, and to avoid outages caused by regional network failures, Agora provides alternate domain names. Implement the following best practice to switch to an alternate domain name:
-
Based on the geographical location of your source stream, use the primary domain name from the following table:
Geographical area Primary domain name Alternate primary domain name Secondary domain name North America rtls-ingress-prod-na.agoramdn.com
na.rtmpg.rtelink.com
na-backup.rtmpg.rtelink.com
Europe rtls-ingress-prod-eu.agoramdn.com
eu.rtmpg.rtelink.com
eu-backup.rtmpg.rtelink.com
Asia excluding Mainland China rtls-ingress-prod-ap.agoramdn.com
ap.rtmpg.rtelink.com
ap-backup.rtmpg.rtelink.com
Chinese mainland rtls-ingress-prod-cn.agoramdn.com
none rtls-ingress-prod-backup-cn.agoramdn.com
-
If the request using the primary domain name fails, use the same domain to try again.
-
If the attempt still fails again, try the alternate domain name.
Ensure high availability of REST services
Implement the following best practice:
Switch the domain name
To ensure high availability of REST services, Agora enables you to switch domain names when you experience service outage due to regional network failures. Take the following steps to set up and switch your domain name:
-
Set the primary domain name based on the location of your service server:
- If the DNS address of the service server is located in a country or region other than mainland China, set the primary domain name to
api.agora.io
. - If the DNS address of the service server is in mainland China, set the primary domain name to
api.sd-rtn.com
.
- If the DNS address of the service server is located in a country or region other than mainland China, set the primary domain name to
-
If your attempt to initiate a RESTful API request using the primary domain fails, set up your retry strategy as follows:
-
Primary domain retry: Retry using the same primary domain name.
-
Alternate domain retry:
- If the current primary domain name is
api.sd-rtn.com
, useapi.agora.io
as the alternate domain name. - If the current primary domain name is
api.agora.io
, useapi.sd-rtn.com
as the alternate domain name.
- If the current primary domain name is
-
Adjacent domain retry: If alternate domain retry fails, retry using the domain name adjacent to the current region.
For example, suppose your business server is located in Europe. You set the primary domain name to
api.agora.io
, and the business server resolves the primary domain name to Germany. Germany is located in central Europe (api-eu-central-1.agora.io
). The domain name table shows that the adjacent area is West Europe. Use theapi-eu-west-1.agora.io
orapi-eu-west-1.sd-rtn.com
domain name to retry.
-
Precautions
Take the following precautions when setting up your retry strategy:
-
To avoid exceeding the QPS limit with retry requests, best practice is to use a back-off strategy. For example, wait 1 second before you retry for the first time, wait 3 seconds before retrying the second time, and wait 6 seconds before retry a third time.
-
If the request fails because of a network problem rather than a DNS domain name resolution problem, skip alternate domain retry and proceed to adjacent domain retry.
-
Before switching to the region domain name, ensure that the REST services you wish to use, for example, cloud recording or channel management, are deployed in that region.
Domain name table
The following table shows the primary and region domain names for various regions.
Primary domain name | Region domain name | Region |
---|---|---|
api.sd-rtn.com | api-us-west-1.sd-rtn.com | Western United States |
api-us-east-1.sd-rtn.com | Eastern United States | |
api-ap-southeast-1.sd-rtn.com | Southeast Asia Pacific | |
api-ap-northeast-1.sd-rtn.com | Northeast Asia Pacific | |
api-eu-west-1.sd-rtn.com | Western Europe | |
api-eu-central-1.sd-rtn.com | Central Europe | |
api-cn-east-1.sd-rtn.com | East China | |
api-cn-north-1.sd-rtn.com | North China | |
api.agora.io | api-us-west-1.agora.io | Western United States |
api-us-east-1.agora.io | Eastern United States | |
api-ap-southeast-1.agora.io | Southeast Asia Pacific | |
api-ap-northeast-1.agora.io | Northeast Asia Pacific | |
api-eu-west-1.agora.io | Western Europe | |
api-eu-central-1.agora.io | Central Europe | |
api-cn-east-1.agora.io | East China | |
api-cn-north-1.agora.io | North China |
Troubleshooting checklist
Refer to the following checklist to quickly confirm if each integration requirement for ensuring the connectivity and reliability of the Media Gateway service has been met.
# | Importance | Check |
---|---|---|
1 | required | The Media Gateway service has been enabled for your App ID. |
2 | required | The API call rate is below the maximum limit. See API Call Limits for details. |
3 | required | The number of concurrent tasks in a project is less than 50. For details, see the maximum number of concurrent tasks. |
4 | required |
|
5 | optional | If calling the RESTful API fails, troubleshoot as follows:
X-Request-ID from the response header. |
6 | optional | If streaming fails using the RTMP/SRT protocol, please follow the steps below to troubleshoot:
streamKey values. |
7 | Optional | If the streaming service or REST service is unavailable due to network failure, follow the following solutions to troubleshoot:
streamKey values. |