Tuesday, February 22, 2022

Azure API Management with Developer Pricing Tier: 504 Gateway Timeout

If you are using Azure API Management with Developer Pricing Tier and it's getting deployed/managed using Azure Resource Manager (ARM) APIs (https://management.azure.com) and your APIs has large schema, you are very likely to get 504 Gateway Timeout errors upon resource management/deployments. 

This is because ARM APIs impose a 2-minute timeout on all operations, and if the API is large, the operation can take more than 2 minutes. Most of the time that's because of SQL bottleneck, as the APIM Developer Pricing Tier uses the Basic SQL Tier which has very limited processing and storage capacity.

Solutions/workarounds,
  • Use your APIM instances' Management API (https://apimname.management.azure-api.net) instead of ARM APIs (https://management.azure.com) to manage your APIM. Direct Management API calls run for as long as needed and are not subject to timeouts.
  • Upgrade APIM instances to larger SKUs. With larger SKU’s we would not have the same issue as those have larger processing and storage capacity.
  • Watch out for what you are returning in your APIs. You might be returning more properties than you really need to. Removing them will reduce the schema size.
As far as I know, Microsoft has plans to make all these ARM operations asynchronous in the near future (no ETA currently), so we are not limited by ARM timeouts.

Hope this will save someone some research time.

Happy Coding.

Regards,
Jaliya

No comments:

Post a Comment