A Http 429 occurs when too many requests are sent to a service or a cluster of services within a certain timeframe. To give you some background. I am working for a construction firm that has to report back technical readiness (TR) and administrative readiness (AR) to its clients. The TR process and the AR process are triggered by an Azure function and they both consist of a sequence of logic apps. Eg. ProcessTREvents, ProcessTRDocuments, ProcessTRDocument and ProcessTRPhoto. Each logic app calls one or more services provided by a system called GoMapForms. The error is: API calls quota exceeded! Maximum admitted 5 per Second. How to solve this?
My first attempt was to open a logic app and change the Http header Connection of each Http Action to close. By changing the connection header, I wanted to make sure the Http connection is closed after each call.
I also made a change in an API App. The Api App also called one of the GMF Http services. By mistake I forgot to set the HttpClient to null at the end of the method, so I did that as well. Unfortunately, this solution didn’t work. Makes sense because the error is not about having too many open connections, it’s about making too many requests.
So, the next idea was to spread the Http calls. Like I said, the TR process and the AR process are triggered by an Azure function. These Azure functions use a time trigger. So, this is what I did:
- First of all I changed the trigger of the TR process to run every 3 minutes. I left the AR process to run every 5 minutes. By doing this, the two processes are not triggered at the same time anymore. Well actually they do every 15 minutes, but that’s a lot less.
- Secondly, I added a delay in the Azure functions. Both the ProcessTREvents and the ProcessAREvents logic apps are called four times per function run. That’s because there are four regions. The region calls were first made in parallel. I changed that to a serial call with a 30 second delay in between.
The last change I made was in the Logic Apps again. Like I said: ProcessTREvents calls ProcessTRDocuments. ProcessTRDocuments calls ProcessTRDocument and ProcessTRPhoto. The call to the child logic apps occurs in loops. At the loop level, you can specify the number of loops that are run in parallel. By default there are 20 parallel runs. In ProcessTREvents and ProcessAREvents I changed that to one, so making a call to ProcessDocuments one-by-one. In ProcessDocuments I changed the setting to 3.